Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Retrieving the VIX term structure from CBOE in R
#@author Bommarito Consulting, LLC;
#@date 20121105
# Imports
# Set RCurl options
options(RCurlOptions = list(timeout = 10, useragent = "Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011 Firefox/16.0.1"))
# Retrieve CBOE VIX term structure page and parse into HTML.
buffer <- getURL("")
doc <- htmlParse(buffer, asText=T)
# Extract the term structure table.
vixTerm <- readHTMLTable(getNodeSet(doc, "//table[starts-with(@id, 'ctl00_')]")[[1]], header=T, colClasses=c('character', 'character', 'numeric', 'numeric'), as.factor=F)
# Clean up and process dates.
names(vixTerm) <- c("tradeDate", "expirationDate", "value", "month")
vixTerm$tradeDate <- as.POSIXct(vixTerm$tradeDate, format="%m/%d/%Y %I:%M:%S %p")
vixTerm$expirationDate <- as.Date(vixTerm$expirationDate, "%d-%b-%y")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.