Skip to content

Commit

Permalink
update v5 account endpoint get wallet balance (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyro41 authored Oct 24, 2024
1 parent e79afee commit ff860cf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
}
36 changes: 21 additions & 15 deletions v5_account_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
6 changes: 5 additions & 1 deletion v5_account_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,27 @@ 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",
"equity": "0.805994",
"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",
},
},
Expand Down

0 comments on commit ff860cf

Please sign in to comment.