Optimal market making with inventory risk: a reservation price that leans against your position and a spread set by risk aversion and order arrival.
The Avellaneda–Stoikov model answers a precise question: where should a risk-averse market maker place the bid and the ask? The answer has two parts. First, the centre of the quotes is not the mid price but a reservation price that moves away from it in proportion to the inventory: r = s − qγσ²(T − t), where q is the position, γ the risk aversion, σ the volatility and T − t the time left. Second, the total spread is γσ²(T − t) + (2/γ)·ln(1 + γ/k), where k says how fast order arrivals fall off with distance. This lab turns both formulas into something you can see move.
It is the price at which the market maker is indifferent between holding the current inventory and not holding it. With a long position the reservation price lies below the mid, because the maker would accept a little less to get rid of risk. Quoting around it instead of around the mid skews both quotes: with a long inventory the ask becomes more attractive and the bid less so, and the position tends to shrink.
It has two terms. The term γσ²(T − t) is compensation for the risk of holding inventory until the end of the horizon. The term (2/γ)·ln(1 + γ/k) comes from the order arrival: when arrivals fall off quickly with distance (large k), quoting wide loses too many trades, so the spread is tighter. A very risk-averse maker quotes wider to trade less often.
Start with zero inventory and see the quotes sit symmetrically around the mid. Then push the inventory positive and watch both quotes slide down. Raise γ and the skew grows; shorten the time left and the skew fades because there is less time for the price to move. Finally draw your own policy and compare its P&L and inventory path with the model's on the same seed.
It reduces inventory swings, but it is not free. A very large γ pushes the quotes wide and skews them hard, so the maker trades less and gives away edge on almost every fill it does get. The common misconception is that zero inventory is the goal; the model actually trades a little inventory risk for spread income, and the best γ depends on how you score the result.