Mariner Backtesting - Strategy.on_timer()

Timer Event

This method will be called when service.add_time_trigger() is scheduled.

Interface:
 def on_timer(self,
             event,
             md,
             order,
             service,
             account):
    pass
Data Attributes for event:
Name Type Information
kind integer Event enum (11) representing the kind of event. *LIVE AND FORWARD ONLY*, represents the type of event (trade, quote, news, imbalance etc)
muts muts Time of the Timer ? Or the System Time of Method being Calle
timer_id object Is a flexible object which can be passed in when using service.add_time_trigger(). Most offen used an integer or string
timestamp muts  
Working Example:

Print the timer_id when on_timer() is called.

 # Copyright Cloudquant, LLC. All right reserved.
from cloudquant.interfaces import Strategy


class OnTimerExample(Strategy):
    do_once = True

    @classmethod
    def is_symbol_qualified(cls, symbol, md, service, account):
        return symbol == 'SPY'

    def on_start(self, md, order, service, account):
        if self.__class__.do_once:
            print service.time_to_string(service.system_time, '%Y-%m-%d')
            self.__class__.do_once = False
        print self.symbol
        service.add_time_trigger(service.time(9,29), timer_id = 'a timer_id')


    def on_timer( self, event, md, order, service, account ):
        print '\nin on_timer()\n\t%s\n' % service.time_to_string(service.system_time, '%H:%M:%S.%f')
        print 'event - TimerEvent\n'

        print ' event.kind  -   ', event.kind
        #print '    event.symbol    -   ', event.symbol
        print ' event.timer_id  -   ', event.timer_id
        print ' event.timestamp -   ', event.timestamp
        print ' event.timestamp -   ', self.pt( event.timestamp, service ), '## time_to_string'

        print '\n\ndifferent timestamps\n\n## Times Converted - time_to_string ##\n\n'
        print ' service.system_time -   ', self.pt( service.system_time, service )
        print ' md.arca_imb .timestamp  -   ', self.pt( md.arca_imb .timestamp, service )
        print ' md.L1.daily_high_timestamp  -   ', self.pt( md.L1.daily_high_timestamp, service )
        print ' md.L1.daily_low_timestamp   -   ', self.pt( md.L1.daily_low_timestamp, service )
        print ' md.L1.minute_start_timestamp    -   ', self.pt( md.L1.minute_start_timestamp, service )
        print ' md.L1.timestamp -   ', self.pt( md.L1.timestamp, service )
        print ' md.nasdaq_imb.timestamp -   ', self.pt( md.nasdaq_imb.timestamp, service )
        print ' md.news.timestamp   -   ', self.pt( md.news.timestamp, service )
        print ' md.nyse_imb.timestamp   -   ', self.pt( md.nyse_imb.timestamp, service )


        service.terminate()

    def pt( self, muts, service ): #print time
        return service.time_to_string(muts, '%H:%M:%S.%f')

Console

2016-01-04
SPY

in on_timer()
    09:29:00.000000

event - TimerEvent

    event.kind  -   11
    event.timer_id  -   a timer_id
    event.timestamp -   1451917740000000
    event.timestamp -   09:29:00.000000 ## time_to_string


different timestamps

## Times Converted - time_to_string ##


    service.system_time -   09:29:00.000000
    md.arca_imb .timestamp  -   09:28:59.633000
    md.L1.daily_high_timestamp  -   19:00:00.000000
    md.L1.daily_low_timestamp   -   19:00:00.000000
    md.L1.minute_start_timestamp    -   09:29:00.000000
    md.L1.timestamp -   09:28:59.635000
    md.nasdaq_imb.timestamp -   09:28:55.110000
    md.news.timestamp   -   19:00:00.000000
    md.nyse_imb.timestamp   -   19:00:00.000000