def sure_cancel(order_id): while True: resp = HuobiService.cancelOrder(1, order_id, CANCEL_ORDER) if resp is not None and 'result' in resp: break if resp is not None and 'msg' in resp: if resp['msg'] == unicode('该委托不存在', "utf-8"): break sleep(3)
# coding=utf-8 ''' 本程序在 Python 3.3.0 环境下测试成功 使用方法:python HuobiMain.py ''' from huobi import HuobiService from .Util import * if __name__ == "__main__": print("获取账号详情") print(HuobiService.getAccountInfo(ACCOUNT_INFO)) print("获取所有正在进行的委托") print(HuobiService.getOrders(1, GET_ORDERS)) print("获取订单详情") print(HuobiService.getOrderInfo(1, 68278313, ORDER_INFO)) print("限价买入") print(HuobiService.buy(1, "1", "0.01", None, None, BUY)) print("限价卖出") print(HuobiService.sell(2, "100", "0.2", None, None, SELL)) print("市价买入") print(HuobiService.buyMarket(2, "30", None, None, BUY_MARKET)) print("市价卖出") print(HuobiService.sellMarket(2, "1.3452", None, None, SELL_MARKET)) print("查询个人最新10条成交订单") print(HuobiService.getNewDealOrders(1, NEW_DEAL_ORDERS)) print("根据trade_id查询order_id") print(HuobiService.getOrderIdByTradeId(1, 274424, ORDER_ID_BY_TRADE_ID)) print("取消订单接口") print(HuobiService.cancelOrder(1, 68278313, CANCEL_ORDER))
#coding=utf-8 from huobi.Util import * from huobi import HuobiService if __name__ == "__main__": print "提交限价单接口" print HuobiService.buy(1,"2355","0.01",None,None,BUY) print "提交市价单接口" print HuobiService.buyMarket(2,"30",None,None,BUY_MARKET) print "取消订单接口" print HuobiService.cancelOrder(1,68278313,CANCEL_ORDER) print "获取账号详情" print HuobiService.getAccountInfo(ACCOUNT_INFO) print "查询个人最新10条成交订单" print HuobiService.getNewDealOrders(1,NEW_DEAL_ORDERS) print "根据trade_id查询order_id" print HuobiService.getOrderIdByTradeId(1,274424,ORDER_ID_BY_TRADE_ID) print "获取所有正在进行的委托" print HuobiService.getOrders(1,GET_ORDERS) print "获取订单详情" print HuobiService.getOrderInfo(1,68278313,ORDER_INFO) print "现价卖出" print HuobiService.sell(2,"22.1","0.2",None,None,SELL) print "市价卖出" print HuobiService.sellMarket(2,"1.3452",None,None,SELL_MARKET)
def sure_cancel(trade_id): while True: resp = HuobiService.cancelOrder(1, trade_id, CANCEL_ORDER) if resp is not None and 'result' in resp: break sleep(3)