You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

from huobi.connection.restapi_sync_client import RestApiSyncClient
from huobi.constant.system import HttpMethod
from huobi.model.account import *
from huobi.utils import *
'''
https://huobiapi.github.io/docs/spot/v1/cn/#bd9157656f
账户余额
API Key 权限:读取
限频值NEW100次/2s
查询指定账户的余额,支持以下账户:
spot现货账户 margin逐仓杠杆账户otcOTC 账户point点卡账户super-margin全仓杠杆账户, investment: C2C杠杆借出账户, borrow: C2C杠杆借入账户
响应数据
{
"data": {
"id": 100009, 账户 ID
"type": "spot", 账户类型 pot现货账户, margin逐仓杠杆账户, otcOTC 账户, point点卡账户, super-margin全仓杠杆账户, investment: C2C杠杆借出账户, borrow: C2C杠杆借入账户矿池账户: minepool, ETF账户: etf, 抵押借贷账户: crypto-loans
"state": "working", 账户状态 working正常 lock账户被锁定
"list": [
{
"currency": "usdt", 币种
"type": "trade", 类型 trade: 交易余额frozen: 冻结余额, loan: 待还借贷本金, interest: 待还借贷利息, lock: 锁仓, bank: 储蓄
"balance": "5007.4362872650" 余额
},
{
"currency": "usdt",
"type": "frozen",
"balance": "348.1199920000"
}
]
}
}
'''
class GetBalanceService:
def __init__(self, params):
self.params = params
def request(self, **kwargs):
account_id = self.params["account-id"]
def get_channel():
path = "/v1/account/accounts/{}/balance"
return path.format(account_id)
def parse(dict_data):
data = dict_data.get("data", {})
balance_list = data.get("list", [])
return default_parse_list_dict(balance_list, Balance, [])
return RestApiSyncClient(**kwargs).request_process(HttpMethod.GET_SIGN, get_channel(), self.params, parse)
def get_request(self, **kwargs):
account_id = self.params["account-id"]
def get_channel():
path = "/v1/account/accounts/{}/balance"
return path.format(account_id)
def parse(dict_data):
data = dict_data.get("data", {})
balance_list = data.get("list", [])
return default_parse_list_dict(balance_list, Balance, [])
return RestApiSyncClient(**kwargs).create_request(HttpMethod.GET_SIGN, get_channel(), self.params, parse)