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

Different number of instruments available over time

  • I have the following problems, I have 5 different objects in self.datas that start at a different point in times. For example the first three assets start being available on 2001-01-01 and the remaining two start on 2005-01-01. How can I backtest from 2001 to 2010 by allocating the portfolio between three assets first and between five assets later? Until now the backtester either raises an error if I try to backtest let's say between 2001 and 2004, or starts trading on 2005 if the dates I set are 2001 to 2010.

  • In order to run strategy from the very beginning of the oldest data feed call strategy logic in both prenext() and next() functions. But you need to put some checks if data feed exists in the prenext().

    Check out Docs - Strategy

Log in to reply