Beispiel #1
0
def get_order_status(order_id, order_price):
    while True:
        resp = HuobiService.getOrderInfo(1, order_id, ORDER_INFO)
        if resp is not None and 'msg' not in resp and 'status' in resp:
            return resp
            break
        sleep_time = get_sleep_time(abs(CURR_PRICE - order_price))
        sleep(sleep_time)
Beispiel #2
0
def sure_order_success(coin_type, order_id, order_price):
    global CURR_PRICE
    while True:
        resp = HuobiService.getOrderInfo(coin_type, order_id, ORDER_INFO)
        # print resp
        if resp is not None and 'msg' not in resp and 'status' in resp:  # all success
            if resp['status'] == 2:
                break
        sleep_time = get_sleep_time(abs(CURR_PRICE - order_price))
        sleep(sleep_time)
Beispiel #3
0
def sure_order_success(coin_type, order_id, order_price, is_forword=False):
    global CURR_PRICE
    while True:
        resp = HuobiService.getOrderInfo(coin_type, order_id, ORDER_INFO)
        # print resp
        if resp is not None and 'msg' not in resp and 'status' in resp:         # all success
            if resp['status'] == 2:
                return float(resp['processed_price'])

        diff = abs(CURR_PRICE - order_price)
        if diff > 10 and is_forword:
            return False   #means this order_price is far away from current_price
        sleep_time = get_sleep_time(diff)
        sleep(sleep_time)
Beispiel #4
0
# 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)