cryptobook.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:crypto-book 作者: vafanassieff 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号