Financial Analysis Monthly Returns, Object not Found

Hello everybody,

I'm a complete beginner and wanted to recreated what this video https://www.youtube.com/watch?v=2Y4HX0UUcrA shows, only for monthly returns instead of daily.
There are two problems:

  1. Error in Return.portfolio(portfolioReturns) :
    Use a returns series of daily frequency or higher.

Even when changing from "monthly" to "daily" I get this error.

  1. In periodicity(R) : can not calculate periodicity of empty object

It says the object is empty but I'm using the exact code from the video in the link.

---CODE---

library(quantmod)
library(PerformanceAnalytics)

tickers <- c("AAPL",
"V",
"NFC.DE",
"MA",
"ZURN.SW")

weights <- c(0.2, 0.2, 0.2, 0.2, 0.2)
portfolioPrices <- NULL
for(ticker in tickers) {
portfolioPrices <- cbind(portfolioPrices,
getSymbols.yahoo(ticker, from="2010-01-01", periodicity = "daily", auto.assign=FALSE)[.4])
}
portfolioReturns <- na.omit(ROC(portfolioPrices))

colSums(is.na(portfolioPrices))

benchmarkPrices <- getSymbols.yahoo("^GSPC", from="2010-01-01", periodicity = "daily", auto.assign=FALSE)
benchmarkReturns <- na.omit(ROC(benchmarkPrices))
colSums(is.na(benchmarkPrices))

portfolioReturn <- Return.portfolio(portfolioReturns)

CAPM.beta(portfolioReturn, benchmarkReturns, 0.035/12)

CAPM.jensenAlpha(portfolioReturn, benchmarkReturns, 0.035/12)

SharpeRatio(portfolioReturn, 0.035/12)

table.AnnualizedReturns(portfolioReturn)
table.CalendarReturns(portfolioReturn)


Many thanks in advance

Best,

Simon

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.