Technical Deep Dive into the Avellaneda & Stoikov Strategy¶
In our previous blog post, we introduced the new avellaneda_market_making
strategy. This time, we delve deeper into the mathematical aspects of this strategy. We aim to explain how we adapted the original Avellaneda-Stoikov model for the cryptocurrency market and simplified the calculation of key parameters, known as greeks.
This article mathematically substantiates the assumptions and calculations that made the authors' model more suitable for Hummingbot traders.
Original Model and Our Proposed Extensions¶
Let's start by revisiting the core equations from the Avellaneda-Stoikov paper:
Original Model¶
Reservation price (market price, adjusted toward your target inventory level):
Optimal spread around reservation price:
Where:
- s [quote asset] = current mid price
- q [no unit] = quantity of stocks in inventory of base asset (could be positive/negative for long/short positions)
[1/quote asset] = inventory risk aversion parameter [quote asset] = volatility- T [no unit] = closing time (conveniently normalized to 1)
- t [no unit] = current time (T is normalized = 1, so t is a time fraction)
[quote asset]= Bid/Ask spread (they are symmetrical to reservation price → ) [1/quote asset]= Order book liquidity parameter
Proposed Extensions¶
The paper's model is predicated on assumptions that may not align well with the needs of a crypto trader. To address this, we propose several modifications:
- Hummingbot allows traders to specify the order amount, so we introduce
order_amount_shape_factor
( ), as described in the 2018 Optimal High-Frequency Market Making paper. - Given the rapid volatility changes in crypto, we suggest a volatility threshold that triggers a recalculation of strategy parameters
vol_to_spread_multiplier
. - Recalculation as mentioned in point 2.
- Considering that bots may run indefinitely, we propose a finite
closing_time
(T) with a recurring time fraction t, alongside parameter recalibration every time t=T.
Calculation of , and ¶
Introduction¶
The original Avellaneda equations offer multiple variables. To establish constraints, we focus on the bid/ask spread to mid-price as a primary value for our bots. Additionally,
Calculation of ¶
Assuming users have set min_spread
and max_spread
, we calculate the maximum possible risk factor (
Case where q>0 (inventory ratio should be decreased)¶
To comply with user-defined spreads:
From this, we derive:
Combining these inequalities:
Case where q<0 (inventory ratio should be increased)¶
For q<0:
Both cases lead to the inequality:
Setting inventory_risk_aversion
(IRA) as a coefficient between 0 and 1, we define
Calculation of ¶
We select order_book_depth_factor
(
Final equation for
Calculation of ¶
order_amount_shape_factor
(inventory_risk_aversion
(IRA), we determine:
¶
When
Thus, if
In this scenario, pure market making strategy is a special case of the Avellaneda market making strategy.
References¶
High-frequency trading in a limit order book (Avellaneda and Stoikov, 2006)
Optimal High-Frequency Market Making (Fushimi, Gonzalez Rojas and Herman, 2018)