Hi Jamie.
I think I get your idea. But even if I add 'context.stock = symbol('SPY'), in my initialize method, I sill could not get the data. Here is the code:
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):
if 'Closing_Data' in data['CLZ15']:
# record(close = data['CLZ15']['close'])
print ('data detected')
else:
print('No data detected')
All the logs you could see is like this: "PRINT No data detected", which means that the fetch_csv doesn't work. I've searched the forum and found one has a similar question like me. Here is the link: https://www.quantopian.com/posts/csv-fetch-not-working. In this post, Alisa said that it needs to be a "pure" CSV , so I created the file on http://www.copy.com. But sill it doesn't work. Now the weirdest thing happens:
import pandas as pd
from pytz import timezone
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.sec = symbol('SPY')
def handle_data(context, data):
advn = data['advn']
# There was a KeyError on the first bar if this check isn't here.
if 'Close' in advn:
print ('data detected')
else:
print ('no data detected')
This is the code where I get from the link I mentioned and modify a little bit (no rename_col function), when I run this code, it could get the data and print it on log. But when I change the url, for example I would like to download 'INDEX_GSPC' data from quandl, it doesn't work again.
import pandas as pd
urla ='https://www.quandl.com/api/v3/datasets/YAHOO/INDEX_GSPC.csv?start_date=2014-01-01&end_date=2015-08-27'
def initialize(context):
fetch_csv(urla, symbol='advn', date_column="Date")
context.sec = symbol('SPY')
def handle_data(context, data):
advn = data['advn']
if 'Close' in advn:
print ('data detected')
print (advn['Close'])
else:
print ('no data detected')
I simply change the url, it now says "no data detected". I am so confused since I don't know what is going on. The same code syntax, different URL for different data on Quandl, different results. This thing are driving me crazy. Could anybody explain this for me?
Thank you very much.