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

Issue with RollOver and live data



  • Hi,

    I had an issue with live data and RollOver data feed, and I think I found where is the problem.
    Can you please review it and maybe submit a patch if relevant.

    The live feed is my own class (Reuters). It returns None when no data is available yet and False when this is the end of the feed (I believe this is a convention here). I am trying to trade futures with my live feed and RollOver, but a problem arises on line 155 of feeds/rollover.py:

    def _load(self):
        while self._d is not None:
            if not self._d.next():  # no values from current data source
                if self._ds:
                    self._d = self._ds.pop(0)
                    self._dts.pop(0)
                else:
                    self._d = None
                continue
    

    The test on if not self._d.next(): is ambigous as it makes no difference between None and False.
    As a result if in a resampling, on say 5 seconds, no ticks came, then RollOver thinks the contract is over and get to the next one, which is wrong.

    The solution I propose is to test False on this line:

    def _load(self):
        while self._d is not None:
            if self._d.next() is False:  # no values from current data source
                if self._ds:
                    self._d = self._ds.pop(0)
                    self._dts.pop(0)
                else:
                    self._d = None
                continue
    

    It works great on both live data feed and backtest data feeds.
    Thanks


  • administrators

    Indeed. I guess at that time ... such a feat was not even considered.



  • Hi,

    I'm glad you've fixed this issue in the latest release.
    Unfortunately, there is a typo in the check for values in the data source:

    def _load(self):
        while self._d is not None:
            if self._d.next() is not False:  # no values from current data src
                if self._ds:
                    self._d = self._ds.pop(0)
                    self._dts.pop(0)
                else:
                    self._d = None
                continue
                ...
    

    It should have been:

    def _load(self):
            while self._d is not None:
                if self._d.next() is False:  # no values from current data src
                ... 
    

    not was falsely added.

    Regards


  • administrators

    Corrected. It will go into 1.9.67.122