Core Strategy Stocks, Crypto, DeFi

Market Making

Paste into Claude, ChatGPT, or any coding agent

This skill covers the theory and practice of automated market making — earning the bid-ask spread by continuously quoting buy and sell prices. It applies to both centralized exchange (CEX) market making via tools like Hummingbot and decentralized exchange (DEX) liquidity provision through concentrated liquidity positions on Uniswap v3/v4 and similar AMMs. Market making is fundamentally a mean-reversion strategy with inventory risk as the primary concern.

When to Use This Skill

  • When setting up a market making bot on a centralized exchange
  • When configuring Hummingbot for pure market making or cross-exchange strategies
  • When deploying or managing concentrated liquidity positions on Uniswap v3/v4
  • When calculating optimal bid-ask spreads for a given asset
  • When managing inventory risk from market making activity
  • When selecting fee tiers and price ranges for DEX LP positions
  • When analyzing market making profitability and performance
  • When evaluating whether an asset is suitable for market making
  • When comparing CEX market making vs DEX liquidity provision approaches

What This Skill Does

  1. Spread Calculation: Determines optimal bid-ask spread as a function of volatility, inventory, and competition
  2. Inventory Management: Designs inventory control strategies to limit directional risk
  3. Hummingbot Configuration: Configures pure market making, cross-exchange, and Avellaneda-Stoikov strategies
  4. Concentrated Liquidity: Selects optimal price ranges and fee tiers for Uniswap v3/v4 positions
  5. Risk Controls: Sets position limits, max loss thresholds, and circuit breakers
  6. Microstructure Analysis: Evaluates order book depth, queue priority, and adverse selection risk
  7. Performance Measurement: Tracks spread capture, inventory PnL, total PnL, and fill rates
  8. Regulatory Awareness: Identifies the line between legitimate market making and manipulation

How to Use

CEX Market Making

Set up a market making strategy for BTC/USDT on Binance with $10,000 capital
Configure Hummingbot for cross-exchange market making between Binance and KuCoin

DEX Liquidity Provision

What price range and fee tier should I use for an ETH/USDC LP on Uniswap v3?
Analyze my concentrated liquidity position -- am I in range? Should I rebalance?

Strategy Analysis

Is market making profitable for [asset pair] given current conditions?

Data Sources

With MCP/CLI tools connected:

  • Hummingbot CLI — Bot configuration, strategy deployment, performance monitoring
  • Binance MCP / Bybit MCP / OKX MCP — Order book data, trade history, fee structure
  • Uniswap MCP (yurenju) — Pool data, position management, fee accrual
  • Jupiter Talk MCP — Solana DEX liquidity data, routing info
  • DexScreener — DEX pair analytics, volume, liquidity depth
  • DeFiLlama — TVL, pool APY comparison, protocol analytics
  • CoinGecko MCP — Price feeds, volume data, volatility metrics

Without tool access: Ask the user to provide:

  1. Asset pair and exchange(s)
  2. Available capital for market making
  3. Current bid-ask spread and order book depth (top 5-10 levels)
  4. Asset’s recent volatility (hourly and daily)
  5. Exchange fee structure (maker/taker fees)
  6. Current inventory position (if already active)
  7. For DEX: current pool TVL, fee tier, and tick spacing

Methodology

Step 1: Assess Market Making Suitability

Not all assets are suitable for market making. Evaluate first:

SUITABILITY CHECKLIST

Volume Requirements:
  Minimum 24h volume: $500K (CEX), $100K (DEX)
  Why: Low volume = wide spreads but very few fills = unprofitable

Spread Requirements:
  Current spread should be > 2x your exchange fees
  Example: If maker fee = 0.02%, spread must be > 0.04% to break even
  Ideal: Spread > 5x your exchange fees

Volatility Assessment:
  Low volatility (<1% daily):   Easy to market make, thin margins
  Medium volatility (1-5% daily): Sweet spot -- spread income covers inventory risk
  High volatility (>5% daily):  Dangerous -- inventory risk dominates spread income
  Extreme (>10% daily):         DO NOT market make (unless very wide spreads)

Competition:
  Tight spreads with deep books → Professional MMs present, margins thin
  Wide spreads with thin books → Opportunity but check WHY (low demand? high risk?)

SUITABILITY SCORE (must score 3+ to proceed):
  [1 point] Volume > $500K/day
  [1 point] Spread > 5x fees
  [1 point] Volatility 1-5% daily
  [1 point] No major upcoming events (earnings, token unlock, hard fork)
  [1 point] You have edge (speed, capital, cross-exchange info)

Step 2: Spread Calculation

The optimal spread depends on volatility, inventory, and competition:

Basic Spread Formula

Minimum Spread = 2 × (exchange_fee + risk_premium)

Risk Premium Components:
  Volatility component = σ × √(holding_period)
  Inventory component  = γ × inventory_skew × σ²
  Adverse selection    = estimated % of informed flow × expected adverse move

Practical Spread Calculation:
  σ_hourly = asset's hourly standard deviation of returns
  Base spread = 2 × σ_hourly (covers 1 std dev move in each direction)
  Adjusted spread = Base spread + (2 × exchange_fees) + inventory_adjustment

Example:
  BTC σ_hourly = 0.15%
  Exchange maker fee = 0.02%
  Base spread = 2 × 0.15% = 0.30%
  Minimum spread = 0.30% + 0.04% = 0.34%
  Practical spread (with buffer): 0.40% - 0.50%

Avellaneda-Stoikov Model (Advanced)

The Avellaneda-Stoikov framework is the academic gold standard:

Reservation price:
  r = s - q × γ × σ² × (T - t)

  Where:
    s = mid price
    q = current inventory (positive = long, negative = short)
    γ = risk aversion parameter (higher = more conservative)
    σ = asset volatility
    T - t = time remaining in trading session

Optimal spread:
  δ = γ × σ² × (T - t) + (2/γ) × ln(1 + γ/k)

  Where:
    k = order arrival intensity parameter

Key insight: The reservation price SHIFTS away from mid when inventory builds.
  Positive inventory → bid lower than mid (discourage more buying)
  Negative inventory → ask lower than mid (encourage buying to flatten)

Hummingbot implementation:
  Strategy: avellaneda_market_making
  Parameters to configure:
    - risk_factor (γ): Start with 0.5, increase if inventory swings too much
    - order_amount: Fixed size per level
    - min_spread: Floor spread (never go below exchange fees + buffer)
    - max_spread: Ceiling spread (avoid being too wide to get fills)

Step 3: Inventory Management

Inventory risk is the primary risk in market making. Your inventory will naturally drift as one side fills more than the other.

INVENTORY MANAGEMENT STRATEGIES

Strategy 1: Quote Skewing (Preferred)
  When long (positive inventory):
    - Move bid DOWN (less aggressive buying)
    - Move ask DOWN (more aggressive selling)
    - Skew amount = inventory_ratio × base_spread × skew_factor
  When short (negative inventory):
    - Move bid UP (more aggressive buying)
    - Move ask UP (less aggressive selling)

  Example:
    Base spread: 0.40% (0.20% on each side)
    Inventory: +$5,000 (target = $0)
    Max inventory: $20,000
    Inventory ratio: 5/20 = 25%
    Skew: 25% × 0.20% × 1.5 = 0.075%
    New bid: mid - 0.275% (wider)
    New ask: mid + 0.125% (tighter)

Strategy 2: Hard Limits
  - Set max inventory position (e.g., $20,000 long or short)
  - When limit hit: stop quoting that side entirely
  - Resume when inventory returns to 50% of limit

Strategy 3: Hedging
  - When inventory exceeds threshold, hedge with a correlated asset
  - Example: Accumulate too much ETH → short ETH perp to hedge
  - Cost: funding rate + basis spread, but eliminates directional risk

Strategy 4: Mean-Reversion Bands
  - Define inventory target (usually 0 or slight long bias)
  - Define bands: ±10%, ±25%, ±50% of max
  - Each band triggers progressively aggressive skewing

INVENTORY LIMITS BY ASSET TYPE:
  Large-cap (BTC, ETH): Max $50K or 5% of capital per side
  Mid-cap (top 50):     Max $20K or 3% of capital per side
  Small-cap:            Max $5K or 1% of capital per side
  Stablecoin pairs:     Max 20% of capital per side (lower risk)

Step 4: Hummingbot Configuration

Hummingbot is the primary open-source market making tool. Configure strategies:

Pure Market Making

# hummingbot config: pure_market_making
exchange: binance
market: BTC-USDT
bid_spread: 0.2          # 0.2% below mid
ask_spread: 0.2          # 0.2% above mid
order_amount: 0.001      # BTC per order
order_levels: 3          # 3 orders on each side
order_level_spread: 0.1  # 0.1% between levels
order_refresh_time: 15   # seconds between refresh
filled_order_delay: 30   # wait 30s after fill
inventory_skew_enabled: true
inventory_target_base_pct: 50  # target 50/50 split
inventory_range_multiplier: 1.5

Cross-Exchange Market Making

# hummingbot config: cross_exchange_market_making
maker_market: kucoin      # Place orders here (wider spreads)
taker_market: binance      # Hedge fills here (deeper liquidity)
market: BTC-USDT
min_profitability: 0.3     # Minimum 0.3% profit per round trip
order_amount: 0.005        # BTC per order
top_depth_tolerance: 0     # Match top of book
cancel_order_threshold: 0.05  # Cancel if spread < 0.05%

# The strategy: Quote on the wider-spread exchange,
# immediately hedge fills on the tighter-spread exchange.
# Profit = spread difference - 2x taker fees

Avellaneda Strategy

# hummingbot config: avellaneda_market_making
exchange: binance
market: ETH-USDT
order_amount: 0.1
risk_factor: 0.5           # gamma (risk aversion)
order_refresh_time: 10
min_spread: 0.1            # minimum 0.1% spread
max_spread: 2.0            # maximum 2.0% spread
volatility_buffer_size: 60 # 60 candle volatility window
trading_intensity_buffer_size: 60

Step 5: DEX Concentrated Liquidity (Uniswap v3/v4)

Concentrated liquidity requires selecting a price range. Capital is only active within this range.

Fee Tier Selection

UNISWAP v3 FEE TIERS

Fee Tier | Tick Spacing | Best For
---------|-------------|----------
0.01%    | 1 tick      | Stablecoin pairs (USDC/USDT, DAI/USDC)
0.05%    | 10 ticks    | Correlated pairs (stETH/ETH, cbETH/ETH)
0.30%    | 60 ticks    | Standard pairs (ETH/USDC, BTC/USDC)
1.00%    | 200 ticks   | Exotic / volatile pairs (PEPE/ETH, new tokens)

Selection logic:
  Pair correlation > 0.99 → 0.01% or 0.05%
  Pair correlation > 0.90 → 0.05% or 0.30%
  Standard major pairs    → 0.30%
  Volatile / low liquidity → 1.00%

Range Selection Strategy

RANGE WIDTH FRAMEWORK

Narrow range (±5% from current price):
  Pros: Maximum capital efficiency, highest fee revenue when in range
  Cons: Goes out of range frequently, requires active management
  Best for: Stable pairs, sideways markets, active managers
  Expected time in range: 2-7 days for volatile assets

Medium range (±15-25% from current price):
  Pros: Balanced fee revenue and rebalancing frequency
  Cons: Lower capital efficiency than narrow
  Best for: Most standard pairs, semi-active management
  Expected time in range: 2-8 weeks for major pairs

Wide range (±50%+ from current price):
  Pros: Rarely goes out of range, low maintenance
  Cons: Low capital efficiency (approaching v2 performance)
  Best for: Set-and-forget, high-volatility pairs
  Expected time in range: Months

RANGE CALCULATION USING VOLATILITY:
  σ_daily = daily standard deviation of price returns
  Range_days = target days in range

  Lower bound = current_price × (1 - z × σ_daily × √Range_days)
  Upper bound = current_price × (1 + z × σ_daily × √Range_days)

  Where z = 1.96 for 95% confidence, 1.64 for 90%

  Example (ETH/USDC):
    Current price: $3,500
    σ_daily: 3.5%
    Target: 14 days in range (90% confidence)
    Lower: $3,500 × (1 - 1.64 × 0.035 × √14) = $3,500 × 0.785 = $2,748
    Upper: $3,500 × (1 + 1.64 × 0.035 × √14) = $3,500 × 1.215 = $4,253
    Range: $2,748 - $4,253 (±21.5%)

Rebalancing Strategy

REBALANCE TRIGGERS (check at least daily):

1. Out of range → Mandatory rebalance
   - Withdraw liquidity
   - Swap to 50/50 ratio at new price
   - Redeploy with new range centered on current price
   - Cost: swap fees + gas (~$5-50 depending on network)

2. Price at range edge (within 10% of boundary) → Prepare to rebalance
   - Have a new range calculated and ready
   - Consider asymmetric range shifted in trend direction

3. Gas price spike → Delay rebalance if possible
   - Wait for gas < 20 gwei on Ethereum mainnet
   - Consider L2 deployment (Arbitrum, Base) for cheaper rebalancing

4. Impermanent Loss threshold → Force rebalance
   - If IL > 50% of earned fees → range was too narrow
   - Widen range on next deployment

IMPERMANENT LOSS CALCULATION:
  IL = 2 × √(price_ratio) / (1 + price_ratio) - 1

  Where price_ratio = current_price / entry_price

  Price change | IL (full range) | IL (±20% range, approx)
  10%          | 0.11%          | 0.6%
  25%          | 0.6%           | 3.2%
  50%          | 2.0%           | 10.5%
  100%         | 5.7%           | 29.3%

  Concentrated liquidity AMPLIFIES impermanent loss proportionally
  to capital efficiency gain. A 10x capital efficient position has ~10x IL.

Step 6: Market Microstructure Awareness

Understanding order book dynamics improves execution:

ORDER BOOK ANALYSIS

Spread Components:
  Quoted spread = Best Ask - Best Bid
  Effective spread = 2 × |Execution Price - Midpoint|
  Realized spread = Effective spread - Price Impact (after N seconds)

Queue Priority:
  Price-time priority: First order at a price level fills first
  Implication: Posting early at a level matters in competitive markets
  Hummingbot: Use order_refresh_time to balance freshness vs. queue position

Adverse Selection:
  Informed traders (insiders, algos with superior information) take your quotes
  Signs of adverse selection:
    - Fills consistently followed by price moving against you
    - Large fills at your best price followed by price continuation
    - Fill rate spike before major price moves

  Mitigation:
    - Wider spreads during high adverse selection periods
    - Reduce size at best bid/offer
    - Time-based quoting: withdraw before news events
    - Asymmetric spreads: wider on the side more likely to get adversely picked

Toxicity Score:
  Track: profit_per_fill over time
  If average profit_per_fill < 0 for 100+ fills → your flow is toxic
  Action: widen spreads by 50% or switch to less adversely-selected pairs

Step 7: Performance Measurement

Track these metrics to evaluate market making profitability:

CORE METRICS (measure daily and weekly)

1. Spread Capture
   = Average half-spread at fill time
   = (sum of |fill_price - mid_at_fill|) / number_of_fills
   Target: > your exchange fee + risk premium

2. Inventory PnL
   = Change in inventory value due to price movement
   = Σ(inventory × price_change) over period
   This is your RISK — can be positive or negative

3. Total PnL
   = Spread PnL + Inventory PnL - Fees - Gas costs
   Must be positive over meaningful period (100+ round trips)

4. Fill Rate
   = Orders filled / Orders placed
   Target: 20-40% (too high = spreads too tight, too low = too wide)

5. Inventory Turnover
   = Total volume / Average inventory
   Higher = better (means you're cycling inventory, not accumulating)

6. Sharpe Ratio of Daily PnL
   = mean(daily_PnL) / std(daily_PnL) × √252
   Target: > 2.0 for viable strategy

7. Maximum Inventory Drawdown
   = Worst inventory PnL in a single day
   Must be < 5% of capital to be sustainable

PROFITABILITY FORMULA:
  Expected daily PnL =
    (spread_capture × daily_fills × 2)
    - (daily_fills × 2 × exchange_fee × avg_fill_size)
    - (expected_inventory_cost)
    - (gas_costs_if_DEX)

  Break-even analysis:
    Required fills/day = Fixed costs / (spread_capture - per_trade_costs)

Step 8: Regulatory Awareness

LEGITIMATE MARKET MAKING vs. MANIPULATION

Legitimate:
  ✓ Providing genuine two-sided quotes
  ✓ Risk management through inventory skewing
  ✓ Earning the bid-ask spread as compensation for risk
  ✓ Improving market quality (tighter spreads, deeper books)

Potentially Problematic:
  ✗ Spoofing: Placing orders you intend to cancel (illegal in most jurisdictions)
  ✗ Layering: Multiple orders at different levels to create false impression
  ✗ Wash trading: Trading with yourself to inflate volume
  ✗ Quote stuffing: Excessive order submission to slow other participants

Rules:
  - Every order placed must represent genuine willingness to trade
  - Order refresh rate should be reasonable (>5 seconds on most exchanges)
  - Never coordinate quotes with other market makers
  - CEX terms of service define additional restrictions per exchange
  - DeFi LP is generally unregulated but smart contract risk replaces regulatory risk

Anti-Patterns

DO NOT do these — they are common market making mistakes:

  1. Market making in a trending market without hedging: If an asset is trending strongly in one direction, you will accumulate inventory on the wrong side. Either hedge or pause during strong trends.

  2. Ignoring adverse selection: If you are consistently losing on fills, you are being picked off by informed traders. Widen spreads or exit the market.

  3. Too-tight ranges on concentrated liquidity: Extremely narrow ranges generate impressive APY numbers but lose to impermanent loss on any meaningful price move. Always calculate IL at range boundaries before deploying.

  4. No inventory limits: Market making without max inventory bounds is equivalent to taking unlimited directional exposure. Set hard limits and enforce them.

  5. Chasing volume in illiquid markets: Thin markets may show attractive spreads but fill rarely. Your capital is tied up earning nothing while exposed to gap risk.

  6. Ignoring gas costs on L1: Frequent rebalancing of Uniswap v3 positions on Ethereum mainnet can consume more in gas than earned in fees. Use L2s for small positions.

  7. Using market making on news-driven assets: Earnings announcements, token unlocks, and protocol upgrades create massive adverse selection. Withdraw liquidity before known events.

  8. Comparing DEX LP APY to lending rates: LP APY includes principal risk (impermanent loss). A 50% APY with 40% IL is worse than a 5% lending rate.

Validation Checkpoints

Input Validation

  • Asset pair identified with exchange(s)
  • Current spread, volume, and volatility data available
  • Capital allocated and exchange fees confirmed
  • Exchange API access configured (for CEX) or wallet connected (for DEX)
  • Historical volatility calculated (hourly and daily)
  • Order book depth assessed (at least top 10 levels)

Output Validation

  • Spread calculated with volatility, fee, and risk components documented
  • Inventory limits defined with max position and skewing parameters
  • Strategy configuration complete (Hummingbot config or LP range + fee tier)
  • Risk controls set: max loss, max inventory, circuit breakers
  • Performance benchmarks defined: minimum fill rate, target Sharpe, max drawdown
  • For DEX LP: impermanent loss calculated at range boundaries
  • Rebalancing triggers and frequency defined
  • Risk validation gate from Risk Management passed

Example

User: “Set up a concentrated liquidity position for ETH/USDC on Uniswap v3 with $20,000”

Analysis:

## Market Making Plan: ETH/USDC Concentrated LP

### Market Assessment
- Current ETH price: $3,500
- 14-day realized volatility (daily): 3.2%
- 24h pool volume (0.30% tier): $180M
- Current pool TVL: $350M
- Your capital: $20,000 (0.006% of pool -- negligible impact)

### Suitability: PASS (4/5)
- [x] Volume > $100K/day ($180M)
- [x] Spread viable (0.30% fee tier > costs)
- [x] Volatility in range (3.2% daily -- medium)
- [x] No major upcoming events (check Ethereum upgrade calendar)
- [ ] Edge: No special edge (retail LP, accept average returns)

### Fee Tier Selection: 0.30%
- ETH/USDC is a standard major pair
- 0.30% tier has highest TVL and volume
- 0.05% tier has growing volume but lower fee revenue per unit

### Range Calculation
- Target: 14 days in range at 90% confidence
- σ_daily = 3.2%
- Lower: $3,500 × (1 - 1.64 × 0.032 × √14) = $2,812
- Upper: $3,500 × (1 + 1.64 × 0.032 × √14) = $4,188
- Rounded to tick spacing: $2,800 - $4,200 (±20%)

### Capital Deployment
- Deposit: $10,000 USDC + $10,000 in ETH (2.857 ETH)
- Capital efficiency vs full range: ~5x
- Expected fee APY: 15-25% (based on recent pool performance)
- Expected IL at boundaries: ~10.5% (if price hits $2,800 or $4,200)

### Impermanent Loss Scenarios
| ETH Price | Price Change | IL        | Fees (14d est.) | Net     |
|-----------|-------------|-----------|-----------------|---------|
| $3,500    | 0%          | 0%        | $115            | +$115   |
| $3,150    | -10%        | -0.6%     | $100            | -$20    |
| $2,800    | -20%        | -2.8%     | $85             | -$475   |
| $4,200    | +20%        | -2.8%     | $85             | -$475   |
| $2,450    | -30%        | OUT OF RANGE (must rebalance)        |

### Rebalancing Plan
- Check daily: Is price within 10% of range boundary?
- Gas budget: $50/rebalance on mainnet ($5 on Arbitrum)
- If out of range > 24 hours: mandatory rebalance
- Consider: deploy on Arbitrum for cheaper rebalancing ($3-5 per tx)

### Risk Controls
- Max capital in single LP: $20,000 (fixed)
- If IL > earned fees for 7 consecutive days: withdraw and reassess
- Withdraw before known high-volatility events (FOMC, ETH upgrades)
- Total LP exposure < 25% of portfolio

### Risk Validation Gate
--> Pass to risk-management for portfolio-level checks
--> Confirm LP exposure fits within overall portfolio allocation