I know I can't use data.history with fetcher, but does anyone have a simple workaround? The most recently posted examples that I found have deprecated code and are very complex (I'm a beginner). The code below is trying to calculate a moving 60-day average of the 30-yr Treasury yields.
Alternatively, if I know a specific date of the data I want, how would I get that single date's value?
def preview(df):
log.info(' \n %s ' % df.head())
return df
def postview(df):
log.info(' \n %s ' % df.head())
return df
def initialize(context):
long_url='https://www.quandl.com/api/v3/datasets/YAHOO/INDEX_TYX.csv?api_key=r85Zyd1sc9d4gBebFSFy' #treasury yield
fetch_csv(long_url, pre_func=preview, post_func=postview, date_column = 'Date', symbol='tyx')
def before_trading_start(context, data):
"""
Called every day before market open.
"""
hist = data.history('tyx', 'Close', 60, '1d')
print hist.mean()