Quantmod's getSymbols() fetches historical prices up till yesterday's close. I do my analysis in the morning and would like to update the series with the current quote (I only use adjusted prices). I can't seem to get it to work. When I use this code :
getSymbols('AGNC')
q <- getQuote('AGNC')
d <- Sys.Date()
qq<- q$Last
x <- zoo(qq,d)
t <- rbind.zoo(Ad(AGNC), x)
print(tail(t))
It prints out OK, but when I try to do something further, like:
dum <- dailyReturn(t)
I get the following error:
Error in colnames<-(*tmp*, value = "daily.returns") :
attempt to set colnames on object with less than two dimensions
Any ideas?
library(quantmod)
getSymbols('AGNC')
q <- getQuote('AGNC')
d <- Sys.Date()
qq<- q$Last
x <- xts(qq,d)
t <- rbind(Ad(AGNC), x)
print(tail(t))
dailyReturn(t)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With