查詢錢包餘額
獲取統一帳戶和經典帳戶錢包餘額, 查詢各個幣種的資產信息. 默認不返回資產或負債為0的幣種信息。
信息
在UTA手動借貸新邏輯下,現貨負債對應的spotBorrow, 請詳見公告.
舊 walletBalance = 新 walletBalance - spotBorrow
HTTP 請求
GET /v5/account/wallet-balance
請求參數
| 參數 | 是否必需 | 類型 | 說明 |
|---|---|---|---|
| accountType | true | string | 帳戶類型 要查詢資金帳戶餘額, 可以使用這個接口 |
| coin | false | string | 幣種名稱
|
響應參數
| 參數 | 類型 | 說明 |
|---|---|---|
| list | array | Object |
| > accountType | string | 帳戶類型 |
| > accountLTV | string | 字段廢棄 |
| > accountIMRate | string | 帳戶初始保證金率 統一帳戶2.0(逐倉模式), 統一帳戶1.0(逐倉模式), 統一帳戶1.0(CONTRACT), 經典帳戶(SPOT, CONTRACT) |
| > accountIMRateByMp | string | 帳戶初始保證金率(用mark price計算) 統一帳戶2.0(逐倉模式), 統一帳戶1.0(逐倉模式), 統一帳戶1.0(CONTRACT), 經典帳戶(SPOT, CONTRACT) |
| > accountMMRate | string | 帳戶維持保證金率 |
| > accountMMRateByMp | string | 帳戶維持保證金率(用mark price計算) |
| > totalEquity | string | 總凈值為賬戶中每個幣種資產凈值的法幣估值之和 (USD): ∑Asset Equity By USD value of each asset |
| > totalWalletBalance | string | 賬戶維度換算成usd的錢包餘額: ∑Asset Wallet Balance By USD value of each asset |
| > totalMarginBalance | string | 賬戶維度換算成usd的保證金餘額: totalWalletBalance + totalPerpUPL |
| > totalAvailableBalance | string | 賬戶維度換算成usd的可用餘額:
|
| > totalPerpUPL | string | 賬戶維度換算成usd的永續和USDC交割合約的浮動盈虧: ∑Each perp and USDC Futures upl by base coin |
| > totalInitialMargin | string | 賬戶維度換算成usd的總初始保證金: ∑Asset Total Initial Margin Base Coin |
| > totalInitialMarginByMp | string | 賬戶維度換算成usd的總初始保證金(用mark price計算): ∑Asset Total Initial Margin Base Coin |
| > totalMaintenanceMargin | string | 賬戶維度換算成usd的總維持保證金: ∑Asset Total Maintenance Margin Base Coin |
| > totalMaintenanceMarginByMp | string | 賬戶維度換算成usd的總維持保證金(用mark price計算): ∑Asset Total Maintenance Margin Base Coin |
| > coin | arrays | 幣種列表 |
| >> coin | string | 幣種名稱,例如 BTC, ETH, USDT, USDC |
| >> equity | string | 當前幣種的資產淨值. Asset Equity = Asset Wallet Balance + Asset Perp UPL + Asset Future UPL + Asset Option Value = walletBalance - spotBorrow + unrealisedPnl + Asset Option Value |
| >> usdValue | string | 當前幣種折算成 usd 的價值 |
| >> walletBalance | string | 當前幣種的錢包餘額 |
| >> free | string | 經典帳戶現貨錢包的可用餘額. 經典帳戶現貨錢包的獨有字段 |
| >> locked | string | 現貨掛單凍結金額 |
| >> spotHedgingQty | string | 用於組合保證金(PM)現貨對衝的數量, 截斷至8為小數, 默認為0 統一帳戶的獨有字段 |
| >> borrowAmount | string | 當前幣種的已用借貸額度 = 現貨負債 + 合約浮虧導致借幣產生的借幣負債 |
| >> availableToWithdraw | string | 注意: 對於accountType=UNIFIED, 該字段從2025年1月9日起已經廢棄
|
| >> accruedInterest | string | 當前幣種的預計要在下一個利息週期收取的利息金額 |
| >> totalOrderIM | string | 以當前幣種結算的訂單委託預佔用保證金. 組合保證金模式下,該字段返回空字符串 |
| >> totalPositionIM | string | 以當前幣種結算的所有倉位起始保證金求和 + 所有倉位的預佔用平倉手續費. 組合保證金模式下,該字段返回空字符串 |
| >> totalPositionMM | string | 以當前幣種結算的所有倉位維持保證金求和. 組合保證金模式下,該字段返回空字符串 |
| >> unrealisedPnl | string | 以當前幣種結算的所有倉位的未結盈虧之和 |
| >> cumRealisedPnl | string | 以當前幣種結算的所有倉位的累計已結盈虧之和 |
| >> bonus | string | 體驗金. UNIFIED帳戶的獨有字段 |
| >> marginCollateral | boolean | 是否可作為保證金抵押幣種(平台維度), true: 是. false: 否
|
| >> collateralSwitch | boolean | 用戶是否開啟保證金幣種抵押(用戶維度), true: 是. false: 否
|
| >> availableToBorrow | string | 由於母子共享借貸限額, 該字段已廢棄, 總是返回"". 請通過查詢抵押品信息接口查詢availableToBorrow |
| >> spotBorrow | string | 現貨槓桿交易借入金額以及手工借貸金額(不包含現貨槓桿活躍訂單借入金額)。現貨負債對應的spotBorrow, 請詳見公告. |
請求示例
- HTTP
- Python
- Node.js
GET /v5/account/wallet-balance?accountType=UNIFIED&coin=BTC HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: xxxxxxxxxxxxxxxxxx
X-BAPI-TIMESTAMP: 1672125440406
X-BAPI-RECV-WINDOW: 5000
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="xxxxxxxxxxxxxxxxxx",
api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
)
print(session.get_wallet_balance(
accountType="UNIFIED",
coin="BTC",
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'xxxxxxxxxxxxxxxxxx',
secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
});
client
.getWalletBalance({
accountType: 'UNIFIED',
coin: 'BTC',
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
響應示例
{
"retCode": 0,
"retMsg": "OK",
"result": {
"list": [
{
"totalEquity": "18070.32797922",
"accountIMRate": "0.0101",
"accountIMRateByMp": "0.0101",
"totalMarginBalance": "18070.32797922",
"totalInitialMargin": "182.60183684",
"totalInitialMarginByMp": "182.60183684",
"accountType": "UNIFIED",
"totalAvailableBalance": "17887.72614237",
"accountMMRate": "0",
"accountMMRateByMp": "0",
"totalPerpUPL": "-0.11001349",
"totalWalletBalance": "18070.43799271",
"accountLTV": "0.017",
"totalMaintenanceMargin": "0.38106773",
"totalMaintenanceMarginByMp": "0.38106773",
"coin": [
{
"availableToBorrow": "3",
"bonus": "0",
"accruedInterest": "0",
"availableToWithdraw": "0",
"totalOrderIM": "0",
"equity": "0",
"totalPositionMM": "0",
"usdValue": "0",
"spotHedgingQty": "0.01592413",
"unrealisedPnl": "0",
"collateralSwitch": true,
"borrowAmount": "0.0",
"totalPositionIM": "0",
"walletBalance": "0",
"cumRealisedPnl": "0",
"locked": "0",
"marginCollateral": true,
"coin": "BTC",
"spotBorrow": "0"
}
]
}
]
},
"retExtInfo": {},
"time": 1672125441042
}