Mariner Backtesting - service.time_interval()

service.time_interval()

Return an integer representing the number of microseconds corresponding to the time units passed in.

Interface:
 time_interval(hours=0,
              minutes=0,
              seconds=0,
              milliseconds=0)

Sample - Calling Method

 service.time_interval( hours=1 )
Parameters:
Name Type Default Information
hours integer 0 integer number of hours
minutes integer 0 integer number of minutes
seconds integer 0 integer number of seconds
milliseconds integer 0 integer number of milliseconds
Returns:
Type Notes
integer A timestamp of time in muts
Working Example:

Add 10 minutes to the market open time

from cloudquant.interfaces import Strategy


class TimeIntervalExample(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")
        print("Market Open Time - ", service.time_to_string(md.market_open_time) )
        print("Market Open Time plus 5 minutes - ", service.time_to_string(md.market_open_time + service.time_interval(minutes=5)) )

Console

AAL
2016-08-09 09:24:32.989000

Market Open Time - 2016-08-09 09:30:00.000000
Market Open Time plus 5 minutes - 2016-08-09 09:35:00.000000