next is not called for individual data feeds.
It is called when the next unit of time of any of the data feeds has elapsed.
A single data feed:
nextis called for each bar of the data feed
B multiple data feeds aligned in time
Straightfoward too. The same principle as above
C multiple data feeds which are not aligned in time
One of the data feeds may advance in time whilst the other(s) may remain static. This can happen, for example, if assets from different exchanges are in the system and the exchanges have different trading calendars. An example
DAX. Bank holidays in the USA and Germany are not aligned (some are but most aren't).
SPYis not trading because it's Thanksgiving Day, the
DAXis happily trading. In this case
nextwill be called and the following will be true:
SPYdata feed will not increase its length and checking the values at
will return the last known values
DAXdata feed will increase its length and the values at
will be the current ones
- The Strategy will increase its length because one of the data feeds has moved forward (and value, cash and other things may have changed)
You may check this which shows an extreme example in which several trading days were removed from the source:
Scenario C is the one applicable to multiple live data feeds, because some may not deliver data for a given period, whilst others will do.
The smaller the period, the higher the chances that some data feeds will not have data for a given period, whilst others (those with more liquidity) will keep pushing the clock forward.
To understand which data feeds have moved forward use:
len(dataX) and see if it has increased with regards to the last time (you may also check
dataX.datetime.datetime(), but this will change in a
replay scenario, with the length remaining constant, hence the recommendation to use