Mariner Backtesting - service.time()

service.time()

Return an integer timestamp representing the absolute time on the current simulation day.

Interface:
 time(hour=0,
     minute=0,
     second=0,
     millisecond=0)

Sample - Calling Method

 service.time(10)

If any argument is omitted, it defaults to zero.

Parameters:
Name Type Default Information
hour integer 0 Hour of day - military time
minute integer 0 Minute of hour
second integer 0 Second of minute
millisecond integer 0 Millisecond of second
Returns
Type Notes
integer A timestamp of time in muts
Working Example:

Get the time for 10 AM ET for the current trading date.

from cloudquant.interfaces import Strategy


class TimeExample(Strategy):

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

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

        # service.time(11) also works
        print(service.time_to_string(service.time(hour = 11)))
        service.terminate()

Console

AAL
2016-08-09 09:24:32.989000

2016-08-09 11:00:00.000000