카테고리 없음

Simplified Avellaneda-Stoikov Market Making | by Crypto Chassis | Open Crypto Trading Initiative | Medium

steloflute 2022. 2. 12. 23:18

Simplified Avellaneda-Stoikov Market Making | by Crypto Chassis | Open Crypto Trading Initiative | Medium

 

Simplified Avellaneda-Stoikov Market Making

Welcome back to Crypto Chassis! Recently we have worked very hard on a brand new product line designed specifically for liquidity…

medium.com

 

Aug 14, 2021

5 min read

Simplified Avellaneda-Stoikov Market Making

Photo by Scott Graham on Unsplash

Welcome back to Crypto Chassis! Recently we have worked very hard on a brand new product line designed specifically for liquidity providers: an optimal end-to-end solution to market making. We spent a lot of time studying the available solutions already present on the internet and made our best efforts to stand on the shoulders of those giants to become a better player by addressing three important gaps (and sometimes even defects) that we have identified in the process: a. Algorithm-Interpretability, b. Paper-Tradability, and c. Backtest-Ability. This article will explain our work on Algorithm-Interpretability: long story short we simplified Avellaneda-Stoikov inventory control strategy to make its input parameters intuitive enough to understand and reason about from a practical trader’s perspective. A future article will explain our work on Paper-Tradability and Backtest-Ability: long story short we took an event-driven approach rather than a time-driven approach to cope with temporal heterogeneous tick data as opposed to temporal homogeneous bar data. Anyway, our application is live and ready to use: https://github.com/crypto-chassis/ccapi#spot-market-making-beta.

In 2008, Marco Avellaneda and Sasha Stoikov published a seminal academic paper on the subject of market making: https://www.math.nyu.edu/~avellane/HighFrequencyTrading.pdf. The article itself involves a lot of very complicated mathematical equations, which at a first glance certainly overwhelms any practical traders who don’t plan to become university professors. 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 mathematical derivations that they went through were lengthy, but the conclusions and insights that they arrived at can be made neat and crisp:

  • 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.

Let us discuss in more details in the context of cryptocurrency spot market making. Assume that we are trading BTC/USD currency pairs. Market making is such a game that at any point in time a market maker has to possess a certain level of inventories in both BTC and USD holdings in order to satisfy the needs from market takers. If a market maker runs out of inventory on one side, the game is essentially over for that market maker. Most of the time the ideal situation for a market maker is to possess equal values of BTC and USD holdings, and each and every time s/he places a buy order and a sell order, both orders get filled in a timely manner. However, the real situation is that if only one side of the order is filled and the other side of the order hangs for a long time unfilled and thus has to be canceled, and now the inventory is no longer balanced, what should s/he do? Assume there’s more BTC in the inventory than USD, Avellaneda & Stoikov concluded that the market maker should no longer position the bid and ask prices symmetrically around the mid price. Instead s/he should lower the bid price ( = buy order price) so that it becomes less likely to buy in even more BTCs (to make inventory imbalance worse), and at the same time keep the same ask price ( = sell order price ). If indeed the buy order doesn’t get filled and the sell order does get filled, the inventory now becomes more balanced between BTC and USD holdings and the market maker has lowered his/her risks of getting the USD inventory depleted in the near future. If still both the buy and sell orders are filled, the inventory now is at the same level of BTC vs. USD imbalance (i.e. same level of inventory risk), but because the market maker lowered the bid price and kept the same ask price, s/he was compensated by pocketing in a larger spread and thus profit, and this added capital has increased the account’s total value and thus has effectively lowered the inventory risk (because the additional capital can potentially be used to replenish the depleted inventory on one side if that happens). Therefore, either way the market maker can maintain his/her market making capability and remain profitable. Furthermore, Avellaneda & Stoikov taught us that based on probability theory the optimal amount to be lowered in the bid price should be linearly proportional to the degree of BTC’s inventory excess, which makes perfect intuitive sense.

Phew! That’s already quite non-trivial to explain. To put Avellaneda & Stoikov’s strategy into a practically applicable context for the trading battle field, we distilled those intricate math formula into two interpretable parameters (and more importantly backtest-able, more on this in a future article): the minimum spread and the maximum spread (see https://github.com/crypto-chassis/ccapi/blob/develop/app/src/spot_market_making/config.env.example). The minimum spread represents the level of maker-maker and taker-taker competitions in the selected market and in general is set at a value such that our orders positioned at the minimum spread can get filled on both sides with a decent probability. The maximum spread represents the market maker’s tolerance limit on the inventory’s allowable imbalances and in general is set at a value such that our order (only one side of the order) positioned at the maximum spread cannot get filled very easily. Finally, remember that Avellaneda & Stoikov taught us that we should linearly move the price between positioned at the minimum spread and positioned at the maximum spread depending on the inventory’s degree of imbalance. Our source code to achieve this is only about 200 lines long and is located at https://github.com/crypto-chassis/ccapi/blob/develop/app/include/app/spot_market_making_event_handler.h.

Happy coding! To sum up, we have released a spot market making application based on classical Avellaneda-Stoikov strategy as an end-to-end solution for liquidity providers. If you are interested in our work or collaborating with us, join us on Discord https://discord.gg/b5EKcp9s8T. 🎉

Disclaimer: This is an educational post rather than investment/financial advice.