Skip to content
Igor Sazonov edited this page Apr 5, 2026 · 1 revision

Questions you're probably asking. Answers that actually help.


🔑 Authentication & Setup

How do I get API keys?

  1. Go to BingX API Management
  2. Click "Create API"
  3. Save your Secret Key immediately — you'll only see it once!
  4. Set permissions based on what you need

What permissions do I need?

Task Permissions Needed
View prices, charts None (public data)
Check balance, positions Read
Place orders Read + Trade
Withdraw funds Read + Trade + Withdraw

Tip: Start with Read-only while testing. Add Trade when you're ready.

Why am I getting "Invalid API Key"?

Common causes:

  1. Typo — Copy-paste, don't type manually
  2. Wrong key type — Make sure it's for Futures, not Spot
  3. IP restriction — Check if your IP is whitelisted
  4. Key disabled — Check API management page
// Test your connection
try {
    $time = Bingx::market()->getServerTime();
    echo "Connected! Server time: {$time['serverTime']}\n";
} catch (\Exception $e) {
    echo "Connection failed: {$e->getMessage()}\n";
}

What's the difference between hex and base64 signature encoding?

Both work. BingX accepts either. We default to base64 because it's slightly more compact.

# In your .env file
BINGX_SIGNATURE_ENCODING=base64  # or 'hex'

💰 Trading Questions

How do I calculate position size?

// Risk 2% of account with 5% stop loss at 10x leverage
$balance = Bingx::account()->getBalance()['balance']['availableMargin'];
$riskAmount = $balance * 0.02;  // 2% risk
$stopLossPercent = 0.05;        // 5% stop

$positionValue = $riskAmount / $stopLossPercent;
$marginNeeded = $positionValue / 10;  // 10x leverage
$quantity = $positionValue / $currentPrice;

What's the difference between LONG and SHORT?

  • LONG = You profit when price goes UP
  • SHORT = You profit when price goes DOWN
// Betting price goes up
->buy()->long()

// Betting price goes down
->sell()->short()

What's the difference between Hedge and One-Way mode?

One-Way Mode:

  • One position per symbol
  • Simpler to manage
  • Good for beginners

Hedge Mode:

  • Can have LONG and SHORT simultaneously
  • More flexible strategies
  • Required for some features (auto-add margin)
// Check current mode
$mode = Bingx::account()->getPositionMode();

// Switch to hedge mode
Bingx::account()->setPositionMode(true);

Why did my order get rejected?

Common reasons:

  1. Insufficient margin

    $balance = Bingx::account()->getBalance();
    echo "Available: {$balance['balance']['availableMargin']}\n";
  2. Invalid quantity — Check minimum order size

    $info = Bingx::market()->getContractInfo('BTC-USDT');
    echo "Min qty: {$info['minQty']}\n";
  3. Price too far from market — For limit orders

  4. Max open orders reached

  5. Position mode mismatch — Check hedge vs one-way

How do I set a stop loss?

// Method 1: With the order (recommended)
Bingx::trade()->order()
    ->futures()
    ->symbol('BTC-USDT')
    ->buy()->long()
    ->type('MARKET')
    ->margin(100)
    ->leverage(10)
    ->stopLossPercent(5)  // 5% stop loss
    ->execute();

// Method 2: Separate order
Bingx::trade()->order()
    ->futures()
    ->symbol('BTC-USDT')
    ->sell()->long()  // Close long position
    ->type('STOP_MARKET')
    ->stopPrice(48000)
    ->closePosition(true)
    ->execute();

What's the difference between STOP and STOP_MARKET?

  • STOP (or STOP_LIMIT) — Triggers a limit order at stop price
  • STOP_MARKET — Triggers a market order at stop price

Use STOP_MARKET for stop losses — guaranteed execution.

How do trailing stops work?

$order = Bingx::trade()->order()
    ->type('TRAILING_STOP_MARKET')
    ->activationPrice(52000)  // Start trailing at $52k
    ->callbackRate(2.0)       // Trail 2% behind peak
    ->execute();
  1. Price hits $52k → trailing starts
  2. Price goes to $55k → stop moves to $53.9k (2% below)
  3. Price goes to $60k → stop moves to $58.8k
  4. Price drops to $58.8k → order executes

📊 Market Data Questions

How do I get historical data?

// Klines (candlesticks)
$klines = Bingx::market()->getKlines(
    symbol: 'BTC-USDT',
    interval: '1h',    // 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w
    limit: 500         // Max 1000
);

// With time range
$klines = Bingx::market()->getKlines(
    symbol: 'BTC-USDT',
    interval: '1d',
    startTime: strtotime('-30 days') * 1000,
    endTime: time() * 1000
);

What intervals are available?

1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M

How do I get funding rate?

$funding = Bingx::market()->getFundingRateInfo('BTC-USDT');
echo "Current rate: {$funding['fundingRate']}\n";
echo "Next funding: {$funding['nextFundingTime']}\n";

Funding rates:

  • Positive = Longs pay shorts
  • Negative = Shorts pay longs
  • Paid every 8 hours

🔧 Technical Questions

Rate limits — how many requests can I make?

BingX limits vary by endpoint:

  • Market data: ~100 requests/second
  • Account/Trade: ~10 requests/second

The SDK handles rate limit errors automatically with retries.

try {
    $result = Bingx::trade()->createOrder([...]);
} catch (\Tigusigalpa\BingX\Exceptions\RateLimitException $e) {
    // Wait and retry
    sleep(1);
}

How do I handle errors properly?

use Tigusigalpa\BingX\Exceptions\{
    ApiException,
    AuthenticationException,
    RateLimitException,
    InsufficientBalanceException
};

try {
    $order = Bingx::trade()->createOrder([...]);
} catch (AuthenticationException $e) {
    // Invalid API key or signature
} catch (RateLimitException $e) {
    // Too many requests
} catch (InsufficientBalanceException $e) {
    // Not enough margin
} catch (ApiException $e) {
    // Other API errors
    echo "Code: {$e->getCode()}\n";
    echo "Message: {$e->getMessage()}\n";
}

Can I use this with Laravel Queues?

Yes! Just make sure to handle exceptions:

class PlaceOrderJob implements ShouldQueue
{
    public function handle()
    {
        Bingx::trade()->createOrder([...]);
    }
    
    public function failed(\Throwable $e)
    {
        // Log failure, notify admin, etc.
    }
}

Does this work with PHP 7.4?

The SDK requires PHP 8.1+ for:

  • Named arguments
  • Union types
  • Enums
  • Other modern features

Can I use multiple API keys?

Yes, create separate client instances:

use Tigusigalpa\BingX\BingxClient;

$mainAccount = new BingxClient(
    apiKey: 'main_key',
    apiSecret: 'main_secret'
);

$subAccount = new BingxClient(
    apiKey: 'sub_key',
    apiSecret: 'sub_secret'
);

$mainAccount->market()->getLatestPrice('BTC-USDT');
$subAccount->account()->getBalance();

🚀 TWAP Questions

When should I use TWAP?

Use TWAP when:

  • Order size > 1% of daily volume
  • You want to minimize slippage
  • You're building/exiting large positions
  • You don't need immediate execution

Don't use TWAP when:

  • Small orders (< $10k)
  • You need instant execution
  • Market is moving fast against you

Can I modify a TWAP order?

No. Cancel it and create a new one.

Bingx::twap()->cancelOrder($orderId, 'BTC-USDT');
$newTwap = Bingx::twap()->buy(...);

What happens if TWAP doesn't complete?

You keep whatever was filled. The rest expires.

$details = Bingx::twap()->getOrderDetail($orderId);
echo "Filled: {$details['executedQty']}/{$details['totalQty']}\n";

💡 Tips & Best Practices

Should I use Market or Limit orders?

Situation Use
Need to enter/exit NOW Market
Want specific price Limit
Stop loss STOP_MARKET
Take profit LIMIT or TAKE_PROFIT

What leverage should I use?

Experience Recommended
Beginner 1-3x
Intermediate 5-10x
Advanced 10-20x
Professional Case by case

Rule: If you're asking this question, use lower leverage.

How do I avoid liquidation?

  1. Use stop losses — Always
  2. Size positions properly — Risk 1-2% per trade
  3. Monitor margin ratio — Stay below 50%
  4. Don't over-leverage — Start with 5x or less
  5. Enable auto-add margin — Extra safety net
// Monitor your risk
$risk = Bingx::account()->getPositionRisk('BTC-USDT');
if ($risk['marginRatio'] > 70) {
    // Add margin or reduce position
}

🆘 Still Stuck?

  1. Search the Wiki — Most answers are here
  2. Check GitHub Issues — Someone might have asked already
  3. Open an Issue — We respond quickly
  4. Read the Code — It's well-documented

Links:

Clone this wiki locally