# Tidy Portfoliomanagement in R

*2018-09-21*

# Preface

This book should accompany my lectures “Research Methods”, “Quantitative Analysis”, “Portoliomanagement and Financial Analysis” and (to a smaller degree) “Empirical Methods in Finance”. In the past years I have been a heavy promoter of the Rmetrics tools for my lectures and research. However, in the last year the development of the project has stagnated due to the tragic death of its founder Prof. Dr. Diethelm Würtz. It therefore happened several times that code from past semesters and lectures has stopped working and no more support for the project was available.

Also, in the past year I have started to be a heavy user of the `tidyverse`

and the financial packages that have been developed on top (e.g. `tidyquant`

). Therefore I have taken the chance, to put together some material from my lectures and start writing this book. In structure it is kept similar to the excellent RMetrics book Würtz et al. (2015) on Portfolio Optimization with R/Rmetrics, that I have been heavily using and recommending to my students in the past years!

## Why read this book

Because it may help my students :-)

## Structure of the book

Not yet fixed. But the book will start with an introduction to the most important tools for the portfolio analysis: timeseries and the `tidyverse`

. Afterwards, the possibilities of managing and exploring financial data will be developed. Then we do portfolio optimization for mean-Variance and Mean-CVaR portfolios. This will be followed by a chapter on backtesting, before I show further applications in finance, such as predictions, portfolio sorting, Fama-MacBeth-regressions etc.

## Prerequisites

To start, install/load all necessary packages using the `pacman`

-package (the list will be expanded with the growth of the book).

```
pacman::p_load(tidyverse,tidyquant,PortfolioAnalytics,quantmod,PerformanceAnalytics,
tibbletime,timetk,ggthemes,timeDate,Quandl,alphavantager,readxl,FFdownload,broom,
DEoptim,pso,GenSA,Rglpk,ROI,ROI.plugin.glpk,ROI.plugin.quadprog,doParallel)
```

## Acknowledgments

I thank my family…

I especially thank the developers of:

- the excellent fPortfolio-Book
- the
`tidyquant`

package and its vignettes - the
`PerformanceAnalytics`

developers and the package vignettes - the
`portfolioAnalytics`

developers (currently working very hard on the package) and its package vignettes

Sebastian Stöckl University of Liechtenstein Vaduz, Liechtenstein

### References

Würtz, Diethelm, Yohan Chalabi, William Chen, and Andrew Ellis. 2015. *Portfolio Optimization with R/Rmetrics*. Rmetrics.