Market Making Strategies
Bid-ask spread management, inventory risk, Avellaneda-Stoikov model, adverse selection, toxic flow detection, and market making on CEX vs DEX.
From Thrive on YouTube
Watch the matching Thrive video
The True Cost of Trading: Fees, Spread, Slippage and Funding
Part of Funding Rates, Liquidations and Open Interest. Education only. Not financial advice.
How Market Makers Operate in Crypto
Market makers provide liquidity by continuously quoting bid and ask prices on the order book. They profit from the bid-ask spread: buying at $64,990 and selling at $65,010 captures $20 per BTC. Sounds simple. In practice, market making is a sophisticated operation that balances spread income against inventory risk, adverse selection, and the constant threat of being run over by informed flow. On a typical day, a crypto market maker might quote $500M+ in notional value across 50+ pairs, earning 1-3 bps net on executed volume while managing inventory exposure that can swing millions of dollars per hour.
Bid-Ask Spread Management
The spread you quote determines both your profit potential and your fill probability. A wider spread means more profit per fill but fewer fills. A tighter spread means more fills but slimmer margins. The optimal spread depends on volatility, current inventory, and your assessment of informed vs. uninformed flow. In high-volatility conditions (BTC moving 2%+ per hour), widen spreads to compensate for the risk that the market moves against your resting orders before you can cancel. In calm markets, tighten spreads to maximize fill rate.
The half-spread should exceed your per-trade cost (exchange fee + expected adverse movement). If your maker fee is 2 bps, you need at minimum a 4 bps spread (2 bps each side) to cover fees alone. Add 2-5 bps for inventory risk and you arrive at a minimum viable spread of 6-9 bps. During a BTC sell-off, you might widen to 15-20 bps. Professional market makers adjust quotes 100-1000x per second in response to order flow signals, inventory changes, and external price feeds.
Inventory Risk
The fundamental risk of market making: you accumulate a directional position. If the market trends, one side of your quotes fills repeatedly while the other does not. You buy continuously as the price falls, building a long position in a declining market. Or sell continuously as the price rises, accumulating a short. This inventory creates directional exposure that can overwhelm spread income. A market maker who earned $5,000 in spread income but holds a 10 BTC long position during a 3% drop has a $19,500 unrealized loss.
Inventory management techniques: skew your quotes so that when inventory is long, your ask is tighter (more aggressive) and your bid is wider (less aggressive), encouraging sells that reduce inventory. Set hard inventory limits beyond which you stop quoting on the accumulating side. Use perps to hedge excess inventory in real-time. The Avellaneda-Stoikov model formalizes this approach.
The Avellaneda-Stoikov Framework
Avellaneda-Stoikov (2008) is the standard academic model for optimal market making. The core insight: the reservation price (your fair value) shifts based on inventory. When long, your reservation price is below mid. You value the asset less because you already hold too much. When short, your reservation price is above mid. The optimal spread around the reservation price depends on volatility and your risk aversion parameter γ.
The reservation price: r = s - q·γ·σ²·(T-t), where s is mid price, q is inventory, γ is risk aversion, σ is volatility, and (T-t) is time remaining. The optimal spread: δ = γ·σ²·(T-t) + (2/γ)·ln(1 + γ/k), where k is the order arrival rate parameter. In practice, you tune γ and k empirically. Higher γ means wider spreads and faster inventory mean-reversion. Lower γ means tighter spreads but more inventory risk.
1import numpy as np2from dataclasses import dataclass34@dataclass5class ASParams:6 gamma: float = 0.1 # risk aversion7 sigma: float = 0.002 # per-second volatility (~3.5% daily)8 k: float = 1.5 # order arrival rate9 T: float = 1.0 # trading session length (normalized)10 dt: float = 0.001 # time step1112class AvellanedaStoikov:13 def __init__(self, params: ASParams):14 self.p = params15 self.inventory = 0.016 17 def reservation_price(self, mid: float, time_remaining: float) -> float:18 """Inventory-adjusted fair value."""19 return mid - self.inventory * self.p.gamma * (self.p.sigma ** 2) * time_remaining20 21 def optimal_spread(self, time_remaining: float) -> float:22 """Optimal spread around reservation price."""23 vol_component = self.p.gamma * (self.p.sigma ** 2) * time_remaining24 arrival_component = (2 / self.p.gamma) * np.log(1 + self.p.gamma / self.p.k)25 return vol_component + arrival_component26 27 def quotes(self, mid: float, time_remaining: float) -> tuple:28 """Return (bid, ask) quotes."""29 r = self.reservation_price(mid, time_remaining)30 spread = self.optimal_spread(time_remaining)31 bid = r - spread / 232 ask = r + spread / 233 return round(bid, 2), round(ask, 2)34 35 def on_fill(self, side: str, price: float, qty: float = 1.0):36 """Update inventory on fill."""37 if side == 'buy':38 self.inventory += qty39 else:40 self.inventory -= qty4142# Usage43params = ASParams(gamma=0.1, sigma=0.002, k=1.5)44mm = AvellanedaStoikov(params)4546mid_price = 65000.047time_left = 0.8 # 80% of session remaining4849bid, ask = mm.quotes(mid_price, time_left)50print(f"Mid: {mid_price:,.2f} | Bid: {bid:,.2f} | Ask: {ask:,.2f}")51print(f"Spread: {(ask - bid):,.2f} ({(ask - bid) / mid_price * 10000:.1f} bps)")5253# After accumulating inventory54mm.inventory = 3.0 # long 3 BTC55bid, ask = mm.quotes(mid_price, time_left)56print(f"\nWith 3 BTC long inventory:")57print(f"Bid: {bid:,.2f} | Ask: {ask:,.2f}")58print(f"Reservation price shift: {mm.reservation_price(mid_price, time_left) - mid_price:,.2f}")Adverse Selection and Toxic Flow
Adverse selection is the market maker's worst enemy. It occurs when informed traders consistently trade against your quotes. They know something you do not, and they profit at your expense. In crypto, toxic flow sources include: whale wallets moving before large market orders, insider trading around token listings or delistings, MEV bots front-running large swaps, and algorithmic momentum traders who are faster than your cancellation speed.
Detect toxic flow by measuring your realized spread versus quoted spread. If you quote a 10 bps spread but your average realized spread (accounting for subsequent price movement after fills) is -5 bps, you are losing to adverse selection. Track fill-to-midpoint reversion: if the mid-price moves against your fill 60%+ of the time within 1 second, the flow is predominantly informed. Response: widen spreads for detected toxic flow sources, reduce quote size, or stop quoting entirely during suspicious activity.
Market Making on CEX vs DEX
| CEX order book | Traditional limit order book. Cancel-and-replace in milliseconds. Maker rebates common. Risks: exchange insolvency, API rate limits, position limits. |
| DEX AMM | Provide liquidity to AMM pools. No active quoting: the bonding curve determines your spread. Risks: impermanent loss, MEV attacks, smart contract exploits. |
| DEX CLOB | On-chain order books (dYdX, Hyperliquid). Latency in seconds, not milliseconds. Gas costs per order placement/cancellation. Different optimal strategies than CEX. |
| Fee structure | CEX: maker rebates up to -0.02%. DEX AMM: 0.05-0.30% of LP fees but IL exposure. DEX CLOB: gas per order, maker rebates via token incentives. |
| Capital requirements | CEX: $50K-500K for competitive MM on mid-cap pairs. DEX AMM: $5K+ (smaller pools). DEX CLOB: $20K+ (lower competition but higher gas cost overhead). |
AMM Liquidity Provision as Market Making
Providing liquidity on an AMM like Uniswap v3 is a form of passive market making. You deposit assets into a liquidity pool and earn trading fees. On Uniswap v3 with concentrated liquidity, you choose a price range: narrower ranges earn more fees per dollar but face higher impermanent loss risk. A position concentrated within ±2% of the current price earns roughly 10x the fees of a full-range position but gets fully converted to the losing asset if price moves 2%+.
The key insight: concentrated LP positions are equivalent to selling options. A narrow-range LP position is economically similar to selling a short-term straddle. You collect premium (fees) and lose money on large moves (impermanent loss). Evaluate LP positions using options Greeks: the expected fee income should exceed the expected impermanent loss plus opportunity cost.
Grid Trading Strategies
Grid trading places buy and sell limit orders at regular intervals above and below the current price. As price oscillates, orders fill on both sides, capturing the spread. It is a simplified form of market making accessible to retail traders. A BTC grid from $60,000 to $70,000 with $200 intervals places 50 orders. As price bounces within the range, each buy-sell pair captures $200. The risk: a sustained breakout in either direction leaves you holding a losing position with no offsetting fills. Grid works in range-bound markets and fails catastrophically in trending markets. Combine with a volatility filter, only run grids when realized volatility is below the 30th percentile.
Hummingbot for Retail Market Making
Hummingbot is an open-source market making bot that supports 40+ exchanges. It provides pre-built strategies (pure market making, cross-exchange MM, AMM arb) with configurable parameters. For retail traders wanting to explore MM, Hummingbot removes the infrastructure burden. You configure strategy parameters and it handles order management.
1# hummingbot pure_market_making configuration2strategy: pure_market_making3exchange: binance4market: BTC-USDT56# Spread and sizing7bid_spread: 0.08% # 8 bps below mid8ask_spread: 0.08% # 8 bps above mid9order_amount: 0.01 # 0.01 BTC per order10order_levels: 3 # 3 levels on each side11order_level_spread: 0.02% # 2 bps between levels1213# Inventory management14inventory_skew_enabled: true15inventory_target_base_pct: 50% # target 50/50 BTC/USDT16inventory_range_multiplier: 1.51718# Risk controls19filled_order_delay: 30 # seconds between refills20hanging_orders_enabled: true21hanging_orders_cancel_pct: 5%2223# Kill switch24kill_switch_enabled: true25kill_switch_rate: -3% # stop if P&L drops 3%1import time2from decimal import Decimal34class SimpleMarketMaker:5 def __init__(self, exchange, symbol, spread_bps=8, size=0.01, max_inventory=0.1):6 self.exchange = exchange7 self.symbol = symbol8 self.spread = Decimal(str(spread_bps)) / Decimal('10000')9 self.size = size10 self.max_inventory = max_inventory11 self.inventory = Decimal('0')12 self.active_orders = {'bid': None, 'ask': None}13 self.pnl = Decimal('0')14 15 def get_mid_price(self) -> Decimal:16 book = self.exchange.fetch_order_book(self.symbol, limit=5)17 best_bid = Decimal(str(book['bids'][0][0]))18 best_ask = Decimal(str(book['asks'][0][0]))19 return (best_bid + best_ask) / 220 21 def skew_spread(self) -> tuple:22 """Skew quotes based on inventory."""23 base_spread = self.spread24 inv_ratio = self.inventory / Decimal(str(self.max_inventory))25 bid_spread = base_spread * (1 + inv_ratio) # widen bid when long26 ask_spread = base_spread * (1 - inv_ratio) # tighten ask when long27 ask_spread = max(ask_spread, Decimal('0.0002')) # minimum 2 bps28 return bid_spread, ask_spread29 30 def update_quotes(self):31 self.cancel_all()32 mid = self.get_mid_price()33 bid_spread, ask_spread = self.skew_spread()34 35 bid_price = float(mid * (1 - bid_spread))36 ask_price = float(mid * (1 + ask_spread))37 38 if self.inventory < Decimal(str(self.max_inventory)):39 self.active_orders['bid'] = self.exchange.create_limit_buy_order(40 self.symbol, self.size, bid_price41 )42 if self.inventory > -Decimal(str(self.max_inventory)):43 self.active_orders['ask'] = self.exchange.create_limit_sell_order(44 self.symbol, self.size, ask_price45 )46 47 def cancel_all(self):48 for side, order in self.active_orders.items():49 if order:50 try:51 self.exchange.cancel_order(order['id'], self.symbol)52 except Exception:53 pass54 self.active_orders = {'bid': None, 'ask': None}Market making is not passive income
1.In the Avellaneda-Stoikov model, what happens to the reservation price when the market maker accumulates a long inventory?
2.How do you detect toxic/informed flow as a market maker?
3.Why is concentrated Uniswap v3 liquidity provision economically equivalent to selling options?
Put this lesson to work
Free on Thrive, no account needed.