

Now, on to constructing a portfolio and calculating volatility. Take a quick look at the monthly returns above, to make sure things appear to be in order. Head(portfolio_component_monthly_returns_xts) # AGG DBC EFA SPY VGT # Convert back to an xts, so we can use the cov() and StdDev() functions. Tq_transmute(mutate_fun = periodReturn, period = "monthly") %>% # a different time period like weekly or yearly. # Use the function from tidyquant note how easily we could change to # We need to gather into long format in order to use tq_transmute(). # I like to have the date column as the first column. # Remove the row.names column it's not needed anymore. # Convert to tibble so can stay in the tidyquant/verse. Let’s import prices and save them to an xts object. Those are AGG (a US bond fund), DBC (a commodities fund), EFA (a non-US equities fund), SPY (an S&P500 ETF), VGT (a technology fund). On to step 1, wherein we import prices and calculate returns for the 5 ETFs to be used in our portfolio.


R users with experience in the world of volatility may wish to skip this post and wait for the visualizations in the next one. Minimum Variance Portfolio: find minimum variance portfolio weightsĪ quick word of warning: this series begins at the beginning with portfolio standard deviation, builds up to a more compelling data visualization in the next post, and finally a nice Shiny app after that.
