跳至主要内容

錢包

訂閱錢包數據推送

Topic: wallet

響應參數

參數類型說明
idstring消息id
topicstringTopic名
creationTimenumber消息數據創建時間
dataarrayObject
> accountTypestring帳戶類型.
  • 統一帳戶: UNIFIED(現貨/USDT和USDC永續/期權), CONTRACT(反向合約)
  • 經典帳戶: CONTRACT, SPOT
> accountLTVstring帳戶LTV: account total borrowed size / (account total equity + account total borrowed size). 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
> accountIMRatestring帳戶初始保證金率: Account Total Initial Margin Base Coin / Account Margin Balance Base Coin. 非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
> accountMMRatestring帳戶維持保證金率: Account Total Maintenance Margin Base Coin / Account Margin Balance Base Coin。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
> totalEquitystring賬戶維度換算成usd的資產淨值:Account Margin Balance Base Coin + Account Option Value Base Coin。非統一保證金模式和統一帳戶(反向)下,該字段返回為空。
> totalWalletBalancestring賬戶維度換算成usd的產錢包餘額:∑ Asset Wallet Balance By USD value of each asset。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
> totalMarginBalancestring賬戶維度換算成usd的保證金餘額:totalWalletBalance + totalPerpUPL。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
> totalAvailableBalancestring賬戶維度換算成usd的可用餘額:RM:totalMarginBalance - 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。非統一保證金模式和統一帳戶(反向)以及統一帳戶(逐倉模式),該字段返回為空。
> coinarrayObject. 幣種列表
>> coinstring幣種名稱,例如 BTC,ETH,USDT,USDC
>> equitystring當前幣種的資產淨值
>> usdValuestring當前幣種折算成 usd 的價值,如果該幣種不能作為保證金的抵押品,則該數值為0
>> walletBalancestring當前幣種的錢包餘額
>> freestring經典帳戶現貨錢包的可用餘額. 經典帳戶現貨錢包的獨有字段
>> lockedstring現貨掛單凍結金額
>> spotHedgingQtystring用於組合保證金(PM)現貨對衝的數量, 截斷至8為小數, 默認為0 統一帳戶的獨有字段
>> borrowAmountstring當前幣種的已用借貸額度
>> availableToBorrowstring由於母子共享借貸限額, 該字段已廢棄, 總是返回"". 請通過查詢抵押品信息接口查詢availableToBorrow
>> availableToWithdrawstring當前幣種的可劃轉提現金額
>> accruedIntereststring當前幣種的預計要在下一個利息週期收取的利息金額
>> totalOrderIMstring以當前幣種結算的訂單委託預佔用保證金. 組合保證金模式下,該字段返回空字符串
>> totalPositionIMstring以當前幣種結算的所有倉位起始保證金求和 + 所有倉位的預佔用平倉手續費. 組合保證金模式下,該字段返回空字符串
>> totalPositionMMstring以當前幣種結算的所有倉位維持保證金求和. 組合保證金模式下,該字段返回空字符串
>> unrealisedPnlstring以當前幣種結算的所有倉位的未結盈虧之和
>> cumRealisedPnlstring以當前幣種結算的所有倉位的累計已結盈虧之和
>> bonusstring體驗金. UNIFIED帳戶的獨有字段
>> marginCollateralboolean是否可作為保證金抵押幣種(平台維度), true: 是. false: 否
  • 當marginCollateral=false時, 則collateralSwitch無意義
  • UNIFIED帳戶的獨有字段
>> collateralSwitchboolean用戶是否開啟保證金幣種抵押(用戶維度), true: 是. false: 否
  • 僅當marginCollateral=true時, 才能主動選擇開關抵押
  • UNIFIED帳戶的獨有字段

訂閱示例

{
"op": "subscribe",
"args": [
"wallet"
]
}
from pybit.unified_trading import WebSocket
from time import sleep
ws = WebSocket(
testnet=True,
channel_type="private",
api_key="XXXXX",
api_secret="XXXXX",
)
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",
"accountMMRate": "0",
"totalEquity": "10262.91335023",
"totalWalletBalance": "9684.46297164",
"totalMarginBalance": "9684.46297164",
"totalAvailableBalance": "9556.6056555",
"totalPerpUPL": "0",
"totalInitialMargin": "0",
"totalMaintenanceMargin": "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"
}
]
}