Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
data.fetcher_assets doesn't work

symbol start_date stock_score
AA 2/13/2012 0.876536739
WFM 2/13/2012 0.056418644
FDX 2/14/2012 0.976608748
M 2/15/2012 0.352700668
AAPL 2/16/2012 0.718324572

I want to use fetche_csv to save a csv file into pandas data frame like above. Then I define a function(get_stock_length)to be called each day.
I expect the result should be:

2/13/2012: AA, WFM length 2
2/14/2012: FDX length 1
2/15/2012: M length 1
2/16/2012: AAPL length 1

The printed result gives me:
2/13/2012 length 2
2/14/2012 length 3
2/15/2012 length 4
2/16/2012 length 5

As you can see from the backtest , the green line keeps going upward, meaning data.fetcher_assets keeps appending symbols and gets larger and larger. Any ideas of how to fix it? Thanks in advance

3 responses

I could be wrong but this is how I understand it: If you have a dated list of securities you are bringing in with fetch_csv it only gives you the fetcher data on or after those dates. So on the 13th you have 2 stocks on your list that are dated the 13th or earlier, on the 14th you have 3 stocks because you added one on the 14th to the two on the 13th already there. etc.

The reason is so that you don't have future biased information about your signal.

If your entire CSV is
AA 2/13/2012 0.876536739
WFM 2/13/2012 0.056418644
FDX 2/14/2012 0.976608748
M 2/15/2012 0.352700668
AAPL 2/16/2012 0.718324572

and you kept running the backtest beyond 2/16/12 the length should stay at 5 forever, until you remove those securities from your CSV

has this been figured out? I'm hitting this as well

same here. It looks like data.fetcher_assets not only counts securities in current simulation time but also all previous securities.