Wallet
Subscribe to the wallet stream to see changes to your wallet in real-time.
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 | Account 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. |
> accountIMRate | string | Initial 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. |
> accountMMRate | string | Maintenance 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. |
> totalEquity | string | Equity 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. |
> totalWalletBalance | string | Wallet 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. |
> totalMarginBalance | string | Margin 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. |
> totalAvailableBalance | string | Available 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. |
> totalPerpUPL | string | Unrealised 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. |
> totalInitialMargin | string | Initial 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. |
> totalMaintenanceMargin | string | Maintenance 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. |
> coin | array | Object |
>> coin | string | Coin name, such as BTC, ETH, USDT, USDC |
>> equity | string | Equity of current coin |
>> usdValue | string | USD value of current coin. If this coin cannot be collateral, then it is 0 |
>> walletBalance | string | Wallet balance of current 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 current coin |
>> availableToBorrow | string | Depreciated 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 current 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"
}
]
}