mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-14 15:09:51 +00:00
Implements endpoint GetAggregatedBalance for Hadax too. (#330)
This commit is contained in:
@@ -36,6 +36,7 @@ const (
|
||||
huobihadaxCurrencies = "common/currencys"
|
||||
huobihadaxTimestamp = "common/timestamp"
|
||||
huobihadaxAccounts = "account/accounts"
|
||||
huobihadaxAggregatedBalance = "subuser/aggregate-balance"
|
||||
huobihadaxAccountBalance = "account/accounts/%s/balance"
|
||||
huobihadaxOrderPlace = "order/orders/place"
|
||||
huobihadaxOrderCancel = "order/orders/%s/submitcancel"
|
||||
@@ -389,6 +390,28 @@ func (h *HUOBIHADAX) GetAccountBalance(accountID string) ([]AccountBalanceDetail
|
||||
return result.AccountBalanceData.AccountBalanceDetails, err
|
||||
}
|
||||
|
||||
// GetAggregatedBalance returns the balances of all the sub-account aggregated.
|
||||
func (h *HUOBIHADAX) GetAggregatedBalance() ([]AggregatedBalance, error) {
|
||||
type response struct {
|
||||
Response
|
||||
AggregatedBalances []AggregatedBalance `json:"data"`
|
||||
}
|
||||
|
||||
var result response
|
||||
|
||||
err := h.SendAuthenticatedHTTPRequest(
|
||||
http.MethodGet,
|
||||
huobihadaxAggregatedBalance,
|
||||
url.Values{},
|
||||
&result,
|
||||
)
|
||||
|
||||
if result.ErrorMessage != "" {
|
||||
return nil, errors.New(result.ErrorMessage)
|
||||
}
|
||||
return result.AggregatedBalances, err
|
||||
}
|
||||
|
||||
// SpotNewOrder submits an order to Huobi
|
||||
func (h *HUOBIHADAX) SpotNewOrder(arg SpotNewOrderRequestParams) (int64, error) {
|
||||
vals := make(map[string]string)
|
||||
|
||||
@@ -202,6 +202,18 @@ func TestGetAccountBalance(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAggregatedBalance(t *testing.T) {
|
||||
t.Parallel()
|
||||
if h.APIKey == "" || h.APISecret == "" || h.APIAuthPEMKey == "" {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
_, err := h.GetAggregatedBalance()
|
||||
if err != nil {
|
||||
t.Errorf("Test failed - Huobi GetAggregatedBalance: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpotNewOrder(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -113,6 +113,12 @@ type AccountBalanceDetail struct {
|
||||
Balance float64 `json:"balance,string"`
|
||||
}
|
||||
|
||||
// AggregatedBalance stores balances of all the sub-account
|
||||
type AggregatedBalance struct {
|
||||
Currency string `json:"currency"`
|
||||
Balance float64 `json:"balance,string"`
|
||||
}
|
||||
|
||||
// CancelOrderBatch stores the cancel order batch data
|
||||
type CancelOrderBatch struct {
|
||||
Success []string `json:"success"`
|
||||
|
||||
Reference in New Issue
Block a user