Esempio n. 1
0
def sure_sell(price, amount):
    trade_id = 0
    resp = {}
    while True:
        trade_id = int(1000000 * random())
        amount = format_amount2(amount)
        # print "before sell"
        resp = HuobiService.sell(1, str(price), str(amount), None, trade_id, SELL)
        # print resp
        # a bug resp can be none
        if resp is not None and 'msg' not in resp and 'id' in resp:
            break
        sleep(1)
    return trade_id, resp['id']
Esempio n. 2
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))
Esempio n. 3
0
from huobi.Util import *
from huobi import HuobiService

if __name__ == "__main__":
    ret = HuobiService.sell(1, 8000, 0.0038, "", 11, SELL)

    print ret
    #ret = HuobiService.getOrderIdByTradeId(1, 2, ORDER_ID_BY_TRADE_ID)
    #ret = HuobiService.getOrderInfo(1, ret['id'], ORDER_INFO)
    #print(ret)
Esempio n. 4
0
#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)



Esempio n. 5
0
#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)