Hi guys,
Does anybody know why I get different outputs from these in research against the backtester?
In Research I am running:
import pandas as pd
import datetime
fundamentals = init_fundamentals()
today = (datetime.datetime.now()-datetime.timedelta(days=2)).strftime('%Y-%m-%d')
period_of_interest = (datetime.datetime.now() - datetime.timedelta(days=8)).strftime('%Y-%m-%d')
daily_query = get_fundamentals(query(fundamentals.asset_classification.morningstar_industry_code,
fundamentals.balance_sheet.total_assets,
fundamentals.financial_statement_filing.file_date,
fundamentals.valuation.market_cap)
.filter(fundamentals.valuation.market_cap > 1)
.filter(fundamentals.financial_statement_filing.file_date > period_of_interest)
.order_by(fundamentals.valuation.market_cap.desc())
.limit(1),
today)
print daily_query
which (running on 25 Aug) I believe gives me the last filing for the largest market cap if it is within 6 days of the 23rd (as in the last full run date available in the back tester)
The output is:
security Equity(8229 [WMT])
morningstar_industry_code 20533079
total_assets 1.9862e+11
file_date 2015-08-18
market_cap 220833020999
In the back tester I am running (23rd to 24th):
import pandas as pd
import datetime
def initialize(context):
pass
def handle_data(context, data):
pass
def before_trading_start(context):
#today = datetime.datetime.now().strftime('%Y-%m-%d')
period_of_interest = (datetime.datetime.now() - datetime.timedelta(days=8)).strftime('%Y-%m-%d')
daily_query = get_fundamentals(query(fundamentals.asset_classification.morningstar_industry_code,
fundamentals.balance_sheet.total_assets,
fundamentals.financial_statement_filing.file_date,
fundamentals.valuation.market_cap
)
.filter(fundamentals.valuation.market_cap > 1)
.filter(fundamentals.financial_statement_filing.file_date > period_of_interest)
.order_by(fundamentals.valuation.market_cap.desc())
.limit(1)
)
print daily_query
update_universe(daily_query.columns.values)
There is no output to the log and I do not appear to have any securities in my universe. Does anyone know what I am not understanding about how it works?