from PythonApi import *
def init(context):
""" Mandatory """
settimer(auto_test, 1000)
pass
def handle_bar(context):
""" Mandatory """
pass
def auto_test(context):
contract_id = context.universe[0]
bar_list = history_bars(order_book_id=contract_id,
bar_count=1,
frequency='5m',
fields=['open', 'close', 'high', 'low', 'datetime'],
include_now=True)
write_logging(str(len(bar_list)))
bar = bar_list[-1]
text = contract_id + ' True'
text += '\n- open: %s' % (bar[0])
text += '\n- close: %s' % (bar[1])
text += '\n- high: %s' % (bar[2])
text += '\n- low: %s' % (bar[3])
text += '\n- datetime: %s' % (bar[4])
write_logging(text)
bar_list = history_bars(order_book_id=contract_id,
bar_count=1,
frequency='5m',
fields=['open', 'close', 'high', 'low', 'datetime'],
include_now=False)
bar = bar_list[-1]
text = contract_id + ' False'
text += '\n- open: %s' % (bar[0])
text += '\n- close: %s' % (bar[1])
text += '\n- high: %s' % (bar[2])
text += '\n- low: %s' % (bar[3])
text += '\n- datetime: %s' % (bar[4])
write_logging(text)
pass