Wallet
Subscribe to the wallet stream to see changes to your wallet in real-time.
info
- There is no snapshot event given at the time when the subscription is successful
- The unrealised PnL change does not trigger an event
Topic: wallet
Response Parameters
Parameter | Type | Comments |
---|---|---|
id | string | Message ID |
topic | string | Topic name |
creationTime | number | Data created timestamp (ms) |
data | array | Object |
> accountType | string | Account type. |
> accountLTV | string | deprecated field |
> accountIMRate | string | Account IM rate UTA2.0(isolated margin), UTA1.0(isolated margin), UTA1.0(CONTRACT), classic account(SPOT, CONTRACT) |
> accountMMRate | string | Account MM rate |
> totalEquity | string | Account total equity (USD) |
> totalWalletBalance | string | Account wallet balance (USD): ∑Asset Wallet Balance By USD value of each asset |
> totalMarginBalance | string | Account margin balance (USD): totalWalletBalance + totalPerpUPL |
> totalAvailableBalance | string | Account available balance (USD), Cross Margin: totalMarginBalance - totalInitialMargin |
> totalPerpUPL | string | Account Perps and Futures unrealised p&l (USD): ∑Each Perp and USDC Futures upl by base coin |
> totalInitialMargin | string | Account initial margin (USD): ∑Asset Total Initial Margin Base Coin |
> totalMaintenanceMargin | string | Account maintenance margin (USD): ∑ Asset Total Maintenance Margin Base Coin |
> coin | array | Object |
>> coin | string | Coin name, such as BTC, ETH, USDT, USDC |
>> equity | string | Equity of coin |
>> usdValue | string | USD value of coin. If this coin cannot be collateral, then it is 0 |
>> walletBalance | string | Wallet balance of coin |
>> free | string | Available balance for Spot wallet. This is a unique field for Classic SPOT |
>> locked | string | Locked balance due to the Spot open order |
>> spotHedgingQty | string | The 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 |
>> borrowAmount | string | Borrow amount of coin |
>> availableToBorrow | string | deprecated field, always return "" due to feature of main-sub UID sharing borrow quota. Please refer to availableToBorrow in the Get Collateral Info |
>> availableToWithdraw | string | Available amount to withdraw of coin |
>> accruedInterest | string | Accrued interest |
>> totalOrderIM | string | Pre-occupied margin for order. For portfolio margin mode, it returns "" |
>> totalPositionIM | string | Sum of initial margin of all positions + Pre-occupied liquidation fee. For portfolio margin mode, it returns "" |
>> totalPositionMM | string | Sum of maintenance margin for all positions. For portfolio margin mode, it returns "" |
>> unrealisedPnl | string | Unrealised P&L |
>> cumRealisedPnl | string | Cumulative Realised P&L |
>> bonus | string | Bonus. This is a unique field for UNIFIED account |
>> collateralSwitch | boolean | Whether it can be used as a margin collateral currency (platform)
|
>> marginCollateral | boolean | Whether the collateral is turned on by user (user)
|
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"
}
]
}