コード例 #1
0
 def __init__(self, uid):
     try:
         ticker_ltc = requests.get(
             r'http://api.huobi.com/staticmarket/ticker_ltc_json.js',
             timeout=5)
         self.ticker_ltc = json.loads(ticker_ltc.text)
         ticker_ltc.close()
         self.account_info = HuobiService.getAccountInfo(ACCOUNT_INFO)
         self.getOrder = HuobiService.getOrders(2, GET_ORDERS)
         #卖单数量
         self.sellOne_count = [
             order for order in self.getOrder if order['type'] == 2
         ]
         #买单数量
         self.buyOne_count = [
             order for order in self.getOrder if order['type'] == 1
         ]
         #已完成的委托
         self.dealOrders = HuobiService.getNewDealOrders(2, NEW_DEAL_ORDERS)
         #资产折合
         self.total = float(self.account_info['total'])
         #卖一价
         self.limit_price = self.ticker_ltc['ticker']['sell']
         #买一价
         self.buyone_price = self.ticker_ltc['ticker']['buy']
         #总量
         self.trade_total = self.ticker_ltc['ticker']['vol']
         #限制挂单数量
         self.orderCount = self.handler_orderCount()
         #可用资金
         self.a_cny_display = float(
             self.account_info['available_cny_display'])
         #可用莱特币
         self.a_ltc_display = float(
             self.account_info['available_ltc_display'])
     except BaseException as e:
         print u'无法获取数据', e
コード例 #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))
コード例 #3
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)