library("quantmod")
myStocks <- c("AAPL", "PLTR", "TSLA", "SBUX", "BA", "SLV", "GDX", "ATVI", "BAC")
getSymbols(myStocks, src="yahoo", from="2020-01-01", to="2022-01-01")
myRetData <- data.frame(as.xts(merge(dailyReturn(AAPL), dailyReturn(TSLA), dailyReturn(SBUX),
dailyReturn(BA), dailyReturn(SLV), dailyReturn(PLTR),
dailyReturn(GDX), dailyReturn(ATVI), dailyReturn(BAC))))
colnames(myRetData) <- myStocks
myRetData
My issue is that SLV return values all appear as N/A. If I change the year from 2020 - 2022 to 2021-2022 everything works fine but for some reason it won't work over a two year time frame. If I remove SLV from the portfolio, a different column (eg - BA) will change all the return values to N/A instead. Is there any way around this and what is wrong with my code? Thanks for any help