You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to get a timer notification after a trading session ends (including after-hours trading) - let's say 5 min after eos. Unfortunately such timers are not fired until the next session begins (or at all)
Here is the code used to set such a timer (in strategy ctor):
(it doesn't matter if the absolute time is used as in the above code or a Timer.SESSION_END constant)
It seems the problem is that the timers are only checked if at least one data feed produces new bar inside `celebro._runnext' method.
def _runnext(self, runstrats):
...
...
if d0ret or lastret: # if any bar, check timers before broker
self._check_timers(runstrats, dt0, cheat=True)
if self.p.cheat_on_open:
for strat in runstrats:
strat._next_open()
if self._event_stop: # stop if requested
return
...
...
However, after trading session - no data feed produces any bars, which means that _check_timers will not be called and no notify_timer notification will be fired.
After looking at it a little bit more, the problem is not only that self._check_timers method is not called anymore if no data feed produces any bars.
Even if it could be called, the timestamp (stored in dt0 variable) passed to the self._check_timers call will be the same as the last timestamp returned by the data feed.
This timestamp would also be frozen in case the data feed has reached the end of trading session - so it doesn't make any sense to call the self._check_timers at all in this case.
The text was updated successfully, but these errors were encountered:
vladisld
changed the title
ive trading: notify_timer is not called if timer is set after eos
live trading: notify_timer is not called if timer is set after eos
Mar 25, 2020
it seems the original timer implementation was designed to be used specifically for backtrading, while the live trading capabilities were added later.
However the current implementation is not fully suitable for live trading scenarios, since it fully depends on the time values provided by the data feed.
The proposed solution is to introduce another type of Timer class which will be used only for live trading scenarios and will use a real world time.
I need to get a timer notification after a trading session ends (including after-hours trading) - let's say 5 min after eos. Unfortunately such timers are not fired until the next session begins (or at all)
Here is the code used to set such a timer (in strategy ctor):
(it doesn't matter if the absolute time is used as in the above code or a Timer.SESSION_END constant)
It seems the problem is that the timers are only checked if at least one data feed produces new bar inside `celebro._runnext' method.
However, after trading session - no data feed produces any bars, which means that _check_timers will not be called and no notify_timer notification will be fired.
After looking at it a little bit more, the problem is not only that self._check_timers method is not called anymore if no data feed produces any bars.
Even if it could be called, the timestamp (stored in dt0 variable) passed to the self._check_timers call will be the same as the last timestamp returned by the data feed.
This timestamp would also be frozen in case the data feed has reached the end of trading session - so it doesn't make any sense to call the self._check_timers at all in this case.
The text was updated successfully, but these errors were encountered: