I am trying to get access to the fama french factors from quandl
Using the code below the df seems to preview ok and I can print that days data with "print data['FAMA_FRENCH']" and I can see the various factors.
But if I try:
data['FAMA_FRENCH'].HML #attribute error
data['FAMA_FRENCH']['HML'] #attribute error
getattr(data['FAMA_FRENCH'],'HML') # Not allowed
My aim would be to have a dataframe of the daily factors prior to this day (for some lookback period).
How is best to do this? Am I just going about it the wrong way?
def initialize(context): fetch_csv('https://www.quandl.com/api/v1/datasets/KFRENCH/FACTORS_D.csv?sort_order=asc&trim_start=2002-01-01', symbol = 'FAMA_FRENCH', date_column = 'Month', date_format = '%Y-%m-%d', post_func=preview) def preview(df): log.info(df.head()) return df # Will be called on every trade event for the securities you specify. def handle_data(context, data): print data['FAMA_FRENCH'] order(sid(24), 0) # It seems to skip handle_data if you don't have an order function