Mariner Backtesting - Naming Timers in service object

Overview:

This lesson covers naming timers. Sometimes you will need more than one timer in your script, and naming timers will allow you to distinguish them from one another.

Basic use case:

Different timers can be set up to be called at separate times. For example, if you need one timer to go off at 9:30 and one to go off at 10:45, you would set these individual timers their own timer IDs. Note that inside the on_timer() event, the timer ID is an attribute of the event. Therefore, the script in the on_timer() event must read event.timer_id rather than just timer_id.

Interface:
 add_time_trigger( timestamp, repeat_interval, timer_id)
Working Example:

Call on_timer() at 9:30, and create a separate timer that calls on_timer() at 10:45.

 service.add_time_trigger( service.time(9,30), timer_id = 'timer 1')
service.add_time_trigger( service.time(10,45), timer_id = 'timer 2')