Skip to main content

Wallet

Subscribe to the wallet stream to see changes to your wallet in real-time.

Topic: wallet

Response Parameters

ParameterTypeComments
idstringMessage ID
topicstringTopic name
creationTimenumberData created timestamp (ms)
dataarrayObject
> accountTypestringAccount type.
  • Unified account: UNIFIED (spot/linear/options), CONTRACT(inverse)
  • Classic account: CONTRACT, SPOT
> accountLTVstringAccount LTV: account total borrowed size / (account total equity + account total borrowed size). In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> accountIMRatestringInitial Margin Rate: Account Total Initial Margin Base Coin / Account Margin Balance Base Coin. In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> accountMMRatestringMaintenance Margin Rate: Account Total Maintenance Margin Base Coin / Account Margin Balance Base Coin. In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> totalEquitystringEquity of account converted to usd:Account Margin Balance Base Coin + Account Option Value Base Coin. In non-unified mode & unified (inverse), the field will be returned as an empty string.
> totalWalletBalancestringWallet Balance of account converted to usd:∑ Asset Wallet Balance By USD value of each asset。In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> totalMarginBalancestringMargin Balance of account converted to usd:totalWalletBalance + totalPerpUPL. In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> totalAvailableBalancestringAvailable Balance of account converted to usd:Regular mode:totalMarginBalance - totalInitialMargin. In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> totalPerpUPLstringUnrealised P&L of Perpetuals and USDC Futures of account converted to usd:∑ Each Perp and USDC Futures upl by base coin. In non-unified mode & unified (inverse), the field will be returned as an empty string.
> totalInitialMarginstringInitial Margin of account converted to usd:∑ Asset Total Initial Margin Base Coin. In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> totalMaintenanceMarginstringMaintenance Margin of account converted to usd: ∑ Asset Total Maintenance Margin Base Coin. In non-unified mode & unified (inverse) & unified (isolated_margin), the field will be returned as an empty string.
> coinarrayObject
>> coinstringCoin name, such as BTC, ETH, USDT, USDC
>> equitystringEquity of current coin
>> usdValuestringUSD value of current coin. If this coin cannot be collateral, then it is 0
>> walletBalancestringWallet balance of current coin
>> freestringAvailable balance for Spot wallet. This is a unique field for Classic SPOT
>> lockedstringLocked balance due to the Spot open order
>> spotHedgingQtystringThe spot asset qty that is used to hedge in the portfolio margin, truncate to 8 decimals and "0" by default This is a unique field for Unified account
>> borrowAmountstringBorrow amount of current coin
>> availableToBorrowstringDepreciated field, always return "" due to feature of main-sub UID sharing borrow quota. Please refer to availableToBorrow in the Get Collateral Info
>> availableToWithdrawstringAvailable amount to withdraw of current coin
>> accruedIntereststringAccrued interest
>> totalOrderIMstringPre-occupied margin for order. For portfolio margin mode, it returns ""
>> totalPositionIMstringSum of initial margin of all positions + Pre-occupied liquidation fee. For portfolio margin mode, it returns ""
>> totalPositionMMstringSum of maintenance margin for all positions. For portfolio margin mode, it returns ""
>> unrealisedPnlstringUnrealised P&L
>> cumRealisedPnlstringCumulative Realised P&L
>> bonusstringBonus. This is a unique field for UNIFIED account
>> collateralSwitchbooleanWhether it can be used as a margin collateral currency (platform)
  • When marginCollateral=false, then collateralSwitch is meaningless
  • This is a unique field for UNIFIED account
>> marginCollateralbooleanWhether the collateral is turned on by user (user)
  • When marginCollateral=true, then collateralSwitch is meaningful
  • This is a unique field for UNIFIED account

Subscribe Example

{
"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)

Stream Example

{
"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"
}
]
}