Beispiel #1
0
                        client_order_id='', price=50, volume=1, direction='buy',
                        offset='open', lever_rate=5, order_price_type='limit'))

# {'data': {'order_id': 42652161}, 'status': 'ok', 'ts': 1537270256575}

print (u' 合约批量下单 ')
orders_data = {'orders_data': [
               {'symbol': 'BTC', 'contract_type': 'quarter',  
                'contract_code':'BTC181228',  'client_order_id':'', 
                '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.send_contract_order(symbol='', contract_type='', contract_code='BTC181228', 
                        client_order_id='', price=10000, volume=1, direction='sell',
                        offset='open', lever_rate=5, order_price_type='limit'))


print (u' 合约批量下单 ')
orders_data = {'orders_data': [
               {'symbol': 'BTC', 'contract_type': 'quarter',  
                'contract_code':'BTC181228',  'client_order_id':'', 
                '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' 获取合约当前未成交委托 ')
while price < currPrice + step * 10:
    order_data = {
        'symbol': 'XRP',
        'contract_type': 'quarter',
        'client_order_id': '',
        'price': round(price, 4),
        'volume': 3,
        'direction': 'sell',
        'offset': 'open',
        'lever_rate': 20,
        'order_price_type': 'limit'
    }
    sell_order_datas.append(order_data)
    price = price + step

result = dm.send_contract_batchorder({'orders_data': sell_order_datas})
if result['status'] == 'ok':
    print("open1 sell success")
    pprint(result)
else:
    print("open1 sell failed")
    pprint(result)

sell_order_datas = []
while price < currPrice + step * 20:
    order_data = {
        'symbol': 'XRP',
        'contract_type': 'quarter',
        'client_order_id': '',
        'price': round(price, 4),
        'volume': 3,