<commit_before># -*- coding: utf-8 -*-
"""
toolset working with cboe data

@author: <NAME>
Licence: GPL v2
"""

from datetime import datetime, date
import urllib2
from pandas import DataFrame, Index
import numpy as np



def getHistoricData(symbol):
    ''' get historic data from CBOE
        symbol: VIX or VXV
        return dataframe
    '''
    urls = {'VIX':'http://www.cboe.com/publish/ScheduledTask/MktData/datahouse/vixcurrent.csv', \
            'VXV':'http://www.cboe.com/publish/scheduledtask/mktdata/datahouse/vxvdailyprices.csv' }
    
    urlStr = urls[symbol]
    
    try:
        lines = urllib2.urlopen(urlStr).readlines()
    except Exception, e:
        s = "Failed to download:\n{0}".format(e);
        print s
        
    header = ['open','high','low','close']   
    dates = []
    data = [[] for i in range(len(header))]
     
    for line in lines[1:]:
        fields = line.rstrip().split(',')
        dates.append(datetime.strptime( fields[0],'%m/%d/%Y'))
        for i,field in enumerate(fields[1:]):
            data[i].append(float(field))
        
    
    
    return DataFrame(dict(zip(header,data)),index=Index(dates)).sort()<commit_msg>fixed format change in vxv (cboe.py)<commit_after># -*- coding: utf-8 -*-
"""
toolset working with cboe data

@author: <NAME>
Licence: GPL v2
"""

from datetime import datetime, date
import urllib2
from pandas import DataFrame, Index
import numpy as np



def getHistoricData(symbol):
    ''' get historic data from CBOE
        symbol: VIX or VXV
        return dataframe
    '''
    urls = {'VIX':'http://www.cboe.com/publish/ScheduledTask/MktData/datahouse/vixcurrent.csv', \
            'VXV':'http://www.cboe.com/publish/scheduledtask/mktdata/datahouse/vxvdailyprices.csv' }
    
    startLine = {'VIX':1,'VXV':2}    
    
    urlStr = urls[symbol]
    
    try:
        lines = urllib2.urlopen(urlStr).readlines()
    except Exception, e:
        s = "Failed to download:\n{0}".format(e);
        print s
        
    header = ['open','high','low','close']   
    dates = []
    data = [[] for i in range(len(header))]
     
    for line in lines[startLine[symbol]:]:
        fields = line.rstrip().split(',')
        dates.append(datetime.strptime( fields[0],'%m/%d/%Y'))
        for i,field in enumerate(fields[1:]):
            data[i].append(float(field))
        
    
    
    return DataFrame(dict(zip(header,data)),index=Index(dates)).sort()
{'fraction_non_alphanumeric': 0.1544481054365733, 'fraction_numerical': 0.00700164744645799, 'mean_word_length': 2.6526315789473682, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6904240', 'n_tokens_mistral': 841, 'n_tokens_neox': 814, 'n_words': 170}