service.time_to_string()
service. (method) Overview: Interface: time_to_string(muts,
format="%Y-%m-%d %H:%M:%S.%f")
Sample - Calling Method
service.time_to_string( service.system_time )
Name | Type | Default | Information |
---|---|---|---|
muts | muts | required | timestamp |
format | string | "%Y-%m-%d %H:%M:%S.%f" | A valid strftime format string that will be used when converting the 'muts' input to a valid time string. |
Return time as a string
Working Example:Print the market close time the day after Thanksgiving 2015.
from cloudquant.interfaces import Strategy
class TimeToStringExample(Strategy):
@classmethod
def is_symbol_qualified(cls, symbol, md, service, account):
return symbol == "AAL"
def on_start(self, md, order, service, account):
#print the symbol
print(self.symbol+"\n")
print ("Human readable timestamp:")
#print the timestamp using the time_to_string() to convert the timestamp to human readable
print(service.time_to_string(service.system_time))
print("\nThis is what a timestamp looks like if you don't use time_to_string()")
#a direct print of the system_time
print(service.system_time)
service.terminate()
Console
AAL Human readable timestamp: 2016-08-15 09:25:00.000000 This is what a timestamp looks like if you don't use time_to_string() 1471267500000000Related Links: