Skip to content

Commit 02bdfd1

Browse files
authored
Merge pull request #1776 from c9s/edwin/bybit/query-wallet-bal
pkg/exchange: update query wallet balance to latest
2 parents 0ca566e + 5a4c38c commit 02bdfd1

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

pkg/exchange/bybit/bybitapi/get_wallet_balances_request.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ type WalletBalances struct {
7070
} `json:"coin"`
7171
}
7272

73-
//go:generate GetRequest -url "/v5/account/wallet-balance" -type GetWalletBalancesRequest -responseDataType .WalletBalancesResponse -rateLimiter 1+15/1s
73+
//go:generate GetRequest -url "/v5/account/wallet-balance" -type GetWalletBalancesRequest -responseDataType .WalletBalancesResponse -rateLimiter 1+45/1s
7474
type GetWalletBalancesRequest struct {
7575
client requestgen.AuthenticatedAPIClient
7676

7777
// Account type
7878
// - Unified account: UNIFIED (trade spot/linear/options), CONTRACT(trade inverse)
7979
// - Normal account: CONTRACT, SPOT
80-
accountType AccountType `param:"accountType,query" validValues:"SPOT"`
80+
accountType AccountType `param:"accountType,query" validValues:"UNIFIED"`
8181
// Coin name
8282
// - If not passed, it returns non-zero asset info
8383
// - You can pass multiple coins to query, separated by comma. USDT,USDC
@@ -87,6 +87,6 @@ type GetWalletBalancesRequest struct {
8787
func (c *RestClient) NewGetWalletBalancesRequest() *GetWalletBalancesRequest {
8888
return &GetWalletBalancesRequest{
8989
client: c,
90-
accountType: AccountTypeSpot,
90+
accountType: AccountTypeUnified,
9191
}
9292
}

pkg/exchange/bybit/bybitapi/get_wallet_balances_request_requestgen.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/exchange/bybit/bybitapi/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const (
127127

128128
type AccountType string
129129

130-
const AccountTypeSpot AccountType = "SPOT"
130+
const AccountTypeUnified AccountType = "UNIFIED"
131131

132132
type MarketUnit string
133133

pkg/exchange/bybit/convert.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -362,14 +362,14 @@ func toGlobalTrade(trade bybitapi.Trade) (*types.Trade, error) {
362362
func toGlobalBalanceMap(events []bybitapi.WalletBalances) types.BalanceMap {
363363
bm := types.BalanceMap{}
364364
for _, event := range events {
365-
if event.AccountType != bybitapi.AccountTypeSpot {
365+
if event.AccountType != bybitapi.AccountTypeUnified {
366366
continue
367367
}
368368

369369
for _, obj := range event.Coins {
370370
bm[obj.Coin] = types.Balance{
371371
Currency: obj.Coin,
372-
Available: obj.Free,
372+
Available: obj.WalletBalance.Sub(obj.Locked),
373373
Locked: obj.Locked,
374374
}
375375
}

0 commit comments

Comments
 (0)