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

prenext datas not correct?

  • Say I have two data feeds with different starting dates, I wanted to start processing as long as one has data, therefore I try to use prenext, since next is only called when both feeds starts to have data.

    However, when I try to access the date in prenext. I gets the last date instead of the correct prenext date. The code is simply:

    def prenext(self):
        for i, d in enumerate(self.datas):
            dt, dn =, d._name

    say feed 1 starts from 2018-01-01, feed 2 starts from 01-20, both until 2018-06-13. The dt in the prenext above however, always returns the last day of the feed 2018-06-13. The earlier feed's close price is correct though; but the latter feed's close price is incorrect and shows the 2018-06-13's price.

    How to understand this? How to fetch the data for the correct date, and price. If the price is not available for a feed, how can we tell that it's not started (since it's not showing nan, but showing a seemingly legitimate price)?

  • administrators

    It's not because it's incorrect. If one data feed is not moving forward it delivers the last known data points (datetime, open, ...)

    To check if a data feed has moved, you have to check its length ... with len(dataX)

    If a data feed has not started yet, its len will be 0

Log in to reply