Skip to content

Instantly share code, notes, and snippets.

@jaredwoodard
Created October 19, 2012 01:57
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaredwoodard/3915846 to your computer and use it in GitHub Desktop.
Save jaredwoodard/3915846 to your computer and use it in GitHub Desktop.
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