Back to Community
Recent changes to Yahoo site prevents fetching .csv data for Vix?

Hello,

Has anyone else run into difficulties recently when trying to use fetcher to pull data from Yahoo? I used to run a couple of algos that used fetcher to simply pull Vix open prices direct from Yahoo csv., but the link seems to no longer work (I get a run time error). I've tried replacing the link I previously used with the new link when you navigate to where you would click to download the historical Vix data, but this did not seem to work..

Could anyone please help?

Thanks,
Win

# Sample code to fetch VIX data from Yahoo .csv

def pre_func(df):  
    vix = df['Adj Close']  
    return df

def initialize(context):  
    yahoo_vix_url = "https://ichart.finance.yahoo.com/table.csv?s=%5EVIX&d=8&e=1&f=2018&g=d&a=0&b=1&c=2012&ignore=.csv" # MM-DD-YEAR

    fetch_csv(yahoo_vix_url,  
              date_column='Date',  
              date_format='%Y-%m-%d',  
              symbol='vix',  
              usecols=[],  
              pre_func=pre_func)

def handle_data(context, data):  
    vix_data = data['vix']

    #exit if the vix data was not fetched  
    if (vix_data is None):  
        print("no vix data")  
        return  
    record(price=vix_data['Adj Close'])  
    print vix_data['Adj Close']

6 responses

Yahoo changed the means of fetching their financial data last week. It requires a cookie to be set, so it works fine when you navigate there with a web browser, but an algo fetch will fail. I blame the new owners, Verizon.

Alternatively, you can access the data on Quantopian. https://www.quantopian.com/data/quandl/cboe_vix

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Josh, does that data set still have the problem/issue/feature where for many days in the past, the VIX was not updated because it wasn't allegedly available by midnight the night before?

@josh. Same question: does the quantopian dataset have the same problem?

This site talks about pulling the data from Google Finance instead: https://financialzipline.wordpress.com/blog/ It also looks like stock data can be retrieved from non-US markets and it might be possible to trade other assets like cryptocoins or commodities with zipline if a data source was available. It's definitely much easier to use the Quantopian platform for US-listed stocks, though.

@Peter,

In research notebooks, you have unfettered access to the data. You can execute your ad hoc analysis with the data using the asof_date as the index for your time series. Doing so will avoid any perceived holes in the data set.

In backtesting, we enforce access to the data using the timestamp field so if the CBOE was late to post their data or Quandl was down or Quantopian had difficulty processing the data and the data wasn't available in our system on that particular day at 8:45 (when before_trading_start() runs), then we forward fill the data with the last, best known data point.

With this choice, we're enforcing 'point-in-time' access to the data. So sometimes the data firms update data post-facto and sometimes data firms have operational issues (like those described above). The backtester simulates the best known data point that Quantopian's data processing system knew at the time. I think this is a valid use case -- modeling and simulating both revisions to data and operational hiccups that inevitably happen in the real world.

There's a strong case (as Simon has made in the past) for a different mode in the backtester that ignores these processing problems in the backtester for certain classes of analysis. We've not yet added that to the product.

But you can certainly execute analyses outside the backtester in a research notebook that ignores the point-in-time aspect.

Thanks
Josh