Skip to content
Sign In

Learning / Syntax / balance

balance - Query Account Balance

Retrieve your current account balance and position information.

What is balance?

balance is a simple utility command that returns your current account balance for the exchange and asset in your webhook.

The exact information returned depends on the exchange and market type (spot vs futures), but typically includes:

  • Total balance (equity)

  • Available balance (free to trade)

  • Used balance (locked in orders/positions)

  • Current position size (for futures)

Syntax

Smart Syntax
// Default: USDT or USDC
balance
// Specify coin
balance ALGO

The coin parameter is optional. Call balance without parameters to query the default coin (USDT for most exchanges, USDC for Binance Spot).

Parameters

coinOptional

Type: string | Default: USDT (USDC for Binance Spot)

Specify which coin/asset balance to query. If not provided, defaults to:

  • • USDT - ByBit, Kucoin, and most exchanges
  • • USDC - Binance Spot

Examples: balance BTC, balance ETH, balance USDT

Real-World Examples

1. Check Balance Before Trading

Query balance at the start of your webhook to verify available funds.

Smart Syntax
BTCUSDT on My_API_Key
// Check current balance
balance
// Continue with trading
market long 0.01

Balance info will appear in the webhook execution log before the market order executes.

2. Verify Trade Execution

Check balance before and after trading to confirm orders executed correctly.

Smart Syntax
ETHUSDT on My_API_Key
// Balance before
balance
market long 0.5
// Balance after
balance

Compare before/after balances to see the exact impact of your trade.

3. Query Specific Coin Balance

Check balance of a specific coin.

Smart Syntax
BTCUSDT on My_API_Key
// Check BTC balance
balance BTC
// Check ETH balance
balance ETH
// Check USDT balance
balance USDT

Query balances for multiple coins in a single webhook.

4. Position Verification

Use with position management to verify your current position size.

Smart Syntax
BTCUSDT on My_API_Key
rem all
pos 0
// Verify position closed
balance
market long 0.01
// Verify new position
balance

Confirms position was closed before entering new one, and verifies new position size.

5. Debug Webhook Issues

When troubleshooting, add balance commands to understand execution flow.

Smart Syntax
BTCUSDT on My_API_Key
// Checkpoint 1
balance
market long 50%
// Checkpoint 2
balance
sl-or-tp short 100%p sl off 2% tp off 5%
// Checkpoint 3
balance

Multiple balance commands create checkpoints to see exactly where issues occur.

Response Format

The balance information appears in your webhook execution log. Typical response includes:

Smart Syntax
// Example Balance Response (ByBit Futures)
{
"coin": "USDT",
"balance": {
"coin": "USDT",
"free": 66.80098378,
"used": 0.0,
"total": 66.80098378
}
}

Fields vary by exchange, but typically show total balance, available (free), and used (locked) amounts.

Best Practices

  • Use for debugging - Add balance commands when troubleshooting webhook issues

  • Verify position changes - Check balance before and after position modifications

  • Monitor available funds - Confirm you have enough balance for planned trades

  • Check execution logs - Balance info appears in webhook execution history

Related Commands

market

- Execute trades based on balance

set

- Configure exchange settings like leverage