Пример #1
0
                trade_time = time.time()
                print(Order['data'])
                trade_number = Order['data']['order_id_str']
                print(trade_number)

            Order.clear()
        else:
            continue

    else:  # 判断是否需要平仓
        if Already_Judged:
            time5 = time.time()  # 获取当前时间
            # 如果时间差大于定额时间,
            if time5 - trade_time >= trading_interval:
                print(symbol, trade_number)
                Order = dm.get_contract_order_info(symbol=symbol_type,
                                                   order_id=trade_number)
                logger.info("查询合约订单返回信息:%s" % Order)

                pprint(Order)
                # 判断订单是否成功
                if Order['status'] == 'error':
                    logger.error("查询合约订单返回查询失败:%s" % Order['err_msg'])
                    print(Order['err_msg'])
                    continue
                elif Order['status'] == 'ok':

                    data_btc = Order['data'][0]

                    head = [
                        data_btc['contract_code'], data_btc['lever_rate'],
                        data_btc['created_at'], data_btc['direction'],
                'price':10000, 'volume':1, 'direction':'sell', 'offset':'open', 
                'leverRate':5, 'orderPriceType':'limit'},
               {'symbol': 'BTC','contract_type': 'quarter', 
                'contract_code':'BTC181228', 'client_order_id':'', 
                'price':20000, 'volume':2, 'direction':'sell', 'offset':'open', 
                'leverRate':5, 'orderPriceType':'limit'}]}
pprint(dm.send_contract_batchorder(orders_data))


print (u' 撤销订单 ')
pprint(dm.cancel_contract_order(symbol='BTC', order_id='42652161'))

print (u' 全部撤单 ')
pprint(dm.cancel_all_contract_order(symbol='BTC'))

print (u' 获取合约订单信息 ')
pprint(dm.get_contract_order_info(symbol='BTC', order_id='42652161'))

print (u' 获取合约订单明细信息 ')
pprint(dm.get_contract_order_detail(symbol='BTC', order_id='42652161', order_type=1, created_at=1542097630215))

print (u' 获取合约当前未成交委托 ')
pprint(dm.get_contract_open_orders(symbol='BTC'))

print (u' 获取合约历史委托 ')
pprint (dm.get_contract_history_orders(symbol='BTC', trade_type=0, type=1, status=0, create_date=7))




Пример #3
0
                'price':1, 'volume':1, 'direction':'buy', 'offset':'open', 
                'leverRate':5, 'orderPriceType':'limit'},
               {'symbol': 'BTC','contract_type': 'quarter', 
                'contract_code':'BTC181228', 'client_order_id':'', 
                'price':2, 'volume':2, 'direction':'buy', 'offset':'open', 
                'leverRate':5, 'orderPriceType':'limit'}]}
pprint(dm.send_contract_batchorder(orders_data))


print (u' 撤销订单 ')
pprint(dm.cancel_contract_order(symbol='BTC', order_id='42652161'))

print (u' 全部撤单 ')
pprint(dm.cancel_all_contract_order(symbol='BTC'))

print (u' 获取合约订单信息 ')
pprint(dm.get_contract_order_info(symbol='BTC', order_id='42652161'))

print (u' 获取合约订单明细信息 ')
pprint(dm.get_contract_order_detail(symbol='BTC', order_id='42652161'))

print (u' 获取合约当前未成交委托 ')
pprint(dm.get_contract_open_orders(symbol='BTC'))

print (u' 获取合约历史委托 ')
pprint (dm.get_contract_history_orders(symbol='BTC', trade_type=0, type=1, status=0, create_date=7))