Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Csv import, simple question

Hi, Trying to get started with importing csv data. Just want to use data from a column as a signal to trigger a trade is something else, not link it to any ticker available in quantopian. I can write the trigger code once i have the csv data flowing in correctly.

Thanks

Heres the code, i have error on the row where i define vix_close

import pandas as pd

vxurl ='http://www.quandl.com/api/v1/datasets/YAHOO/INDEX_VIX.csv?request_source=python&request_version=2&sort_order=asc&trim_start=2002-01-01'

def initialize(context):  
    # Only need data from csv as a signal, not as a ticker  
    fetch_csv(  
        vxurl,  
        symbol='MySymbolName',  
        date_column='Date',  
    )

def handle_data(context, data):  
  # VIX_Close is the column name of what i want into the algo  
    vix_close = data['MySymbolName']['VIX_Close']  
    record(VixValuePlot = vix_close)  
2 responses

Hey Darell,
'VIX_Close' is not an actual column in the dataframe so you are getting a KeyError. That being said, I still get the error when using the right column name, but you can check if the data exists like I did in the backtest. I have run into this before, it only seems to happen on the first bar. Hope this helps.

David

This works, Thanks so much David