From ff860cfb0c25fb8535303a1419fdaceeb1bbd436 Mon Sep 17 00:00:00 2001 From: Rostislav <43965646+lyro41@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:12:56 +0300 Subject: [PATCH] update v5 account endpoint get wallet balance (#187) --- .../v5-account-get-wallet-balance.json | 45 ++++++++----------- v5_account_service.go | 36 ++++++++------- v5_account_service_test.go | 6 ++- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/integrationtest/v5/account/testdata/v5-account-get-wallet-balance.json b/integrationtest/v5/account/testdata/v5-account-get-wallet-balance.json index 854a82c..85af799 100644 --- a/integrationtest/v5/account/testdata/v5-account-get-wallet-balance.json +++ b/integrationtest/v5/account/testdata/v5-account-get-wallet-balance.json @@ -1,48 +1,39 @@ { "list": [ { - "totalEquity": "30587.3509045", + "totalEquity": "0.00009475", "accountIMRate": "0", - "totalMarginBalance": "30587.3509045", + "totalMarginBalance": "0.00009475", "totalInitialMargin": "0", "accountType": "UNIFIED", - "totalAvailableBalance": "30587.3509045", + "totalAvailableBalance": "0.00009475", "accountMMRate": "0", "totalPerpUPL": "0", - "totalWalletBalance": "30587.3509045", + "totalWalletBalance": "0.00009475", + "accountLTV": "0", "totalMaintenanceMargin": "0", "coin": [ { - "availableToBorrow": "2.5", + "availableToBorrow": "", + "bonus": "0", "accruedInterest": "0", - "availableToWithdraw": "1.258926", + "availableToWithdraw": "0.0000948", "totalOrderIM": "0", - "equity": "1.258926", + "equity": "0.0000948", "totalPositionMM": "0", - "usdValue": "29579.89105993", + "usdValue": "0.00009475", "unrealisedPnl": "0", - "borrowAmount": "0.0", + "collateralSwitch": true, + "spotHedgingQty": "0", + "borrowAmount": "0.000000000000000000", "totalPositionIM": "0", - "walletBalance": "1.258926", - "cumRealisedPnl": "0", - "coin": "BTC" - }, - { - "availableToBorrow": "2500000", - "accruedInterest": "0", - "availableToWithdraw": "912.35705796", - "totalOrderIM": "0", - "equity": "1012.35705796", - "totalPositionMM": "0", - "usdValue": "1007.45984457", - "unrealisedPnl": "0", - "borrowAmount": "0.0", - "totalPositionIM": "0", - "walletBalance": "1012.35705796", - "cumRealisedPnl": "0", + "walletBalance": "0.0000948", + "cumRealisedPnl": "-43291.2691172", + "locked": "0", + "marginCollateral": true, "coin": "USDT" } ] } ] -} \ No newline at end of file + } \ No newline at end of file diff --git a/v5_account_service.go b/v5_account_service.go index 5d940aa..358b630 100644 --- a/v5_account_service.go +++ b/v5_account_service.go @@ -38,34 +38,40 @@ type V5WalletBalanceResult struct { // V5WalletBalanceCoin : type V5WalletBalanceCoin struct { - AvailableToBorrow string `json:"availableToBorrow"` - AccruedInterest string `json:"accruedInterest"` - AvailableToWithdraw string `json:"availableToWithdraw"` - TotalOrderIM string `json:"totalOrderIM"` + Coin Coin `json:"coin"` Equity string `json:"equity"` - TotalPositionMM string `json:"totalPositionMM"` UsdValue string `json:"usdValue"` - UnrealisedPnl string `json:"unrealisedPnl"` + WalletBalance string `json:"walletBalance"` + Free string `json:"free,omitempty"` + Locked string `json:"locked"` + SpotHedgingQuantity string `json:"spotHedgingQty"` BorrowAmount string `json:"borrowAmount"` + AvailableToWithdraw string `json:"availableToWithdraw"` + AccruedInterest string `json:"accruedInterest"` + TotalOrderIM string `json:"totalOrderIM"` TotalPositionIM string `json:"totalPositionIM"` - WalletBalance string `json:"walletBalance"` + TotalPositionMM string `json:"totalPositionMM"` + UnrealisedPnl string `json:"unrealisedPnl"` CumRealisedPnl string `json:"cumRealisedPnl"` - Free string `json:"free"` - Locked string `json:"locked"` - Coin Coin `json:"coin"` + Bonus string `json:"bonus"` + MarginCollateral bool `json:"marginCollateral"` + CollateralSwitch bool `json:"collateralSwitch"` + AvailableToBorrow string `json:"availableToBorrow"` } // V5WalletBalanceList : type V5WalletBalanceList struct { - TotalEquity string `json:"totalEquity"` + AccountType string `json:"accountType"` + // Deprecated: + AccountLTV string `json:"accountLTV"` AccountIMRate string `json:"accountIMRate"` + AccountMMRate string `json:"accountMMRate"` + TotalEquity string `json:"totalEquity"` + TotalWalletBalance string `json:"totalWalletBalance"` TotalMarginBalance string `json:"totalMarginBalance"` - TotalInitialMargin string `json:"totalInitialMargin"` - AccountType string `json:"accountType"` TotalAvailableBalance string `json:"totalAvailableBalance"` - AccountMMRate string `json:"accountMMRate"` TotalPerpUPL string `json:"totalPerpUPL"` - TotalWalletBalance string `json:"totalWalletBalance"` + TotalInitialMargin string `json:"totalInitialMargin"` TotalMaintenanceMargin string `json:"totalMaintenanceMargin"` Coin []V5WalletBalanceCoin `json:"coin"` } diff --git a/v5_account_service_test.go b/v5_account_service_test.go index 6dfccb8..906e1d9 100644 --- a/v5_account_service_test.go +++ b/v5_account_service_test.go @@ -28,10 +28,12 @@ func TestV5Account_GetWalletBalance(t *testing.T) { "accountMMRate": "0", "totalPerpUPL": "-0.11001349", "totalWalletBalance": "18070.43799271", + "accountLTV": "0", "totalMaintenanceMargin": "0.38106773", "coin": []map[string]interface{}{ { "availableToBorrow": "2.5", + "bonus": "0", "accruedInterest": "0", "availableToWithdraw": "0.805994", "totalOrderIM": "0", @@ -39,12 +41,14 @@ func TestV5Account_GetWalletBalance(t *testing.T) { "totalPositionMM": "0", "usdValue": "12920.95352538", "unrealisedPnl": "0", + "collateralSwitch": true, + "spotHedgingQty": "0", "borrowAmount": "0", "totalPositionIM": "0", "walletBalance": "0.805994", - "free": "", "locked": "", "cumRealisedPnl": "0", + "marginCollateral": true, "coin": "BTC", }, },