AS是经典的做市模型,最主要就是为了控制库存风险。一般来说在震荡行情中,很适合做市,特别是波动率不高情况下,我们通过AS的经典论文得到2个最关键公式,下面来解读一下这个公式的含义,如何在hummingbot 策略中如何设置这些参数。
本文大部分思路来自英文版:
A comprehensive guide to Avellaneda & Stoikov’s market-making strategy
还有AS的技术细节:Avellaneda strategy: A technical deep dive

直接开整:
A brief explanation about the model proposal
In their introduction, Avellaneda & Stoikov talk about a market maker’s two main concerns:
Dealing with inventory risk
Finding the optimal bid and ask spreads.
After going through some mathematical modeling, they arrive at two formulas that help market makers solve these problems.
讲人话就是:AS策略最主要解决2个核心问题,
1、库存风险 (也就是单边的行情,你持有很多仓位,下场比较惨兮兮)
2、找到最优的买入价格、卖出价格。
通过一系列的数学推导和各种骚操作,最终得到如来真经。

Reservation price:(预定价格)

Where,
s = current market mid price (中间价,也就是【最佳卖价+最佳买价】/2)
q = quantity of assets in inventory of base asset (也就是买入多少价值的股票数量)
σ = market volatility (市场波动率,可以用std标准差来表示)
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)
t是当前时间,T是结束时间,如果是操盘连续合约,那么T可以设置为无穷大。

δa, δb = bid/ask spread, symmetrical → δa=δb 也就是一段时间内,这个midprice 上蹿下跳的幅度计算,其实做市也就是一种网格,或者说类似布林带,我们经过计算在底部放买单,在高点放一个卖单,如果上下都成交了,那么仓位不变,你把利差赚了。相当于高卖低卖(当然要考虑去掉手续费)。
γ = inventory risk aversion parameter 这个翻译过来就是 规避库存风险的参数,当他取值很大的时候,我们按照公式一计算的预定价格就和中间价差距就远。
κ = order book liquidity parameter 这个是一个评估订单本,订单密度参数。也就是K值越大,参与买卖的人比较多,出价也比较均衡,订单量也比较大。
如果K值很小就是一个 大一点的市价单,直接就可能打穿(吃掉 best ask 或者 best bid)和推动中间价移动。

What is the reservation price” />
AS通过3个fator来规避这种存货风险:

持仓量q,也就是买入股票数量
How distant is the trader’s current inventory position is from the target position? (q)
也就是查询当前持仓和目标仓位的差值。比如你有2万USDT,想来做btc的现货做市,你可以设定你最多持有0.5个比特币和1万usdt(币和现金各半,设定btc 价格2万美金一个)。而你现在只有2万usdt,所以这个差值q = 0-0.5 =-0.5 ,初始化的时候,策略要一直尽力去买入btc了。而当你有0.8个btc,那么AS策略,就要卖出btc,维持0.5btc这个目标;
When q<0, the trader is short on the asset, and the reservation price will be higher than market mid-price, increasing the chance of a buy order is filled; 也就是q小于目标值了,就要提高预定值,这样买单执行概率增大。

When q > 0, the trader is long on the asset, and the reservation price will be lower than market mid-price, increasing the chance of a sell order is filled;也就是q大于目标值了,就要降低预定值,这样卖单执行概率增大。

持仓风险γ
How much inventory risk does the trader wants to take? (γ)这一段比较简单,你设置γ越大,公式一后面部分成绩就大,然后和midprice偏离就大。如果设置很小就很靠近midprice.
This parameter is a value that must be defined by the market maker, considering how γ inventory risk he is willing to be exposed.

If γ value is close to zero, the reservation price will be very close to the market mid-price. Therefore, the trader will have the same risk as if he was using the symmetrical price strategy.设置为0,就是固定网格值的网格策略,虽然盈利概率99.5%,但最后一次就是让你送命。

Time until the trading session ends (T-t),也就是交易持续的时间

The agent’s objective is to maximize the expected exponential utility of his P&L profile at a terminal time T.
如果操盘加密货币,那么就是全年无休,怎么设置这个永续时间呢?下篇分解

You might have noticed that I haven’t added volatility(σ) on the main factor list, even though it is part of the formula. That is because volatility value depends on the market price movement, and it isn’t a factor defined by the market maker. If the market volatility increases, the distance between reservation price and market mid-price will also increase.

您可能已经注意到,我没有在主要因素列表中添加波动率(σ),尽管它是公式的一部分。这是因为波动值取决于市场价格的变动,而不是做市商定义的因素。如果市场波动性增加,则保留价格与市场中间价之间的距离也将增加。