Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Faster history building ?

If you run this code, live or backtest it takes 5 weeks before it starts trading (you can also lower the number but the results are worse, is there any way you can force the code to use the data of the past 5 weeks instead of having to gather data for 5 weeks ?

    context.past_queries.append(indicator)  
    if len(context.past_queries) > 5:  
        del context.past_queries[0]  
    if len(context.past_queries) == 5:  
        mean_indicator = np.mean(context.past_queries)  
4 responses

Just call data.history.

Alright that fixed it, cheers ! :D

Just to add, one really shouldn't store anything price-derived in context, ever. What you get from history could change from one day to the next, due to a dividend or split, so anything saved in context from yesterday will be totally incongruous.

Just recalculate everything every time you need it.

Ok I'll try that tomorrow, I'm to tired right now.
Cheers for the tip !