“帐户"对象没有属性获取Huobi_python API [英] "Account" object has no atribute get Huobi_python API

查看:226
本文介绍了“帐户"对象没有属性获取Huobi_python API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Huobi_python api试图使余额显示出来,可悲的是,我得到了这个错误:

From the Huobi_python api, I'm trying to get the balance to show up sadly enough I get this error :

追踪(最近一次通话结束):文件 "C:/Users/Root/PycharmProjects/Huobi_API/TestZone.py",第9行,在 打印(balance.get(0).get(0).balance)

"Traceback (most recent call last): File "C:/Users/Root/PycharmProjects/Huobi_API/TestZone.py", line 9, in print(balance.get(0).get(0).balance)

AttributeError:帐户"对象没有属性获取""

AttributeError: 'Account' object has no attribute 'get'"

我不知道我在做什么错或如何使.get开始工作 链接到github: https://github.com/huobiapi/huobi_Python

I have no clue what I'm doing wrong or how to get the .get get to work Link to github: https://github.com/huobiapi/huobi_Python

from huobi import *
from huobi.model.constant import *



request_client =  RequestClient(api_key="XXXXXXXXXX", secret_key="XXXXXXXXXXXXX")

balance = request_client.get_account_balance_by_account_type(AccountType.SPOT)
print(balance.get(0).get(0).balance)

推荐答案

还有一种替代方法,可以通过SubscriptionClient获得详细信息平衡.下面显示了您的帐户ID,帐户类型/阶段和余额以及币种.以下代码的来源是

There is an alternative way to get the detail balance by SubscriptionClient. The following present your account ID(s), account type(s)/ stage(s) and balance(s) with currency(ies). The source of the below code is

https://github.com/HuobiRDCenter/huobi_Python/blob/master/example/websocket/reqsignaccountlist.py

from huobi import SubscriptionClient
from huobi.constant.test import *
from huobi.model import *
from huobi.base.printobject import PrintMix, PrintBasic

sub_client = SubscriptionClient(api_key=g_api_key, secret_key=g_secret_key)

def callback(account_balance: 'AccountBalanceRequest'):
    print("---- account_balance:  ----")
    PrintBasic.print_basic(account_balance.timestamp, "Timestamp")
    PrintBasic.print_basic(account_balance.client_req_id, "Client Req ID")
    PrintBasic.print_basic(account_balance.topic, "Topic")
    print("Account List as below : count " + str(len(account_balance.account_list)))
    if len(account_balance.account_list):
        for account in account_balance.account_list:
            PrintBasic.print_basic(account.id, "\tId")
            PrintBasic.print_basic(account.account_type, "\tAccount Type")
            PrintBasic.print_basic(account.account_state, "\tAccount State")
            print("\tAccount ID : " + str(account.id) + " Balance List as below :")
            if len(account.balances):
                for balance in account.balances:
                    PrintBasic.print_basic(balance.currency, "\t\tCurrency")
                    PrintBasic.print_basic(balance.balance_type, "\t\tBalance type")
                    PrintBasic.print_basic(balance.balance, "\t\tBalance")
                    print()
    print()

sub_client.request_account_balance_event(callback=callback, client_req_id = None, auto_close = True)

输出:

> ---- account_balance:  ---- Timestamp : 1569693210000 Client Req ID : 1569XXXXXXXXX Topic : accounts.list Account List as below : count 2
>         Id : 1XXXXXXX
>         Account Type : spot
>         Account State : working
>         Account ID : 19XXXXX Balance List as below :
>                 Currency : but
>                 Balance type : trade
>                 Balance : 19.6
> 
>                 Currency : aac
>                 Balance type : trade
>                 Balance : 2.45
> 
>                 Currency : iic
>                 Balance type : trade
>                 Balance : 49
> 
>                 Currency : eon
>                 Balance type : trade
>                 Balance : 10
> 
>                 Currency : eop
>                 Balance type : trade
>                 Balance : 10
> 
>                 Currency : ht
>                 Balance type : trade
>                 Balance : 84.14270001
> 
>                 Currency : hot
>                 Balance type : trade
>                 Balance : 0.2333
> 
>                 Currency : theta
>                 Balance type : trade
>                 Balance : 0.0022
> 
>                 Currency : uc
>                 Balance type : trade
>                 Balance : 49
> 
>                 Currency : btc
>                 Balance type : trade
>                 Balance : 0.0083007271
> 
>                 Currency : ssp
>                 Balance type : trade
>                 Balance : 0.0002
> 
>                 Currency : uuu
>                 Balance type : trade
>                 Balance : 161.7
> 
>                 Currency : gtc
>                 Balance type : trade
>                 Balance : 1.5313
> 
>                 Currency : usdt
>                 Balance type : trade
>                 Balance : 273.618382
> 
>                 Currency : eth
>                 Balance type : trade
>                 Balance : 0.00006
> 
>                 Currency : tos
>                 Balance type : trade
>                 Balance : 0.0001
> 
>                 Currency : meetone
>                 Balance type : trade
>                 Balance : 5
> 
>                 Currency : smt
>                 Balance type : trade
>                 Balance : 0.4461
> 
>                 Currency : uip
>                 Balance type : trade
>                 Balance : 9.8
> 
>                 Currency : portal
>                 Balance type : trade
>                 Balance : 4.9
> 
>                 Currency : add
>                 Balance type : trade
>                 Balance : 5
> 
>                 Currency : mex
>                 Balance type : trade
>                 Balance : 24.5
> 
>                 Currency : cnn
>                 Balance type : trade
>                 Balance : 882
> 
>                 Currency : cdc
>                 Balance type : trade
>                 Balance : 24.5
> 
>                 Currency : hvt
>                 Balance type : trade
>                 Balance : 2.5
> 
>                 Currency : iq
>                 Balance type : trade
>                 Balance : 51
> 
>                 Currency : lxt
>                 Balance type : trade
>                 Balance : 24.5
> 
>                 Currency : egcc
>                 Balance type : trade
>                 Balance : 24.5
> 
>                 Currency : 18c
>                 Balance type : trade
>                 Balance : 9.8
> 
>                 Currency : zla
>                 Balance type : trade
>                 Balance : 2.352
> 
>                 Currency : datx
>                 Balance type : trade
>                 Balance : 14.7
> 
>                 Currency : she
>                 Balance type : trade
>                 Balance : 49
> 
>                 Currency : gsc
>                 Balance type : trade
>                 Balance : 4.9
> 
>                 Currency : tfuel
>                 Balance type : trade
>                 Balance : 168.911
> 
>                 Currency : mds
>                 Balance type : trade
>                 Balance : 22.9753
> 
>         Id : 20XXXXX
>         Account Type : point
>         Account State : working
>         Account ID : 20XXXXX Balance List as below :
>                 Currency : hbpoint
>                 Balance type : trade
>                 Balance : 976.7123546577

这篇关于“帐户"对象没有属性获取Huobi_python API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆