逆向选择与价格偏差
Adverse Selection and Markouts

原始链接: https://machow.ski/posts/markouts_and_adverse_selection/

本文探讨了做市机制,重点分析了提供流动性所固有的挑战。做市商通过买卖价差获利,但也面临重大风险,主要是**库存风险**(持有未对冲资产)和**逆向选择**(与拥有优势信息的交易者进行交易)。 当做市商报出价格时,本质上是“亮出了底牌”。更快速、掌握信息优势的交易者往往利用延迟优势,在做市商调整报价前“抢单”。这种具有高度方向性的问题交易被称为**有毒流**。为了减少损失,做市商采取扩大价差、跨关联资产或交易所对冲,以及利用交易所提供的保护措施(如“撤单优先”协议)等策略。 作者强调,衡量成功与风险需要追踪**标记(markouts)**——即计算一笔交易相对于特定时间跨度内中间价的理论盈亏指标。通过分析这些标记,市场参与者可以识别信息流,并评估交易所的健康状况。作者还介绍了 *markouts.dev*,这是一款旨在跨平台追踪此类指标的工具,旨在证明较低的标记通常与更公平、更高效的交易环境相关。

Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 逆向选择与标记 (machow.ski) 3 点,由 costco 于 1 小时前发布 | 隐藏 | 过往 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

banner

All the views expressed below are the personal views of the author, and are not financial or investment advice.

Every exchange needs its market makers. Liquidity (which is the availability of quotes in order books) is the lifeblood of any sensible exchange, and thus the presence of these entities is both necessary and desirable. Market making, however, is not an easy game to play!

Every quote that is placed runs the risk of getting picked off by someone both sharper and faster, and if you aren’t careful, this can siphon off any potential profits. In this article, we will be covering the concept of adverse selection, which is where one market participant has more information than another, and uses it to their advantage. As part of this, we will also cover the concept of markouts, which can be used to measure it.

It’s been quite a while since I’ve written! Since that time, AI has become highly prevalent in online writing. While I may use AI to research or code, I want to assure you that my writing (for better or for worse) is my own!

How Does Market Making Work?

As always, it’s worth actually describing what a market maker does first before looking at the behaviour in question. Naturally, if you are already well-versed, feel free to skip forward to the next section.

A Basic Case

A market maker is like any other market participant, in that they can place and cancel orders, and carry out trades. The detail, however, is in how they behave. While many participants are trying to trade in some particular direction (e.g. long, because they think the price will go up), a market maker has an altogether different objective. For every one of the aforementioned takers, there must be a someone who provides the liquidity and takes the other side of the trade. That entity is typically the market maker, whose sole purpose is to provide quotes so that others may transact.

To be upfront, I am not an expert on market making; however, the basics are relatively simple to understand. In the classic case, a market maker provides quotes to both buy (bids) and sell (asks/offers). The gap between these is known as the spread, and it is also in effect one of the market maker’s primary sources of profit. Traders will hit the quotes provided by the maker, and assuming the maker’s quotes don’t change, the maker will be buying at their bid, and selling higher at their ask (by the spread).

While the specific quoting method varies, generally the market maker will have some view on what the fair price of the asset is, and will try and quote around this price. As the fair price of the asset changes, so will the market maker’s quotes.

The bid/ask spread

The bid/ask spread

In general, a market maker is not trying to profit by holding on to a position while the price moves. In fact, it is often the opposite. Ideally, the market maker would prefer it if the price didn’t move much at all as long as trades are filling quotes on both sides at a reasonable rate. They can happily sit there all day and collect the spread as users buy / sell.

Inventory Risk

In reality, prices move all the time. In fact, outside of a few “structurally stable” markets (such as stablecoin pairs, e.g. USDT/USDC), they can often move quite drastically! One of the biggest risks a market maker faces is that of inventory risk, which is the risk of holding an unhedged position (inventory), and being exposed to the price action of that symbol.

Consider for instance, that you are a market maker on a BTCUSD perpetual future. This perp tracks the underlying price of Bitcoin, and is thus exposed to it. You have placed both bid and ask quotes on the book, and do not have any starting position. Say that these quotes are at \$69,000 and \$71,000 respectively, and the current fair price of the contract is right in the middle at \$70,000.

An example of how quotes change around a new fair price.

An example of how quotes change around a new fair price.

Because a maker is passive, you must wait for someone to hit your liquidity. Say that a trader comes along and hits the bid, causing you to buy 1 BTC at \$69,000. You are now long 1 BTC. Say that the price now dumps suddenly to \$65,000. Through no action of your own, you are now at an unrealised loss of \$4,000. The problem now is that you still need to quote. You start quoting around the fair price again, with a bid at \$64,000 and an ask at \$66,000 (the same spread). Another taker comes along and buys from you at \$66,000. You realise a loss of:

$66,000 - $69,000 = -$3,000

This is an example of what happens when you are unhedged. Given how fast prices move, this can be quite problematic, and thus many market makers will aim to be mostly delta neutral by not holding any exposure at all to the asset that they are market making.

Hedging Inventory Risk

How do you deal with this inventory risk? Trading the same symbol is problematic, as in general you are the one who is providing the liquidity, and that would also require crossing the spread (lose money)! Therefore, you must find something else, or go somewhere else to find the same thing.

One option, of course, is to find a symbol that is correlated to the asset you are trading. For Bitcoin (BTC), a possible option might be Ethereum (ETH). Historically, ETH has a correlation (how closely the prices move together) of ~0.8-0.9. While this relationship isn’t guaranteed to always hold, it can potentially be used to hedge the BTC risk. For instance, the user can go short some ETHUSD perp to mitigate the BTC risk. To do this properly, however, requires calculating the hedge ratio of the two, as well as monitoring to make sure the hedge is working. At the exact time of writing, to hedge 1 BTC you would need to go short approximately 38.4 ETH. However, this ratio would be subject to continuous change.

Correlation between BTC and ETH. Source: Coinmetrics

Correlation between BTC and ETH. Source: Coinmetrics

Another option is to simply hedge the same asset, but on a different exchange. For instance, find another exchange which trades a similar BTCUSD perp, and short that for the same amount. There are some caveats here, such as accounting for different funding mechanisms and periods, but in general this is probably the simplest way to hedge cleanly.

This form of cross-exchange hedging requires having two exchange connectivity setups, as well as the need to account for fees (as you will need to take aggressively on the other exchange). So it ends up looking something like this:

  1. Get hit on your bid on exchange A, and go long 1 BTC (pay maker fee)
  2. Place an aggressive sell for 1 BTC on exchange B, and go short 1 BTC (pay spread + taker fee)
A visual example of how cross-exchange hedging works. Note how the spread on exchange B is tighter, allowing the market maker to make a small profit.

A visual example of how cross-exchange hedging works. Note how the spread on exchange B is tighter, allowing the market maker to make a small profit.

Even though the market maker is holding two open positions, since they are in opposite directions they have effectively “locked” in a profit (or loss) between the price they bought at vs. the price they sold at, even if it was on two different exchanges. Notice that there were several costs associated with doing this, such as having to cross the spread, and pay fees. It is therefore up to the market maker to widen their quotes such that they make sufficient money on the spread in order to cover all of these costs.

What is Adverse Selection?

Market makers can be viewed as having an inherent disadvantage in the market. This is because, unlike the takers in the market, the market maker must “show their hand” first by placing a quote. The taker therefore is given the option to take it or not, at their discretion. In fact, there is even a paper that models a market maker’s quotes as writing free put and call options, highlighting the risk that the Market Maker (MM) exposes themselves to by simply quoting.

Types of Flow

A continuous set of trades for a symbol is often called flow. This flow can have many different characteristics, depending on the constituent traders that make up said flow. One large aggregate grouping that is most relevant to this discussion is informed and uninformed flow.

Uninformed flow represents traders who do not have an accurate view of where the price is moving. Note that this classification has a temporal component. Not knowing where the price is going within ~1 second doesn’t necessarily mean that a trader doesn’t, for example, have a more accurate view for 10 minutes or 10 days down the line. For the purposes of this discussion, however, we care mostly about these very short time periods, as these are where the market maker will need to hedge. As such, over these time ranges uninformed flow can be seen as essentially random or “noise like”.

An example of what uninformed flow might look like. Buys and sells are positioned randomly.

An example of what uninformed flow might look like. Buys and sells are positioned randomly.

On the other side, informed flow has a very good idea of where the price is going to move. There are various ways this can happen, such as e.g. having well trained order book imbalance models or similar, but in many cases an obvious source of such information is simply other exchanges.

An example of what informed flow might look like. Buys and sells appear positioned just before large moves in the correct direction.

An example of what informed flow might look like. Buys and sells appear positioned just before large moves in the correct direction.

For instance, often the highest-volume exchange, such as Binance, can be where price discovery occurs, and once this happens, this new price is “transmitted” to other exchanges by way of market makers changing their quotes.

“The tether-margined perpetual contract on Binance is clearly the main source of volatility, continuously transmitting strong flows to all other instruments and receiving very little volatility from other sources.”

Carol Alexander & Daniel Heck & Andreas Kaeck, 2021. “The Role of Binance in Bitcoin Volatility Transmission,” Papers 2107.00298, arXiv.org, revised Aug 2021.

Exchange A (blue line) leads Exchange B (purple line). When A’s price moves, B will move also after a short delay (milliseconds usually).

Exchange A (blue line) leads Exchange B (purple line). When A’s price moves, B will move also after a short delay (milliseconds usually).

However, such a change takes time to propagate from any leading exchange to the interested parties. Indeed, there is a whole set of steps that need to happen for a participant to react to such a price change. For instance:

  1. Price changes on exchange A
  2. Price change is published on exchange A WebSocket feed
  3. Participant receives price update on their system
  4. Participant runs business logic to understand the change, and make a decision
  5. Participant sends an order to exchange B
  6. Exchange B picks up the order, validates it, and places it in the book

Each of these steps incurs latency, and a large part of the market making game is optimising your stack, colocating your servers, or even setting up direct microwave links in order to shave milliseconds, microseconds, (or in more extreme cases) nanoseconds, off of each and every one of these steps.

In this latency arms race, whoever is the fastest has an immediate advantage, and if fast enough, can have an almost prescient ability to predict the price on smaller non-leader venues. A sophisticated High Frequency Trader (HFT) in the crypto space is probably operating in the range of tens of milliseconds, if not less. Therefore, any cross-exchange latency advantage can classify the flow as “informed” in that time range.

“There are three ways to make a living in this business: be first, be smarter, or cheat. Now, I don’t cheat. And although I like to think we have some pretty smart people in this building, it’s a hell of a lot easier to just be first.”

John Tuld (played by Jeremy Irons), Margin Call (2011)

Going back to market making, we can see below an example of how a slower market maker can be “picked off” by a much faster taker, leading to an immediate unrealised loss, even if they manage to hedge.

An example of how a slower market maker can have their quote picked off by a faster informed taker.

An example of how a slower market maker can have their quote picked off by a faster informed taker.

Toxic Flow

A maker whose quote has been picked off can be said to have been adversely selected, as their quote was in effect caught out. Flow that picks off market makers’ quotes quickly and with high directionality is sometimes called toxic flow, due to its impact on market makers. As mentioned, market makers are particularly susceptible to this kind of flow, due to their requirement to always “show their hand” and keep their quotes open.

You can actually model this by running a simulated exchange. In this example, a market maker quotes symmetrically around the mark price with some specific spread. The price itself moves randomly under Brownian motion. Along with the market maker, we place a trader who in effect trades randomly by placing market orders at the bid or ask, with equal probability, to represent general noise flow.

We simulate 100 runs and plot all of the resulting PnL paths of the maker. The purple line shows the average path. We note that although there is some variance (expected with any stochastic system), the average net PnL at the end of the simulation ends up positive, despite the price going up and down. The following is with a market maker quote spread of 10 basis points (0.1%).

Average PnL of a market maker with random flow with a 10bps spread. The top chart shows one example run’s fill placement.

Average PnL of a market maker with random flow with a 10bps spread. The top chart shows one example run’s fill placement.

In the above case, the maker on average makes about \$4,140 when running for 100 ticks (time steps). In fact, we can see how if the market maker increases their spread, they will make more money. It’s worth noting though that this is in fact extremely unrealistic, as a market maker with wider spreads will lose out to fills from other makers who quote tighter. As always, everything is in equilibrium.

Average PnL of a market maker with random flow with a 20bps spread.

Average PnL of a market maker with random flow with a 20bps spread.

Now consider that we keep the original 10bps spread, but now add in an informed taker. Unlike the random trader, this trader has a simple form of “prescience”. They are able to predict the price exactly 10 ticks into the future. Their strategy is that if they predict that the price will be higher/lower, they will market buy/sell, and later, at the predicted horizon, they will close their position. To make it more obvious, the informed taker sizes their trades to be larger when they see an edge. The chart shows the negative impact of such a trader on the PnL of the market maker.

Average PnL of a market maker with 10bps spread, and one informed and one uninformed trader.

Average PnL of a market maker with 10bps spread, and one informed and one uninformed trader.

You can spot the informed taker pattern just in the PnL chart from the sawtooth-shaped waves. The initial jump comes from the fact that the informed taker will cross the spread, meaning that the initial unrealised PnL jumps by half the spread. However, within 10 ticks that gain slowly bleeds off as the (predicted) price moves away. Notice that with the presence of the informed taker, the market maker’s PnL has dropped by around 60% to \$1,620.

Also worth noting (and we will discuss it later) is that by increasing their spread, the market maker is able to mitigate the effect of the toxic taker. Of course, this is not a panacea, as the wider spread would affect their fill rate from normal flow. In this case, raising the spread by 2bps to 12bps can roughly mitigate the effect of the informed taker, and regain their original ~\$4k PnL.

Average PnL of a market maker with 12bps spread, and one informed and one uninformed trader.

Average PnL of a market maker with 12bps spread, and one informed and one uninformed trader.

As can be seen, the presence of informed flow can immediately affect the quoting of makers in order to protect their margins.

Mitigating Adverse Selection

We have discussed what adverse selection, and how market makers can lose money when quotes that are not priced correctly are taken before they can react by faster participants. But how can it be mitigated? There are in fact several ways in which this can be done, both by makers themselves and by participating exchanges.

Widening Spreads / Pulling Quotes

The primary countermeasure makers can deploy is to simply to widen their spreads. A wider spread is harder to take advantage of, as a potential taker’s arbitrage trade must be profitable enough to cover not only the costs of the trade, but also the additional spread. As mentioned, the downside of this is that a maker that is quoting wide will not get filled at all. After all, no one wants to buy something \$1,000 higher than on other venues. If the situation is adverse enough, a maker may opt to just switch off their quoting altogether and wait for better market conditions to continue quoting. We’ll be covering how this can be detected in a later section.

Widening the spread can be used as a mitigation strategy for adverse selection.

Widening the spread can be used as a mitigation strategy for adverse selection.

Exchange Flow Segmentation

Clients on exchanges can be segmented (put into various categories) based on various factors. One of these factors can be the degree of informed trading that they do (more on this later). With this categorisation system in place, it is possible to operate different pools in which makers can potentially be screened from getting sniped, and can therefore provide tighter spreads to higher-latency clients.

Another mechanism is simply “self-selection” via so-called Retail Price Improvement (RPI) systems. For instance, on Binance it is possible to mark an order as an RPI order. Such orders are post only (they are always passive), and cannot be taken by API orders. An Application Programming Interface (API) is a way for applications to talk to an exchange, and this is the primary way low-latency entities would trade.

An example of how a Binance RPI order handles an aggressive order.

An example of how a Binance RPI order handles an aggressive order.

Cancel Priority

As mentioned earlier, one of the key issues for makers is often that they may be aware that the market has moved relatively quickly, but they are simply unable to shift their liquidity out of the way fast enough. Another approach is to give cancels priority when sending requests to the exchange. This means that makers who need to cancel their orders to get out of the way have a structural advantage over the taker who is trying to snipe their order.

A well-known example is the Decentralised Exchange (DEX) Hyperliquid. Since the exchange is on-chain, it works using the concept of blocks which can contain several market instructions. We’ve covered how this block-based transaction model allows for multiple actions to be included and ordered in a single block in the block model section of the flash loans article. The following shows how a hypothetical block without re-ordering might look when a faster taker picks off a market maker’s order.

An unordered block showing a market maker’s order getting picked off by an informed taker who beats their cancel.

An unordered block showing a market maker’s order getting picked off by an informed taker who beats their cancel.

On Hyperliquid, every validated block MUST be reordered so that cancels and post-only orders execute first. Each block takes around 100-200ms, and thus if a maker notices a sudden price move, their cancel (even if sent in after an aggressive adverse order) will still be prioritised, potentially avoiding the undesirable fill.

A cancel-first ordered block showing that the market maker is able to cancel their order, despite being slower than the informed taker’s aggressive order.

A cancel-first ordered block showing that the market maker is able to cancel their order, despite being slower than the informed taker’s aggressive order.

Measuring Adverse Selection

For any maker, as a regular part of doing business, it is worth knowing if you have been adversely selected. One way of doing this is to measure markouts at various time intervals (called horizons). The concept is relatively simple:

  1. Look at a trade that you made, find its execution price and direction (buy or sell)
  2. Look at the mid price at various time intervals (100ms, 1s, 10s, etc) from the time of the trade onwards
  3. Calculate the profit of the trade as if you closed the position at that time interval (so if you bought, assume you sold at that price)
A chart showing a series of markouts for a buy trade at 1, 5, 10 and 15 seconds.

A chart showing a series of markouts for a buy trade at 1, 5, 10 and 15 seconds.

In the chart above, you can see how the markout can be measured for an aggressive buy trade. Notice that the mid price rises over time after the trade, so this would be seen to have positive markouts from the perspective of the trader. The markout is often quoted in basis points (1/100th of a percent) of the trade price. It can be calculated as:

$$ M = \frac{S(P_{mid} - P_{trade})}{P_{trade}} $$

Where $P$ is the trade or mid price, $S$ is the direction of the trade (1 for buy, -1 for sell), and $M$ is the markout. This direction is assuming that you are measuring your own trade. For instance, we might expect the markout table to look something like this for the example above.

Horizon (s)Markout (bps)
11.0
53.0
102.0
155.0

The mid price here is used as a proxy for the “fair market price” of whatever is being traded. There are some arguments to be made as to whether this is accurate as a fair price, and there are alternatives that can be used. However, in the interest of simplicity, we will go with that.

In this setup, a positive markout indicates that at that time interval, you theoretically made money on the trade. Conversely, a negative markout indicates that at that time interval you in theory lost money. Note that this doesn’t actually represent the real profit and loss, as that depends on whether the position really was closed, or whether it was hedged somewhere else.

However, this can be a useful measure to identify if the flow that is being traded is toxic. For instance, consider 100% uninformed flow. If we plot the markouts with the horizons on the x-axis, we can create a markout curve. This can show us how the price behaves at different points in time after our trade. By taking multiple markouts and averaging them, we can get a general view of what the average markouts for our trades look like.

A markout curve showing a signature of uninformed / random flow.

A markout curve showing a signature of uninformed / random flow.

In this case, assume the price moves randomly, and the fills are likewise random (uninformed flow). What would you expect the markout to be?

You might expect it to be 0, as the positive markouts will cancel out the negative markouts. However, in reality the markout should be slightly positive (as we can see in the diagram above). This is because the markout is being measured from the price the trade was executed at, while the markout price is being measured from the mid price. If you measure the markout at a horizon of 0 (i.e. right at the moment of the trade), you would expect the markout to be half of the spread. See the diagram below for why that is.

The immediate markout for a passive trade is generally half a spread.

The immediate markout for a passive trade is generally half a spread.

How about if there exists an informed taker? What would the markouts look like then? The below chart shows a possible example.

A markout curve showing a possible informed taker.

A markout curve showing a possible informed taker.

What immediately stands out is the sharp drop around ~200ms. In fact, at this level the markout goes negative, implying that the market maker lost money on paper around that time. What this suggests is that there is an informed taker that operates with approximately a 200ms latency advantage. Now, if the market maker is able to hedge within 200ms, then this is (potentially) not a problem. If not, however, it is likely that the market maker is losing money due to this effect.

We can in fact demonstrate this effect by going back to the earlier section on toxic flow. Below is a plot of the average markouts for a market maker where an informed taker with a 5-tick latency advantage (to make it more obvious) is present. Notice how it drops off down to 5 ticks, after which it is effectively flat.

Simulated markout curve for a market maker facing an informed taker with a 5 tick latency advantage.

Simulated markout curve for a market maker facing an informed taker with a 5 tick latency advantage.

Measuring Exchange Markouts

An interesting exercise is to adapt the concept of markouts not just to a single maker (who cares only about their trades), but generally to all trades on an exchange. The ingredients required to calculate markouts are public trades and quotes, both of which are generally available via WebSocket APIs. In this case, the markouts are calculated by looking at the direction of the trade. Since the convention on exchanges is that the aggressive trade is the one published, this direction along with the quotes can be used to ascertain profitability at different time horizons.

Latest Trades feed on OKX. Note how trades are highlighted green/red for buy/sell, indicating their direction.

Latest Trades feed on OKX. Note how trades are highlighted green/red for buy/sell, indicating their direction.

To that end, I put together a site, markouts.dev, which tracks markouts from several centralised and decentralised exchanges. On the site you can see the overall average Volume Weighted Average Markout (VWAM) by exchange, and also by symbol. This is the average markout weighted by the USD notional of each trade, so that larger trades are weighted more heavily than dust trades. It can be quite interesting to see how markouts compare between exchanges, and also on various symbols.

Markout comparison between various exchanges.

Markout comparison between various exchanges.

One thing to note is that the markout here is calculated from the perspective of the taker. So a positive markout indicates that a taker made money on the trade at the markout horizon. I also added one modification here, which is that it is possible to measure markouts not just from the trade price, but also from the mid price (mid to mid). This can be useful in eliminating the effect of the size of the spread from the markout itself.

Markouts can also be measured from the mid price at the time of the trade, rather than the trade itself.

Markouts can also be measured from the mid price at the time of the trade, rather than the trade itself.

You can also click into individual markouts to see how the quotes behaved over time after the trade occurred. Storing all of the quotes is absolutely ruining my disk space, so make use of it!

Detailed markout view with the quote context.

Detailed markout view with the quote context.

It’s a bit rough around the edges, and due to the sheer volume of data there can be capture issues. In fact, for some of the larger exchanges I had to limit the capture to the top 100 symbols by volume, as otherwise my meagre $20-a-month server was not able to keep up!

It’s definitely interesting to see the data in aggregate. For instance, my general observation is that for the larger exchanges the average markout at around 1 second is about 2 basis points. The aforementioned Hyperliquid seems to enjoy a slightly lower average markout at around 1.1bps, possibly due to the cancellation priority mechanism.

If you have any feedback, I’d be happy to hear it!

Glossary

Adverse Selection
A situation where one market participant has better information than another, and uses it to trade against them.
Application Programming Interface (API)
A mechanism by which trading applications can interact with an exchange programatically.
Delta Neutral
Having little or no directional exposure to the underlying asset being traded.
Decentralised Exchange (DEX)
An exchange that operates without a centralised matching or custody system, often using on-chain infrastructure.
Fair Price
A market maker’s estimate of the current true value of an asset, around which they place bids and asks.
Flow
The stream of trades for a market or symbol.
High Frequency Trading
Trading carried out by algorithms that operate with extremely low latencies (eg. on the order of milliseconds or microseconds).
Horizons
The time intervals after a trade at which markouts are measured, such as 100ms, 1s, or 10s.
Informed Flow
Trades from participants who have a useful short-term view of where the price is likely to move.
Inventory Risk
The risk of holding an unhedged position and being exposed to price moves in that asset.
Markout
A measure of how profitable a trade would be if marked against a later reference price, usually the mid price at a chosen horizon.
Markout Curve
A plot of markouts across different time horizons after a trade.
Market Maker
A participant who provides liquidity by placing quotes that other traders can transact against.
Post Only
An order instruction that ensures an order rests on the book as passive liquidity rather than immediately trading.
Retail Price Improvement (RPI)
A system that allows certain passive orders to prevent being matched against API-originating orders.
Toxic Flow
Flow that tends to trade just before favourable price moves, causing losses for the market makers it trades against.
Unhedged
Holding an open exposure without an offsetting position to reduce the risk.
Uninformed Flow
Trades from participants who do not have a reliable short-term view of where the price is likely to move.
Volume Weighted Average Markout (VWAM)
The average markout weighted by the notional size of each trade, so larger trades have more influence.
联系我们 contact @ memedata.com