jjzjj

Avellaneda & Stoikov’s market-making strategy AS模型的通俗理解篇(一)

高频交易dragon 2024-01-11 原文

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?
The basic strategy for market making is to create symmetrical bid and ask orders around the market mid-price. 一般策略就是围绕中间价进行报价,比如卖价 midprice +σ;买入价 midprice -σ

But this kind of approach, depending on the market situation, might lead to the market maker inventory skewing in one direction, putting the trader in a wrong position as the asset value moves against him.
这样的方法弊端就是,发生单边下跌行情,你可能就满仓持有资产,亏大了。如果单边上涨,你就无货可卖,俗称卖飞了。

For example, if the BTC-USDT market price enters a downtrend and the trader uses the symmetrical approach, his buy orders will be filled more often than the sell orders. At the end of the day, the market maker will be loaded with BTC, and his total inventory will have a smaller value.看看下面的btc震荡下跌图,如果你采用类似固定值网格操盘法,你就收到一堆btc存货,而且btc价格不断走低,你也亏了不少。

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.

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

有关Avellaneda & Stoikov’s market-making strategy AS模型的通俗理解篇(一)的更多相关文章

  1. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  2. ruby-on-rails - 由于 "wkhtmltopdf",PDFKIT 显然无法正常工作 - 2

    我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-

  3. ruby-on-rails - Rails - 子类化模型的设计模式是什么? - 2

    我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co

  4. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  5. ruby-on-rails - Rails - 一个 View 中的多个模型 - 2

    我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何

  6. ruby-on-rails - 如何从 format.xml 中删除 <hash></hash> - 2

    我有一个对象has_many应呈现为xml的子对象。这不是问题。我的问题是我创建了一个Hash包含此数据,就像解析器需要它一样。但是rails自动将整个文件包含在.........我需要摆脱type="array"和我该如何处理?我没有在文档中找到任何内容。 最佳答案 我遇到了同样的问题;这是我的XML:我在用这个:entries.to_xml将散列数据转换为XML,但这会将条目的数据包装到中所以我修改了:entries.to_xml(root:"Contacts")但这仍然将转换后的XML包装在“联系人”中,将我的XML代码修改为

  7. ruby - 检查 "command"的输出应该包含 NilClass 的意外崩溃 - 2

    为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar

  8. ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=' - 2

    我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer

  9. ruby-on-rails - 在混合/模块中覆盖模型的属性访问器 - 2

    我有一个包含模块的模型。我想在模块中覆盖模型的访问器方法。例如:classBlah这显然行不通。有什么想法可以实现吗? 最佳答案 您的代码看起来是正确的。我们正在毫无困难地使用这个确切的模式。如果我没记错的话,Rails使用#method_missing作为属性setter,因此您的模块将优先,阻止ActiveRecord的setter。如果您正在使用ActiveSupport::Concern(参见thisblogpost),那么您的实例方法需要进入一个特殊的模块:classBlah

  10. ruby-on-rails - 如何优雅地重启 thin + nginx? - 2

    我的瘦服务器配置了nginx,我的ROR应用程序正在它们上运行。在我发布代码更新时运行thinrestart会给我的应用程序带来一些停机时间。我试图弄清楚如何优雅地重启正在运行的Thin实例,但找不到好的解决方案。有没有人能做到这一点? 最佳答案 #Restartjustthethinserverdescribedbythatconfigsudothin-C/etc/thin/mysite.ymlrestartNginx将继续运行并代理请求。如果您将Nginx设置为使用多个上游服务器,例如server{listen80;server

随机推荐