Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hummingbot/hummingbot/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Spot Perpetual Arbitrage captures price differences between spot markets and perpetual futures markets while earning or paying funding rates. This market-neutral strategy profits from basis spreads and funding rate inefficiencies.How It Works
- Detect Arbitrage Opportunity: Compares spot and perpetual prices
- Open Position: When spread exceeds threshold, opens opposite positions on both markets
- Hold for Funding: Maintains position to collect funding payments
- Close Position: When convergence spread is met, closes both positions
- Profit: Captures initial spread + accumulated funding rates
Unlike directional trading, this strategy is market-neutral and profits from convergence, not price direction.
When to Use
Ideal Conditions
- High funding rates (>0.1% per 8h)
- Persistent basis spread between spot/perp
- Low transaction costs
- Sufficient capital for both markets
Avoid When
- Funding rates near zero
- High exchange withdrawal fees
- Limited capital (can’t open both sides)
- Extreme volatility causing liquidation risk
Core Configuration Parameters
Market Setup
Spot exchange connectorExamples:
binance, coinbase_pro, krakenSpot trading pair in BASE-QUOTE formatExample:
BTC-USDTDerivative exchange connectorExamples:
binance_perpetual, bybit_perpetual, dydx_perpetualPerpetual contract trading pairExample:
BTC-USDT (perpetual contract)Position Sizing
Order size in base asset for both spot and perpetualExample:
0.1 opens 0.1 BTC on spot and 0.1 BTC on perpetualLeverage for perpetual market positionExample:
5 uses 5x leverage on perpetual sideRange: Varies by exchangeHigher leverage reduces capital requirement on perpetual side but increases liquidation risk.
Arbitrage Thresholds
Minimum price difference percentage to open an arbitrage position. Enter
1 for 1%.Example: 0.3 opens position when spread ≥ 0.3%Range: -100% to 100%Should exceed: transaction costs + slippage + minimum desired profitMinimum price difference to close existing position. Enter
1 for 1%.Example: -0.1 closes when spread narrows to -0.1%Range: -100% to 100%Can be negative to close positions even at a small loss, relying on accumulated funding to be profitable.
Slippage Management
Slippage buffer for spot market orders. Enter
1 for 1%.Example: 0.1 adds 0.1% buffer to spot ordersProtects against price movement during execution.Slippage buffer for perpetual market orders. Enter
1 for 1%.Example: 0.1 adds 0.1% buffer to perpetual ordersExecution Control
Seconds to wait before opening next arbitrage positionExample:
300 waits 5 minutes between position opensPrevents over-trading and allows market to stabilize.Example Configurations
Basic BTC Funding Arbitrage
- Trades 0.01 BTC per arbitrage
- Uses 3x leverage on perpetual
- Opens when spread ≥ 0.5%
- Closes when spread ≤ 0.1%
- 5-minute delay between positions
Aggressive High-Frequency
- Tighter opening threshold (0.2%)
- Negative closing threshold (closes even at small loss)
- Higher leverage (5x) for capital efficiency
- Faster cycling (60-second delay)
- Relies on funding rate income
Conservative Long-Hold
- Wide opening threshold (1.0%)
- Conservative closing (0.3%)
- Low leverage (2x) for safety
- Longer hold periods
- Higher slippage buffers for safety
Strategy Mechanics
Position Opening Logic
Position Closing Logic
Funding Rate Analysis
Understanding Funding Rates
Funding rates are periodic payments between long and short perpetual contract holders:
- Positive Funding: Perpetual > Spot → Longs pay shorts
- Negative Funding: Spot > Perpetual → Shorts pay longs
Profit Calculation
Optimal Funding Strategies
- High Positive Funding
- High Negative Funding
- Neutral Funding
Market: Perpetual trading at premium, longs pay shortsStrategy:Position: Long spot + Short perpetualIncome: Initial spread + funding payments
Risk Management
Risk Mitigation Strategies
Set Appropriate Leverage
Set Appropriate Leverage
Calculate safe leverage based on volatility:Start with 2-3x regardless of calculation.
Monitor Funding Continuously
Monitor Funding Continuously
Track funding rate changes:
Maintain Excess Margin
Maintain Excess Margin
Keep margin ratio > 50%:
Use Exchange with Low Withdrawal Fees
Use Exchange with Low Withdrawal Fees
Factor in rebalancing costs:
| Exchange | Withdrawal Fee | Impact on Min Profitability |
|---|---|---|
| Binance | 0.0005 BTC | +50k |
| Coinbase | 0.00001 BTC | +50k |
| Kraken | 0.00015 BTC | +50k |
Advanced Techniques
Multi-Position Management
The strategy opens one arbitrage position at a time. For multiple positions:
- Run multiple Hummingbot instances
- Use different
order_amountvalues - Stagger
next_arbitrage_opening_delaytimes
Dynamic Threshold Adjustment
Adjust thresholds based on funding:Cross-Exchange Optimization
- Same Exchange (Binance)
- Different Exchanges
- No withdrawal fees for rebalancing
- Unified margin (if cross-margin enabled)
- Faster execution
- Exchange risk concentration
Performance Optimization
Calculating Minimum Profitability
min_opening_arbitrage_pct: 1.2 to ensure profitability.
Optimal Position Sizing
Tips for Success
Start Small and Scale
Start Small and Scale
Begin with minimum position sizes:After 1 week profitable → increase by 50%
After 1 month profitable → scale to target size
Monitor Both Markets
Monitor Both Markets
Track metrics:
- Spot balance
- Perpetual margin ratio
- Funding rate history
- Open position P&L
Rebalance Regularly
Rebalance Regularly
Transfer profits weekly:
- Close all positions
- Withdraw excess from perpetual
- Rebalance spot/perpetual allocations
- Resume strategy
Use Historical Data
Use Historical Data
Backtest thresholds using historical spreads:
Source Code Reference
Configuration:/source/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage_config_map.py:56
Strategy Implementation: /source/hummingbot/strategy/spot_perpetual_arbitrage/spot_perpetual_arbitrage.py
Proposal Logic: /source/hummingbot/strategy/spot_perpetual_arbitrage/arb_proposal.py
Related Strategies
- AMM Arbitrage: Spot to AMM arbitrage
- Perpetual Market Making: Pure market making on perpetuals
- Cross Exchange Market Making: Market making with hedging