Skip to content
This repository was archived by the owner on Dec 11, 2024. It is now read-only.

Commit 808ab80

Browse files
committed
add a new api for subAccounts balance info
1 parent aa4478f commit 808ab80

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

account.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,36 @@ type DeleteSubApiKeyRes struct {
118118
ApiKey string `json:"apiKey"`
119119
SubName string `json:"subName"`
120120
}
121+
122+
// SubAccountsBalance Get All Sub-Accounts Balance - Futures
123+
func (as *ApiService) SubAccountsBalance(currency string) (*ApiResponse, error) {
124+
p := map[string]string{
125+
"currency": currency,
126+
}
127+
req := NewRequest(http.MethodGet, "/api/v1/account-overview-all", p)
128+
return as.Call(req)
129+
}
130+
131+
type SubAccountBalanceModel struct {
132+
Summary struct {
133+
AccountEquityTotal json.Number `json:"accountEquityTotal"`
134+
UnrealisedPNLTotal json.Number `json:"unrealisedPNLTotal"`
135+
MarginBalanceTotal json.Number `json:"marginBalanceTotal"`
136+
PositionMarginTotal json.Number `json:"positionMarginTotal"`
137+
OrderMarginTotal json.Number `json:"orderMarginTotal"`
138+
FrozenFundsTotal json.Number `json:"frozenFundsTotal"`
139+
AvailableBalanceTotal json.Number `json:"availableBalanceTotal"`
140+
Currency string `json:"currency"`
141+
} `json:"summary"`
142+
Accounts []struct {
143+
AccountName string `json:"accountName"`
144+
AccountEquity json.Number `json:"accountEquity"`
145+
UnrealisedPNL json.Number `json:"unrealisedPNL"`
146+
MarginBalance json.Number `json:"marginBalance"`
147+
PositionMargin json.Number `json:"positionMargin"`
148+
OrderMargin json.Number `json:"orderMargin"`
149+
FrozenFunds json.Number `json:"frozenFunds"`
150+
AvailableBalance json.Number `json:"availableBalance"`
151+
Currency string `json:"currency"`
152+
} `json:"accounts"`
153+
}

account_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,20 @@ func TestApiService_DeleteSubApiKey(t *testing.T) {
140140
}
141141
t.Log(ToJsonString(w))
142142
}
143+
144+
func TestApiService_SubAccountsBalance(t *testing.T) {
145+
s := NewApiServiceFromEnv()
146+
rsp, err := s.SubAccountsBalance("USDT")
147+
if err != nil {
148+
t.Fatal(err)
149+
}
150+
w := SubAccountBalanceModel{}
151+
if err := rsp.ReadData(&w); err != nil {
152+
t.Fatal(err)
153+
}
154+
155+
t.Log(ToJsonString(w.Summary))
156+
for _, account := range w.Accounts {
157+
t.Log(ToJsonString(account))
158+
}
159+
}

0 commit comments

Comments
 (0)