# NOT RUN {
data(sp500)
# the data can be made with the following code (eg to include a longer or
# shorter time span)
# }
# NOT RUN {
require(TTR)
# load SP500 returns
Sys.setenv(tz='UTC')
sp500 <- getYahooData('^GSPC',start=19500101,end=20120228,freq='daily')
ep <- endpoints(sp500, on="months", k=1)
sp500 <- sp500[ep[2:(length(ep)-1)]]
sp500$sp500_ret <- log(sp500$Close) - lag(log(sp500$Close))
sp500 <- na.exclude(sp500)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab