sp500 | R Documentation |
This data set consists of (monthly) values of the S&P 500 stock exchange index. The variable of interest is the logarithm of the return values, i.e., the logarithm of the ratio of indices, in this case the closing index is used.
data(speed)
A data frame with 744 observations and 6 variables.
Open
Index at the start of trading.
High
Highest index.
Low
Lowest index.
Close
Index at the close of trading.
Volume
The volume of trading.
logret
The log return of the closing index.
Yahoo Data.
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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.