diff --git a/account.go b/account.go index 7284d09..82625fc 100644 --- a/account.go +++ b/account.go @@ -118,3 +118,36 @@ type DeleteSubApiKeyRes struct { ApiKey string `json:"apiKey"` SubName string `json:"subName"` } + +// SubAccountsBalance Get All Sub-Accounts Balance - Futures +func (as *ApiService) SubAccountsBalance(currency string) (*ApiResponse, error) { + p := map[string]string{ + "currency": currency, + } + req := NewRequest(http.MethodGet, "/api/v1/account-overview-all", p) + return as.Call(req) +} + +type SubAccountBalanceModel struct { + Summary struct { + AccountEquityTotal json.Number `json:"accountEquityTotal"` + UnrealisedPNLTotal json.Number `json:"unrealisedPNLTotal"` + MarginBalanceTotal json.Number `json:"marginBalanceTotal"` + PositionMarginTotal json.Number `json:"positionMarginTotal"` + OrderMarginTotal json.Number `json:"orderMarginTotal"` + FrozenFundsTotal json.Number `json:"frozenFundsTotal"` + AvailableBalanceTotal json.Number `json:"availableBalanceTotal"` + Currency string `json:"currency"` + } `json:"summary"` + Accounts []struct { + AccountName string `json:"accountName"` + AccountEquity json.Number `json:"accountEquity"` + UnrealisedPNL json.Number `json:"unrealisedPNL"` + MarginBalance json.Number `json:"marginBalance"` + PositionMargin json.Number `json:"positionMargin"` + OrderMargin json.Number `json:"orderMargin"` + FrozenFunds json.Number `json:"frozenFunds"` + AvailableBalance json.Number `json:"availableBalance"` + Currency string `json:"currency"` + } `json:"accounts"` +} diff --git a/account_test.go b/account_test.go index 59f8c48..47e116d 100644 --- a/account_test.go +++ b/account_test.go @@ -140,3 +140,20 @@ func TestApiService_DeleteSubApiKey(t *testing.T) { } t.Log(ToJsonString(w)) } + +func TestApiService_SubAccountsBalance(t *testing.T) { + s := NewApiServiceFromEnv() + rsp, err := s.SubAccountsBalance("USDT") + if err != nil { + t.Fatal(err) + } + w := SubAccountBalanceModel{} + if err := rsp.ReadData(&w); err != nil { + t.Fatal(err) + } + + t.Log(ToJsonString(w.Summary)) + for _, account := range w.Accounts { + t.Log(ToJsonString(account)) + } +}