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
Perpetual Market Making applies market making strategies to perpetual futures markets, allowing traders to use leverage while providing liquidity. This strategy extends pure market making concepts to derivatives markets with position management and profit-taking features.How It Works
- Place Leveraged Orders: Creates bid and ask orders on perpetual markets
- Monitor Positions: Tracks long and short positions separately
- Profit Taking: Automatically places opposite orders to reduce positions
- Stop Loss: Protects against adverse price movements
- Refresh Orders: Updates orders based on market conditions
When to Use
Best For
- Perpetual futures markets with funding rates
- Leveraged liquidity provision
- Traders comfortable with derivatives
- Markets with position-based incentives
Avoid When
- Unfamiliar with leverage mechanics
- Exchange has high funding rates
- Extremely volatile markets
- Insufficient collateral for liquidation risk
Core Configuration Parameters
Derivative Setup
The derivative exchange connectorExamples:
binance_perpetual, bybit_perpetual, dydx_perpetualPerpetual trading pair in BASE-QUOTE formatExample:
BTC-USDT (for BTC-USDT perpetual contract)Leverage multiplier for positionsExample:
10 for 10x leverageRange: Varies by exchange (Binance supports up to 75x for most pairs)Position management modeOptions:
One-way: Net position (long and short offset each other)Hedge: Separate long and short positions
Hedge mode allows simultaneous long and short positions, useful for complex strategies.
Spread Configuration
Distance from mid-price for bid orders. Enter
1 for 1%.Example: 0.1 places bids 0.1% below mid-priceDistance from mid-price for ask orders. Enter
1 for 1%.Example: 0.1 places asks 0.1% above mid-priceMinimum spread before automatically canceling orders. Enter
1 for 1%.Range: -100% to 100%Example: 0.05 cancels orders if spread drops below 0.05%Order Management
Order size in base asset (contracts)Example:
0.01 for 0.01 BTC worth of contractsWith leverage, actual exposure = order_amount * leverageFrequency in seconds to refresh ordersExample:
30.0 refreshes every 30 secondsMinimum price change to trigger refresh. Enter
1 for 1%.Range: -10% to 10%Multi-Level Orders
Number of orders per sideExample:
3 creates 3 buy and 3 sell ordersSpread increment between levels. Enter
1 for 1%.Required if order_levels > 1Amount increase/decrease per levelExample:
0.005 increases each level by 0.005 BTCProfit Taking
Spread from long position entry price to place profit-taking sell orders. Enter
1 for 1%.Example: 2.0 places sell order 2% above long entry priceRange: 0% to 100%Spread from short position entry price to place profit-taking buy orders. Enter
1 for 1%.Example: 2.0 places buy order 2% below short entry priceRange: 0% to 100%Stop Loss
Spread from entry price to place stop loss orders. Enter
1 for 1%.Example: 5.0 places stop loss 5% away from entryRange: 0% to 101%Stop loss triggers market orders in the opposite direction to close positions.
Seconds before refreshing unfilled stop loss ordersExample:
120 refreshes stop loss every 2 minutes if not executedAdditional slippage buffer for stop loss orders. Enter
1 for 1%.Ensures stop loss orders execute even in volatile conditions.Price Sources
Price reference for order placementOptions:
current_market: Use current derivative mid-priceexternal_market: Use another exchange’s pricecustom_api: Use custom API endpoint
Type of price to useOptions:
mid_price: Average of best bid and asklast_price: Last traded pricelast_own_trade_price: Your last trade pricebest_bid: Top bid pricebest_ask: Top ask price
External exchange/derivative for price referenceRequired when
price_source=external_marketTrading pair on external source
Advanced Features
Price above which only sell orders are placed. Use
-1 to disable.Price below which only buy orders are placed. Use
-1 to disable.Enable best bid/ask jumping (order book top positioning)
Delay in seconds after order fill before placing new orders
Example Configurations
Conservative Market Making
- Moderate 3x leverage
- Conservative spreads (0.1%)
- Profit taking at 1%
- Stop loss at 3%
- One-way position mode
Aggressive Multi-Level
- High 10x leverage
- Tight spreads (0.05%)
- 5 order levels
- Hedge mode for complex positions
- Quick profit taking (0.5%)
- Order optimization enabled
Price Source from Spot
Position Management
One-Way Mode
- Simpler position tracking
- Natural hedging of long/short
- Lower margin requirements
Hedge Mode
- Simultaneous long and short
- Independent position management
- Advanced arbitrage strategies
Leverage and Risk
Liquidation Price Calculation
Recommended Leverage by Experience
| Experience Level | Recommended Leverage | Risk Level |
|---|---|---|
| Beginner | 2-3x | Low |
| Intermediate | 3-5x | Medium |
| Advanced | 5-10x | High |
| Expert | 10-20x | Very High |
Funding Rate Considerations
Perpetual contracts charge/pay funding rates every 8 hours. Consider funding rates when market making:
- Positive Funding: Longs pay shorts (favor short positions)
- Negative Funding: Shorts pay longs (favor long positions)
Checking Funding Rates
Tips for Success
Start with Low Leverage
Start with Low Leverage
Begin with 2-3x leverage regardless of exchange limits. Increase gradually as you gain experience:
Always Use Stop Loss
Always Use Stop Loss
Set stop loss at 2-5x your normal spread to prevent catastrophic losses:
Monitor Margin Ratio
Monitor Margin Ratio
Keep margin ratio above 20% to avoid liquidation:If margin < 30%, reduce position size or add collateral.
Account for Funding Costs
Account for Funding Costs
Calculate break-even including funding:
Risk Management
Risk Mitigation Checklist
- Set
stop_loss_spreadon all strategies - Use leverage ≤ 5x for most markets
- Maintain margin ratio > 30%
- Monitor funding rates 3x daily
- Set
price_ceilingandprice_floorfor range-bound trading - Enable
order_optimizationduring high volatility - Keep 50% capital in reserve for margin calls
Performance Optimization
Order Placement Strategy
- Tight Spreads (Competitive)
- Wide Spreads (Safe)
- Balanced
Comparison with Spot Market Making
| Feature | Perpetual MM | Spot MM |
|---|---|---|
| Leverage | Yes (2-100x) | No |
| Funding Costs | Yes (every 8h) | No |
| Profit Taking | Built-in | Manual |
| Stop Loss | Built-in | External |
| Position Modes | One-way/Hedge | N/A |
| Liquidation Risk | Yes | No |
| Capital Efficiency | High | Lower |
Source Code Reference
Configuration:/source/hummingbot/strategy/perpetual_market_making/perpetual_market_making_config_map.py:106
Strategy Implementation: /source/hummingbot/strategy/perpetual_market_making/perpetual_market_making.py
Order Tracker: /source/hummingbot/strategy/perpetual_market_making/perpetual_market_making_order_tracker.py
Related Strategies
- Pure Market Making: Spot market equivalent
- Spot Perpetual Arbitrage: Arbitrage between spot and perpetual