def buy(args):
path = args.config['book-path']
# Check if the file book.json exist and if not create it
# and iniate it with '[]'
if not os.path.isfile(path):
data = "[]"
file = open(path, 'a+')
file.write(data)
file.close()
order = Order(args)
data = json.loads(open(path).read())
data.append(order.toDict())
with open(path, 'w') as outfile:
json.dump(data, outfile, indent=4)
# Display the order with a nice table
table_data = [
['id', 'Exchange', 'Market', 'Price'],
[order.id , order.exchange, order.market, order.last]
]
table = SingleTable(table_data)
table.title = 'Buy Order'
print (table.table)
评论列表
文章目录