For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Indicators problem

  • When using 10 years intraday data (1-minute resolution) for a backtest of 5 years and indicators with periods such as 730 days - backtrader loads extremely slowly to the point where I have to wait 4-5 hours to actually start getting results from the test.

    In BT we have to specify fromdate/todate during the data feed creation so the test starts and ends at the periods needed, but that brings a problem to indicators with long periods ( I load the indicators in strategy's init() ) - with that in mind the backtest starts 730 days after dataset's "fromdate" making the test useless by cutting it in half because the indicator doesn't have data 730 days before "fromdate" of the dataset.

    And another problem related to this - right now in order to run a backtest of 5 years with 730 days indicator I have to set fromdate 2 years before the actually needed start date, resulting in graphs starting with 2 years of nothing...

    Any way of fixing that?

    For example in zipline - result = data.history(ticker, 'open', 730, '1d') works extremely fast, and is not limited by the fromdate/todate period of the dataset/backtest - instead the data.history() method has access to the whole dataset so indicators are immediately available on the first day of the backtest, and extremely fast too.

    Is something like this planned for backtrader? Are there any "hacks" to achieve this (other than running the backtest data few years before it is actually needed for the test)?

    Also, do indicators take into account trading calendars when selecting the 'period' days ? Sometimes I'm getting very weird results with days missing - the data for the day is there, but nothing gets done (nothing in the log from next()), it's like the day is skipped for some reason.

Log in to reply