April 1, 2023
Avellaneda and Stoikov MM paper implementation
Overview

By Siddharth Kumar
3 min read
Overview
In 2008, Marco Avellaneda and Sasha Stoikov published a seminal academic paper on the subject of market making. The article itself involves a lot of very complicated mathematical equations and SDEs, half of which I do not have the academic ability to solve yet, but the central proposals from Avellaneda & Stoikov are to address two major concerns from a market maker's perspective: how to deal with inventory risks and how to find the optimal bid-ask spreads. The main conclusions from the paper are:
- To minimize inventory risk, prices should be skewed to favor the inventory to come back to its targeted ideal balance point.
- To maximize trade profitability, spreads should be enlarged such that the expected future value of the account is maximized.
After solving all the SDEs, the authors come up with the following formulas for the theoretical (reservation) price, and bid-ask spread:
Where,
- s = current market mid price
- q = quantity of assets in inventory of base asset (could be positive/negative for long/short positions)
- σ = market volatility
- T = closing time, when the measurement period ends (conveniently normalized to 1)
- t = current time (T is normalized = 1, so t is a time fraction)
- δa, δb = bid/ask spread, symmetrical → δa=δb
- γ = inventory risk aversion parameter
- κ = order book liquidity parameter
Theoretical(Reservation) Price:
- The value of q on the formula measures how many units the market maker inventory is from the desired target.
- γ parameter is a value that must be defined by the market maker, considering how much inventory risk he is willing to be exposed. A value closer to zero means more aggressive quoting.
- (T-t) is the time until the trading session ends. Avellaneda & Stoikov added the trading session terminal time (T). As the trading session is nearing the end, the reservation price will approach the market mid-price, reducing the risk of holding the inventory too far from the desired target.
Strategy Outline:
- Calculate the reservation price based on what is the target inventory
- Calculate the optimal bid and ask spread
- Post limit orders using the reservation price as reference:
- Bid offer price = reservation price — optimal spread / 2
- Ask offer price = reservation price + optimal spread / 2
Implementation
I will now test the performance of this strategy using numerical simulations, focusing primarily on the shape of the P&L profile and the final inventory q. We simulate a Brownian motion and try to quote around the mid price. The github repo containing all the code is here.
If you want to go through the code, then you can change some of the variables by going to the init method.
And then generate simulation results with the following code:
Results
The above code yeilds the following pnl curve:
Final note
If you made it this far, then congrats you have a higher attention span than 90% of people around you. If you found this useful then consider following my medium account.
None of what I have written in this article is Financial Advice. Yes, none of it. If you blindly follow an article written by an 19 y/o Uni kid without doing any due diligence of your own, then well what can I say more.