Created
August 17, 2012 15:46
-
-
Save choffstein/3380026 to your computer and use it in GitHub Desktop.
Fetch historical VIX data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
months = ["F","G","H","J","K","M","N","Q","U","V","X","Z"] | |
years = ["04","05","06","07","08","09","10","11","12"] | |
for year in years: | |
for month in months: | |
filename = "CFE_" + month + year + "_VX.csv" | |
url = "http://cfe.cboe.com/Publish/ScheduledTask/MktData/datahouse/" + filename | |
try: | |
response = urllib2.urlopen(url) | |
if response.code == 200: | |
data = response.read() | |
f = open(filename, "w") | |
f.write(data) | |
f.close() | |
except: | |
continue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment