Market Making: Inventory Management and Optimal Quoting
Module: Fintech AI | Difficulty: Advanced
Avellaneda-Stoikov Model
where = mid-price, = inventory, = risk aversion.
PnL Decomposition
Inventory Risk
import numpy as np
class MarketMaker:
def __init__(self, gamma, sigma, inventory_limit=100):
self.gamma = gamma; self.sigma = sigma
self.inv_limit = inventory_limit; self.inventory = 0
def optimal_quote(self, mid_price, time_to_close):
inventory_penalty = self.gamma * self.sigma**2 * self.inventory
spread = self.gamma * self.sigma**2 * time_to_close
bid = mid_price - spread/2 - inventory_penalty
ask = mid_price + spread/2 - inventory_penalty
return {'bid': bid, 'ask': ask}
def update_inventory(self, trade, size):
if trade == 'buy':
self.inventory += size
else:
self.inventory -= size
Research Insight: Optimal market making requires balancing profit from spread against inventory risk. The Avellaneda-Stoikov model provides the optimal quoting strategy under the assumption of Poisson arrivals and permanent impact. In practice, the model is adapted with additional risk controls.