Getting Data For Multiple Assets (With Calculations): R For Finance
codebliss codebliss
10.7K subscribers
7,782 views
128

 Published On Sep 28, 2017

In this tutorial, we will obtain data for a vector of tickers and perform different periodic calculations on them. We use the ROC method initially, but we find we are limited if we want to calculate monthly or weekly returns for our portfolio. We can use the dplyer library in order to chain the getSymbols function with the periodReturn method in order to get our desired frequency returns for the portfolio. The dplyer library is especially useful for operating on dataframes. In this case, it is used in conjunction with a forward-pipe operator in order to chain two functions together. The function we are using to calculate returns in this script is monthlyReturn(dataframe) which is essentially the same thing. Just a heads up, the forward pipe operator may have different significance within different libraries that utilize them.

Source Code and Blog Post: http://programmingforfinance.com/2017...

My Website: http://programmingforfinance.com/

show more

Share/Embed