跳至主要内容

錢包

訂閱錢包數據推送

Topic: wallet

信息
  • 在訂閱成功後不會立馬推送快照數據, 只有當餘額發生變化時, 才會觸發推送
  • 浮動盈虧的變化不會觸發推送

響應參數

參數類型說明
idstring消息id
topicstringTopic名
creationTimenumber消息數據創建時間
dataarrayObject
> accountTypestring帳戶類型 UNIFIED
> accountIMRatestring帳戶初始保證金率
  • 您可以參考該鏈結了解統一帳戶下字段含義和計算方式
  • 下面所有帳戶維度的字段都不適用於逐倉模式
> accountMMRatestring帳戶維持保證金率
> totalEquitystring總凈值為賬戶中每個幣種資產凈值的法幣估值之和 (USD): ∑Asset Equity By USD value of each asset
> totalWalletBalancestring賬戶維度換算成usd的錢包餘額: ∑Asset Wallet Balance By USD value of each asset
> totalMarginBalancestring賬戶維度換算成usd的保證金餘額: totalWalletBalance + totalPerpUPL
> totalAvailableBalancestring賬戶維度換算成usd的可用餘額:
  • 全倉保證金: totalMarginBalance - Haircut - totalInitialMargin.
  • 組合保證金: total Equity - Haircut - totalInitialMargin
> totalPerpUPLstring賬戶維度換算成usd的永續和USDC交割合約的浮動盈虧: ∑Each perp and USDC Futures upl by base coin
> totalInitialMarginstring賬戶維度換算成usd的總初始保證金: ∑Asset Total Initial Margin Base Coin
> totalMaintenanceMarginstring賬戶維度換算成usd的總維持保證金: ∑Asset Total Maintenance Margin Base Coin
> accountIMRateByMpstring忽略, 可以使用accountIMRate, 算法和值保持一致
> accountMMRateByMpstring忽略, 可以使用accountMMRate, 算法和值保持一致
> totalInitialMarginByMpstring忽略, 可以使用totalInitialMargin, 算法和值保持一致
> totalMaintenanceMarginByMpstring忽略, 可以使用totalMaintenanceMargin, 算法和值保持一致
> accountLTVstring廢棄字段
> coinarrayObject. 幣種列表
>> coinstring幣種名稱,例如 BTC, ETH, USDT, USDC
>> equitystring當前幣種的資產淨值: Asset Equity = Asset Wallet Balance + Asset Perp UPL + Asset Future UPL + Asset Option Value = walletBalance - spotBorrow + unrealisedPnl + Asset Option Value
>> usdValuestring當前幣種折算成 usd 的價值, 如果該幣種不能作為保證金的抵押品, 則該數值為0
>> walletBalancestring當前幣種的錢包餘額 = 現貨負債 + 合約浮虧導致借幣產生的借幣負債
>> lockedstring現貨掛單凍結金額
>> spotHedgingQtystring用於組合保證金(PM)現貨對衝的數量, 截斷至8為小數, 默認為0
>> borrowAmountstring當前幣種的已用借貸額度
>> accruedIntereststring當前幣種的預計要在下一個利息週期收取的利息金額
>> totalOrderIMstring以當前幣種結算的訂單委託預佔用保證金. 組合保證金模式下,該字段返回空字符串
>> totalPositionIMstring以當前幣種結算的所有倉位起始保證金求和 + 所有倉位的預佔用平倉手續費. 組合保證金模式下,該字段返回空字符串
>> totalPositionMMstring以當前幣種結算的所有倉位維持保證金求和. 組合保證金模式下,該字段返回空字符串
>> unrealisedPnlstring以當前幣種結算的所有倉位的未結盈虧之和
>> cumRealisedPnlstring以當前幣種結算的所有倉位的累計已結盈虧之和
>> bonusstring體驗金
>> marginCollateralboolean是否可作為保證金抵押幣種(平台維度), true: 是. false: 否
  • 當marginCollateral=false時, 則collateralSwitch無意義
>> collateralSwitchboolean用戶是否開啟保證金幣種抵押(用戶維度), true: 是. false: 否
  • 僅當marginCollateral=true時, 才能主動選擇開關抵押
>> spotBorrowstring現貨槓桿交易借入金額以及手工借貸金額(不包含現貨槓桿活躍訂單借入金額)。現貨負債對應的spotBorrow, 請詳見公告.
>> freestring廢棄, 不再有現貨錢包
>> availableToWithdrawstring該字段從2025年1月9日起已經廢棄
>> availableToBorrowstring廢棄, 由於母子共享借貸限額, 總是返回"". 請通過查詢抵押品信息接口查詢availableToBorrow

訂閱示例

{
"op": "subscribe",
"args": [
"wallet"
]
}
from pybit.unified_trading import WebSocket
from time import sleep
ws = WebSocket(
testnet=True,
channel_type="private",
api_key="xxxxxxxxxxxxxxxxxx",
api_secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
)
def handle_message(message):
print(message)
ws.wallet_stream(callback=handle_message)
while True:
sleep(1)

推送示例

{
"id": "592324d2bce751-ad38-48eb-8f42-4671d1fb4d4e",
"topic": "wallet",
"creationTime": 1700034722104,
"data": [
{
"accountIMRate": "0",
"accountIMRateByMp": "0",
"accountMMRate": "0",
"accountMMRateByMp": "0",
"totalEquity": "10262.91335023",
"totalWalletBalance": "9684.46297164",
"totalMarginBalance": "9684.46297164",
"totalAvailableBalance": "9556.6056555",
"totalPerpUPL": "0",
"totalInitialMargin": "0",
"totalInitialMarginByMp": "0",
"totalMaintenanceMargin": "0",
"totalMaintenanceMarginByMp": "0",
"coin": [
{
"coin": "BTC",
"equity": "0.00102964",
"usdValue": "36.70759517",
"walletBalance": "0.00102964",
"availableToWithdraw": "0.00102964",
"availableToBorrow": "",
"borrowAmount": "0",
"accruedInterest": "0",
"totalOrderIM": "",
"totalPositionIM": "",
"totalPositionMM": "",
"unrealisedPnl": "0",
"cumRealisedPnl": "-0.00000973",
"bonus": "0",
"collateralSwitch": true,
"marginCollateral": true,
"locked": "0",
"spotHedgingQty": "0.01592413"
}
],
"accountLTV": "0",
"accountType": "UNIFIED"
}
]
}