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

Clone Algorithm
6
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5744a330a3cf360f8a68161f
There was a runtime error.
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.