Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
pulls csv files from the CBOE and converts them to xts
library("quantmod")
# we're pulling the Google VIX index (VXGOG) but this also works for VXAPL, VXGS etc.
# see http://www.cboe.com/micro/equityvix/introduction.aspx
url <- "http://www.cboe.com/publish/ScheduledTask/mktdata/datahouse/VXGOGDailyPrices.csv"
symb = read.csv(url,header=FALSE, stringsAsFactors=F)
symb <- symb[-1,]
colnames(symb) <- c(symb[1,])
symb <- symb[-1,]
#associates the Date column as the date for the other columns
symb$Date <- as.Date(symb$Date, format='%m/%d/%Y')
symb[,2:5] <- data.frame(sapply(symb[,2:5],as.numeric),stringsAsFactors=F)
#makes the OHLC xts
symb <- xts(symb[,2:5], order.by=symb$Date, frequency='d')
chart_Series(symb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.