I'm just trying to understand based on the examples here and in the docs how to implement fetcher and I seem to have encountered an error right out of the gate which I can't quite understand.
This is what I've setup from the examples provided...
def rename_col(df):
df = df.rename(columns={'Value': 'value'})
df = df.fillna(method='ffill')
df = df[['value', 'sid']] # really not quite sure what this part is for.
log.info(' \n %s '% df.head())
return df
def initialize(context):
fetch_csv('http://www.quandl.com/api/v1/datasets/BUNDESBANK/BBK01_WT5511.csv?trim_start=2012-01-01',
date_column='Date',
symbol='gold',
usecols=['Value'],
post_func=rename_col,
date_format='%Y-%m-%d'
)
def handle_data(context, data):
context.trading_days += 1
if data['gold']['sid']:
log.debug("--> %s"%data['gold'])
running the above returns what I think I would expect...
DEBUG--> SIDData({'returns': <function _transform at 0x6b2e410>, 'vwap': <function _transform at 0x6b2ea28>, 'stddev': <function _transform at 0x6b2e1b8>, 'sid': 'gold', 'source_id': 'PandasRequestsCSV82c479a46aedae750f001c48634ec100', 'dt': Timestamp('2013-01-04 00:00:00+0000', tz='UTC'), 'mavg': <function _transform at 0x6b2e938>, 'type': 9, 'value': 1632.25, 'datetime': Timestamp('2013-01-04 00:00:00+0000', tz='UTC')})
and when I check, I see that data['gold']['sid'] == gold
however, I get a Key error if I try and access data['gold']['value'] or data['gold'].value
from the examples I've seen here it seems like this should actually work.