def save_order_list(self, tday):
orders = self.id2order.keys()
if len(self.id2order) > 1:
orders.sort()
order_list = [self.id2order[key] for key in orders]
filename = self.file_prefix + 'order_' + tday.strftime('%y%m%d') + '.csv'
with open(filename, 'wb') as log_file:
file_writer = csv.writer(log_file, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL);
file_writer.writerow(
['order_ref', 'local_id', 'sysID', 'inst', 'volume',
'filledvolume', 'filledprice', 'filledorders',
'action_type', 'direction', 'price_type',
'limitprice', 'order_time', 'status', 'order_class', 'trade_ref'])
for iorder in order_list:
forders = [ str(key) + ':' + '_'.join([str(s) for s in iorder.filled_orders[key]]) for key in iorder.filled_orders if len(str(key))>0 ]
filled_str = '|'.join(forders)
file_writer.writerow(
[iorder.order_ref, iorder.local_id, iorder.sys_id, iorder.instrument, iorder.volume,
iorder.filled_volume, iorder.filled_price, filled_str,
iorder.action_type, iorder.direction, iorder.price_type,
iorder.limit_price, iorder.start_tick, iorder.status, iorder.type, iorder.trade_ref])
评论列表
文章目录