Portfolio Theory Dr. Andrea Rigamonti andrea.rigamonti@econ.muni.cz Seminar 1 Content: • R in a nutshell • Obtaining financial data R in a nutshell • R is a programming language mostly used for statistical computing and graphics. • Freely available at: https://www.r-project.org/ • Huge (and ever increasing) amount of packages. • Active online community (e.g. on stackoverflow: https://stackoverflow.com/) • Not very user friendly at the beginning. • There are many guides available online. This is one: https://cran.r-project.org/doc/manuals/r-release/R-intro.pdf (but look for the one that suits you best) R in a nutshell • You should also install RStudio, a very useful IDE (also free) that makes working with R much more comfortable: https://www.rstudio.com/ • A collection of packages under the name tidyverse is now commonly used for data science and finance: www.tidyverse.org • R Markdown allows you to interactively create documents directly from RStudio. You can check this book: https://bookdown.org/yihui/rmarkdown/ Obtaining financial data Unadjusted stock prices are easily available online, but they should not be used: we need data adjusted for dividends and stock splits. • There are many professional data providers, but most are very expensive. E.g. Datastream or Bloomberg • Data from there usually also require to be cleaned (for missing and/or wrong data) • Yahoo finance provides free data, but maybe not the most reliable source Obtaining financial data A good alternative is Alpha Vantage: https://www.alphavantage.co/ • Many data are free. Other require a cheap subscription. • Not a huge variety of data, but no need for cleaning • Very easy to download data directly in R thanks to the "alphavantager" R package Fama-French factors are available at the French data library: https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ data_library.html Factors for Germany from HU Berlin (might not be as reliable as US factor data): https://www.wiwi.hu-berlin.de/de/professuren/bwl/bb/daten/data-library Obtaining financial data Other free sources a various financial data: • https://www.openassetpricing.com/ • https://www.msci.com/ • https://fred.stlouisfed.org/