Issue with on_timer() event function not being called or executed at runtime

lf263820lf263820 Posts: 17
edited March 2018 in Onboarding Help

I have tried to execute on_timer event function every 3 mn at runtime in my program. When I implemented it ,
it used to work but since today (03/04/2018) , it is not working anymore.
Has Python runtime been updated?

ATTENTION: I have just noticed if you add service.add_time_trigger without timer_id , on_timer is triggered but with timer_id , the timer event function does not work. But my program needs to call timer_id with the on_timer event function. Please detail what to do.

Please let me why this issue is happening?. See some codes below for understanding the problem.

def on_start(self, md, order, service, account):
service.add_time_trigger(service.time(9, 35), repeat_interval = service.time_interval(0,3), timer_id='N1')

def on_minute_bar(self, event, md, order, service, account, bar):
pass

def on_timer(self, event, md, order, service, account):
print(service.time_to_string(event.timestamp) + " - Timer triggered " + self.symbol )

Tagged:

Answers

  • ptunneyptunney Posts: 246

    lf

    I am not able to reproduce this problem..

    Here is my full code, it works fine. If I do not pass a timer_id it gets called with None as the timer_id

    I added event to your print statement so you could see this.

    Timer_id is not a requirement, it is there in case you call multiple timers so that you can do if event.timer_id=="xxxx" then

    Ensure you are not running in fast mode. Make sure you have nothing weird set when you submit the backtest.

    If you are still having issues contact me directly (let me know what date you are running on).

    Paul

    from cloudquant.interfaces import Strategy
    
    class LF_TIMER(Strategy):
    
        @classmethod
        def is_symbol_qualified(cls, symbol, md, service, account): #
            return symbol=="SPY"
    
        def on_start(self, md, order, service, account):
    #        service.add_time_trigger(service.time(9, 35), repeat_interval = service.time_interval(0,3), timer_id='N1')
            service.add_time_trigger(service.time(9, 35), repeat_interval = service.time_interval(0,3))
    
        def on_timer(self, event, md, order, service, account):
            print(service.time_to_string(event.timestamp) + " - Timer triggered " + self.symbol ),event
    
  • lf263820lf263820 Posts: 17
    edited March 2018

    Paul,
    I finally found what is preventing Timer event function to trigger. It does not work when you run your application in FAST MODE. So you are right, do not use fast mode .
    Leon

  • ptunneyptunney Posts: 246

    Excellent! Yes, FAST MODE effectively switches you back to CloudQuant LITE. It can be useful if you are not using some of those extra features as it definitely increases the speed of your backtests.. I often forget and have it check for a few backtests before I realize what is happening!! Humans eh!

Sign In or Register to comment.