Avellaneda strategy: A technical deep dive

博客»Avellaneda strategy: A technical deep dive

Nicolas Baum

2021-04-22 · 6 min read

Following our initial blog post on the new avellaneda_market_making strategy, we are back with deeper, more mathematical dive into ths strategy! Today we will explain how we modified the original Avellaneda-Stoikov model for the cryptocurrency industry, along with how we simplified the calculation of key parameters (greeks).

The purpose of this article is to mathematically back assumptions and calculations that helped translate the authors' model into one more suitable for Hummingbot traders.

Original model and our proposed extensions

First, let's briefly recap 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:


  • 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 built under the following assumptions:

  1. Order amount is not defined

  2. Volatility is constant

  3. Order book statistical characterization is constant

  4. The market maker intends to maximize profit using a total inventory q during a limited T time horizon

Since these assumptions may not be suitable for crypto trader, we propose the following changes:

  1. Since Hummingbot enables traders to specify the order amount, we introduce an an additional parameter order_amount_shape_factor (\eta) that adjusts order amount given inventory position, as described in the 2018 Optimal High-Frequency Market Making paper.

  2. To account for the rapidly changing volatility that exists in crypto, we propose a volatility diff threshold which, if surpassed, will trigger recalculation of the strategy parameters vol_to_spread_multiplier.

  3. Recalculation as in point 2.

  4. Since running bot may have infinite time horizon, our solution is to have a finite closing_time (T) but with recycle of remaining time fraction t together with parameter recalculation every time t=T.

Calculation of  and 


With the original Avellaneda equations, we are faced with multiple degrees of freedom. We can pick any value for these parameters, so some constraints are needed. Since bid/ask spread to mid-price is one of the most important values for our bots, that should be a reasonable choice to build our criteria. Also, as the paper states, \gamma acts like a risk aversion parameter to inventory risk. We want a knob parameter to control that factor while meeting the spread parameters set by the user.

Calculation of 

We will work under the assumption that user has set both min_spread and max_spread parameters when configuring the strategy. For the calculation of the maximum possible risk factor (), the author works with the initial spreads optimal bid/ask to mid-price ( and), which should not be smaller than min spread nor bigger than max spread (in relationship to the mid-price).

Note: As the delta between reservation price and mid price () and optimal spreads are functions of (t-T), for decreasing absolute value of q (approaching the target inventory level), it can be safely said that spreads of optimal bid and ask to mid-price will be decreasing as time goes by. Therefore, the following calculations will be centered at the moment t=0 where spreads are the widest possible.

The image below shows the distribution of price levels and spreads when there is an excess of inventory, so the reservation price is lower than the mid price and spreads are adjusted accordingly:

all spreads and prices

q>0 (inventory needed to be decreased)


To comply with maximum and minimum spreads:

We will now calculate an expression for these spreads at t=0. First, the ask spread:

Replacing equations for r(s,t) and optimal spread...

So expression reached is:

Similarly, with the bid spread, the limitation will be the maximum spread set by the user in this case:

Which leads to the expression:

Taking both inequalities and adding them up together the following result is reached:

q<0 (inventory needed to be increased)

In the same way, for the opposite case, if q<0 the final expression reached is:

So both cases can be treated using \|q\|, and then the following inequality for  holds

As risk_factor () is non-negative, with this maximum threshold calculated, we now have a range for all possible  values. The previously mentioned knob will be a coefficient ranging from 0 to 1, which will define where within this range will  be. This coefficient will be called inventory_risk_aversion (IRA).

Final equation for :

Calculation of 

order_book_depth_factor () will selected so that the algorithm starts with the maximum possible spread at t=0. This decision appears arbitrary, but the argument behind it is to go through a wider range of spreads so as to maximize strategy profitability. So to start with the calculation, we will first determine the maximum possible spread at t=0.

The order furthest from the mid price will be the one where terms are added, so we calculate:

Now, from this maximum optimal spread at time t=0,  can be inferred as a function of this spread using the paper's equation for 

Final equation for :

Calculation of 

Recall that order_amount_shape_factor (\eta) is a modifier to order amount, borrowed from the 2018 Fushimi paper (see References).

eta usage

Basically from both orders submitted in the strategy proposal, the one going against reaching the target inventory will be decreased in size exponentially based on how far bot is from reaching target q. This is similar to the inventory skew approach in Hummingbot's pure market making strategy.

Leveraging the inventory_risk_aversion (IRA) parameter defined earlier, the amount of decay in the exponential decay function will be controlled by IRA:

What happens if 

We have seen what happens to reservation price and optimal spread when . But what happens if ?

If you read previous Avellaneda strategy post, you will know that if  (which is equivalent to ), then knob is set to no inventory risk aversion. That means that user simply sets spreads symmetrical to mid-price, but can you imagine what will be the final spread values? Lets do the math...

So we know about reservation price that  and that optimal spread . Lastly, we calculate \kappa,

This means, that if  spread around r = mid_price will be fixed

So in the case \gamma \to 0 this is the same as a regular pure market making strategy with symmetrical spread = Max Spread around mid-price. In this way, pure market making strategy becomes a special case of Avellaneda market making strategy.


High-frequency trading in a limit order book (Avellaneda and Stoikov, 2006)

Optimal High-Frequency Market Making (Fushimi, Gonzalez Rojas and Herman, 2018)


dYdX + Hummingbot Bounty Hunt
dYdX + Hummingbot Bounty Hunt
Avellaneda strategy: A technical deep dive
Avellaneda strategy: A technical deep dive
A comprehensive guide to Avellaneda & Stoikov’s market-making strategy
A comprehensive guide to Avellaneda & Stoikov’s market-making strategy

免责声明:位于https://hummingbot.io、https://docs.hummingbot.io、https://miners.hummingbot.io的网站(统称为“网站”)是属于CoinAlpha, Inc.(“公司”、“我们”和“我们的”)的受版权保护的作品。本网站的某些功能可能受附加指南、条款或规则的约束,这些指南、条款或规则将发布在与此类功能相关的网站上。所有此类附加条款、指南和规则均通过引用纳入本条款。这些使用条款(以下简称“条款”)规定了具有法律约束力的条款和条件,以规范您对本网站的使用。访问或使用本网站,即表示贵方接受这些条款(代表贵方自己或贵方所代表的实体),并且贵方声明并保证贵方有权利、权限和能力签订这些条款(代表贵方自己或贵方所代表的实体)。如果贵方未满18岁,则不得访问、使用本网站或接受这些条款。如果贵方不同意这些条款的所有规定,请勿访问和/或使用本网站。