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

Hi all, Cant get data from Quandl with this code, i get the: Runtime exception: KeyError: 'Equities'

import pandas as pd  
urla ='http://www.quandl.com/api/v1/datasets/ISE/EQU_SI.csv?trim_start=2011-01-01'  
def initialize(context):  
    fetch_csv(urla, symbol='advn', date_column="Date")  
def handle_data(context, data):  
  advn = data['advn']['Equities']

Same issue with trying to get in csv from dopbox. Trying to get "dma" column from csv (i know its there):
import pandas as pd urla ='https://www.dropbox.com/s/92impo9rk7bmh1w/NYAD_Data.csv' def initialize(context): fetch_csv(urla, symbol='advn', date_column="Date", date_format = '%y-%m-%d') def handle_data(context, data): advn = data['advn']['dma']

3 responses

Darell,
I think the problem is that there are no referenced securities in this algorithm so there is no universe for data to pass in. I added a security reference and it looks like it is working.

David

Thanks, it plots well now. Please take a look if i use it correctly, tried to lift it out of the If statement, thanks

import pandas as pd  
urla ='http://www.quandl.com/api/v1/datasets/ISE/EQU_SI.csv?trim_start=2011-01-01'

def initialize(context):  
    fetch_csv(urla, symbol='advn', date_column="Date")  
    context.stock = symbol('SPY')  
    context.signal = None

def handle_data(context, data):  
    advn = data['advn']  
    if "Equities" in advn:  
        context.signal = advn['Equities']  
    # Trying to use the equities data as part of a signal calc here  
    signalx = context.signal * 123  
    record(Signal = signalx)  

Hi Darell and David,

I have the same issue. I'd like to use the data with symbol 'CLZ15' (Crude Oil Dec 2015 Future), there is no such symbol in the quantopian database. What do you mean that there is no universe for data to pass in since there is no referenced symbol in this algorithm. Following is my code:

def initialize(context):  
    url = 'https://copy.com/oJWlFssZuibJcObZ'  
    fetch_csv(url,  
              date_column = 'tradingDay',  
              date_format = '%m/%d/%y',  
              symbol ='CLZ15')  
def handle_data(context, data):  
    # Implement your algorithm logic here.  
        print (data['CLZ15']['close'])  

Whenever I run this code, it says:" Runtime exception: KeyError: ''close". But once I change it to the following, it works:

def initialize(context):  
    url = 'https://copy.com/oJWlFssZuibJcObZ'  
    fetch_csv(url,  
              date_column = 'tradingDay',  
              date_format = '%m/%d/%y',  
              symbol ='CLZ15')  
     context.stock = symbol('SPY')  
def handle_data(context, data):  
    # Implement your algorithm logic here.  
        print (data['CLZ15']['close'])  

Thank you very much