Mariner Backtesting - service.clear_event_triggers()

service.clear_event_triggers()

Remove all event triggers from the list of triggers. NOTE : THIS INCLUDES ORDER HANDLING EVENTS (FILL, CANCEL, REJECT etc). Be sure to add them back in.

Interface:
 clear_event_triggers()

Sample - Calling Method

 service.clear_event_triggers()
Parameters:

None

Returns:

None

Remarks:
  • Only works in on_start()
Working Example:

Clear Event Trigger

from cloudquant.interfaces import Strategy, Event


class ClearEventTriggersExample(Strategy):

    @classmethod
    def is_symbol_qualified(cls, symbol, md, service, account):
        return symbol == "AAL"

    def on_start(self, md, order, service, account):
        # print start time and symbol
        print(self.symbol + "\n" + service.time_to_string(service.system_time) + "\tin on_start()\n\n")

        #set timer for 3:55 PM EST (5 minutes before close)
        service.add_time_trigger(service.time(15, 55))

        #this clear the event triggers, but does not interfere with the above time_trigger
        service.clear_event_triggers()

    def on_trade(self, event, md, order, service, account):
        #on_trade is not called because of the clear_event_triggers()
        print(service.time_to_string(md.L1.timestamp) + "\tin on_trade()\n\n")
        #this will not print

    def on_timer(self, event, md, order, service, account):
        #even though event triggers were cleared, on_timer is still called
        print(service.time_to_string(event.timestamp) + "\tin on_timer()\n\n")


    def on_finish(self, md, order, service, account):
        # even though event triggers were cleared, on_finish is still called
        print(service.time_to_string(md.L1.timestamp) + "\tin on_finish()\n\n")

Console

AAL
2016-08-08 09:29:55.102000    in on_start()

2016-08-08 15:55:00.000000    in on_timer()


2016-08-08 16:00:00.000000    in on_finish()