
Reproducible Finance with R
Code Flows and Shiny Apps for Portfolio Analysis
- 230 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Reproducible Finance with R
Code Flows and Shiny Apps for Portfolio Analysis
About this book
Reproducible Finance with R: Code Flows and Shiny Apps for Portfolio Analysis is a unique introduction to data science for investment management that explores the three major R/finance coding paradigms, emphasizes data visualization, and explains how to build a cohesive suite of functioning Shiny applications. The full source code, asset price data and live Shiny applications are available at reproduciblefinance.com. The ideal reader works in finance or wants to work in finance and has a desire to learn R code and Shiny through simple, yet practical real-world examples.
The book begins with the first step in data science: importing and wrangling data, which in the investment context means importing asset prices, converting to returns, and constructing a portfolio. The next section covers risk and tackles descriptive statistics such as standard deviation, skewness, kurtosis, and their rolling histories. The third section focuses on portfolio theory, analyzing the Sharpe Ratio, CAPM, and Fama French models. The book concludes with applications for finding individual asset contribution to risk and for running Monte Carlo simulations. For each of these tasks, the three major coding paradigms are explored and the work is wrapped into interactive Shiny dashboards.
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Information
xts world. xts is both a package and a type of object. xts stands for extensible time series. Most of our work in this book will be with time series, and indeed most financial work involves time series. An xts object is a matrix, that also, always, has a time index for the order of the data. It holds a time series, meaning it holds the observations and the times at which they occurred. An interesting feature of an xts object is that it holds dates in an index column. In fact that index column is considered column number zero, meaning it is not really a column at all. If we have an object called financial_data and wanted to access the dates, we would use index(financial_data).xts object but not have a date index. If the date index were its own column, that would imply that it could be deleted or removed.xts world, there are two crucial packages that we will use: quantmod and PerformanceAnalytics. quantmod is how we will access the internet and pull in pricing data. That data will arrive to us formatted as an xts object.PerformanceAnalytics, as the name implies, has several useful functions for analyzing portfolio performance in an xts object, such as StdDev(), SharpeRatio(), SortinoRatio(), CAPM.Beta(). We will make use of this package in virtually all of the chapters.dplyr package for data wrangling, transformation and organizing. dplyr does not have built-in functions for our statistical calculations, but it does allow us to write our own functions or apply some other package’s functions to our data.tibble. Throughout this book, I will use those two interchangeably: data frame = tibble in this book.(1) each variable has its own column(2) each observation is a row(3) each value is a celltidyquant, which includes the tidyquant, timetk and tibbletime packages. This universe takes a lot of the best features of xts, PerformanceAnalytics and the tidyverse and lets them play well together. For example, tidyquant allows us to apply a function from PerformanceAnalytics to a tidy data frame, without having to convert it to an xts object.xts, solve it via tidyverse, solve it via tidyquant and verify that the results are the same. In this way, we will become familiar with data in different formats and using different paradigms.xts objects using the highcharter package and tidy objects using the ggplot2 package.highcharter is an R package but Highcharts is a JavaScript library - the R package is a hook into the JavaScript library. Highcharts is fantastic for visualizing time series and it comes with great built-in widgets for viewing different time frames. I highly recommend it for visualizing financial time series but you do need to buy a license to use it in a commercial setting.ggplot2 is itself part of the tidyverse and as such it works best when data is tidy (we will cover what that word ‘tidy’ means when applied to a data object). It is one of the most popular data visualization packages in the R world.install.packag...Table of contents
- Cover
- Half Title
- Title Page
- Copyright Page
- Dedication
- Table of Contents
- Preface
- About the Author
- 1 Introduction
- Returns
- Concluding Returns
- Risk
- Concluding Risk
- Portfolio Theory
- Concluding Portfolio Theory
- Practice and Applications
- Concluding Practice Applications
- Appendix: Further Reading
- Index