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

Can a repeating Timer be killed?

  • I need to get call back periodically, but if the trade is closed I don't want the call back anymore. Is there a way to stop it?


  • administrators

    No, timers cannot be killed, because the idea with which they were developed is that you always want to check the same things when the time rules you have chosen (for example: 10 minutes after the session start or the 15th day of each month)

    They are not meant to be tied to trades. You have 2 options:

    • If your timer is a daily one, you can use the allow named argument to a timer to pass a callable which (dis)allows a given day for a callback

    See: Docs - Timers


    • Use an attribute of your strategy as flag to indicate if the code should progress in notify_timer or not.

    At the end of the day both methods amount to basically the same, since the callable which you would pass to allow is probably going to be a method of your strategy, which notify_timer already is.

Log in to reply