Consolidated Order Books & Smart Order Routers

16 minute read
Subscribe to the mailing list, or follow me on twitter!

banner

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

Trading out large orders can cause significant market impact if not done carefully. In this article we will cover how consolidated order books can be used to assess liquidity depth of the overall market, and how systems know as “Smart Order Routers” allow dynamic routing of orders so as to trade out large quantities of assets without adverse effects.

If you are unfamiliar with order books, reading the introduction to order books is highly recommended. If you are just interested in trying out the demo app, you can find it here: cryptosor.info.

Exchange Market Impact

We have talked about market impact many times before. The more passive orders there are at prices near the top of the book, the better the price that can be achieved by a large order. While a small order may only remove one or maybe two levels (and move the price one or two ticks), a large order can remove significantly more causing the last price to swing violently.

With the increase in capital inflow from institutional clients in recent years, market participants may find themselves in a position of having to move and trade large volumes of capital. While an individual trader with their spot account may just buy and sell on a whim, such institutions face an altogether more complicated game. A retail client may optimistically deal with notionals in the range of millions of USD, institutions may need to deal with orders that can be 100x that size.

As an example, looking right now at FTX I see that to buy 10BTC would give me a slippage of around 5bps, or 0.05%. Not too bad, at the current BTC price of \$41,600 that’s roughly \$170 lost too slippage, and a market impact (price move) of about \$15.

FTX order book showing the average price at specific depths

FTX order book showing the average price at specific depths

However, let’s say I’m an institution and I need to move 1000BTC (about \$41MM USD notional). The slippage on FTX would be about 177bps or 1.7%, costing roughly 735k USD for the slippage. Bear in mind, that this is just the average price and the actual market impact (how many price levels were removed) was close to \$3,300. This would cause a huge wick in the charts, which might potentially cause the market to react unpredictably, exacerbating your problems. As you can see, the larger the amounts, the larger the impact and therefore the larger the cost to the business.

Mitigating Price Impact

As we just saw, if you are a large institution managing a lot of money, trading with it can be quite unwieldy. Nevertheless, institutions carry out trades like this frequently, and most of the time… you wouldn’t even know! There are several ways of trying to reduce market impact for large orders, and below are a couple.

Favouring Passive Orders

Sending an aggressive order such as a market order, or a deep limit order means that you will have to cross the spread in order to trade. This is not always ideal, as not only will you have to pay more due to the spread, but also you may end up paying taker fees as well, increasing your cost.

If possible, passive orders can be used to improve the price and also to have less market impact. Of course, use of passive orders means that you are more exposed to the risk of the price moving adversely while you are waiting to be filled. Therefore, smart strategies will blend passive and aggressive orders depending on their market outlook in order to balance the cost of being aggressive with the potential cost of waiting.

Over The Counter (OTC) Desks

One of the easiest (and most MBA friendly) ways is just to outsource the problem! Over The Counter or OTC desks are businesses that specialise in taking large orders on behalf of clients. The name originates from the fact that unlike in a centralised exchange with many players, the client is going directly to the brokers “shop” to do a deal. The workflow (sometimes called Request For Quote or RFQ) is typically like this:

  1. Client comes to OTC desk saying e.g. “I want to sell 1000 BTC, please give me a quote for how much you will pay me”.
  2. The OTC desk will evaluate internally how they could handle such an order. They will then reply to the client saying: “I will buy 1000 BTC for \$39,000 per BTC”.
  3. Having received the quote, the client now has the option of deciding if they like it. They can of course reject the quote, or they can accept it if they like the terms. Usually the quote has a Time To Live or TTL which is how long the quote is valid for.
  4. Assuming the client accepts within the time limit, they will agree to the quote, and the trade will be booked (just like on an exchange) and funds will be transferred.
  5. The client has now made the sale, and is done with the transaction.
  6. The OTC desk now has 1000 BTC with which they can do what they like. Usually, they will try to sell it off to another client, or they may warehouse it waiting for some other party to buy it off them.
An indicative quote from FTX OTC to buy 100 BTC. Note the expiry time, as quotes typically are only valid for a few seconds.

An indicative quote from FTX OTC to buy 100 BTC. Note the expiry time, as quotes typically are only valid for a few seconds.

One of the ways such entities make money is to quote the client a slightly worse price than the OTC desk thinks they can get in the market themselves. As such, the client is paying a spread in order to use the OTC desks expertise in offloading large orders.

Trading The Order Out Slowly

A common way of trying to reduce market impact is to take a large order, break it up into multiple smaller orders, and then trade them out in the market over time. Doing so allows market makers time to refill liquidity, thereby reducing the impact of the order.

This area of finance is commonly called Algorithmic Execution, and is a very wide area that has a lot of interesting elements. I plan to revisit this in more detail in a future article.

Trading On Multiple Markets

Up till now, we have been exclusively looking at trading on one exchange. But assuming certain assets (like Bitcoin) are fungible (the same) on multiple exchanges, perhaps we could use this to our advantage?

Each exchange that we can trade on represents an order book, and therefore a pool of liquidity that we can use to trade out our order. If we can split out our order over several different exchanges, we might be able to reduce our slippage overall. For instance, if we wanted to buy 120 BTC on Binance (at the time of writing) we would achieve a slippage of around 23bps (0.23%). However, we could split up our purchase over e.g. Binance, FTX and Coinbase, sending a 40 BTC order to each one. Doing so results in an approximate slippage of only 9bps (0.09%).

Splitting up an order over multiple markets can decrease the impact on individual exchanges order books, and therefore reduce slippage.

Splitting up an order over multiple markets can decrease the impact on individual exchanges order books, and therefore reduce slippage.

So this is nice, we have reduced our slippage and our market impact by simply using multiple exchanges and splitting up our order. Is this optimal though?

Consolidated Order Books

As mentioned, we can model the market as a collection of order books each of which we can trade against. In the above example we simply divided up our order evenly across the number of markets (order books) we had access to. This results in a price improvement, but if you think about it, not all liquidity is equal!

Remember that we are dealing with multiple order books, and their prices may not be inline with each other. Indeed, the price between exchanges can vary for various different reasons. Some may be transient such as momentary fluctuations in price, others may be systemic such as the exchange having high fees which adds to the cost of trading there. Consider therefore three exchanges A, B and C with the following order books for some symbol X:

Individual order books of three different exchanges.

Individual order books of three different exchanges.

Let’s say we want to buy 6,000 X. Using the strategy above, we split our order into three 2,000 X Buy orders and send them to the exchanges. Our trade feed would end up looking like this:

Resultant trade feed of executing a 6,000 quantity buy order over three different exchanges.

Resultant trade feed of executing a 6,000 quantity buy order over three different exchanges.

Our trading results in an average price of 101.5. Not too bad, but as mentioned not optimal.

To find the best achievable price, we need to create what is known as a consolidated order book (sometimes also called a composite or aggregate order book). This is a book that contains all the available price levels from all the exchanges, sorted in price/time priority. In our case, we simply take all three books and merge them together, indicating which price level belongs to which exchange.

Consolidated order book from exchanges A, B and C. Crossed prices are marked in red.

Consolidated order book from exchanges A, B and C. Crossed prices are marked in red.

Notice also that at the top of the book, some prices are marked in red. This indicates the book is crossed at these levels (the best bid is greater or equal to the best ask). Such crosses can indicate arbitrage opportunities where someone could make a risk free profit. In this case, someone could buy from C at 98, and sell on A for 99, netting a \$1 profit per share.

We can now “pretend” trade 6,000 shares against this book, which would result in the following trades:

Resultant trade feed of executing a 6,000 quantity buy order against a consolidated order book.

Resultant trade feed of executing a 6,000 quantity buy order against a consolidated order book.

Notice that our average buy price is much better, at 99.17. If you look closely at the individual exchange’s books, you will see this is mainly because of cheaply priced liquidity on exchange C. By using the consolidated book we have prioritised executing against the cheaper exchange (C), netting us a better price.

Of course, in real life you cannot execute against a consolidated order book, since it is only a representation of the real world. What would actually happen is that after evaluating the trades as above, you would send orders to the individual exchanges depending on how much needed to be executed. So for the above, you would send two orders (ignoring the badly priced exchange B entirely):

ExchangeQuantityLimit Price
A2,000102
C4,00098

Smart Order Routers

Anyone who has worked at an investment bank can attest to the vast number of systems within such institutions. Most people working in Crypto are dimly aware of the scale of such places, and how convoluted their systems can be. Most electronic trading divisions will have a variety of different systems all connected and working together to execute trades, manage positions, and do dozens of other things.

There are systems for exchange connectivity, for managing risk, for tracking traders PnL and for watching said traders (trade surveillance) to make sure they aren’t up to no good. There are circuit-breaker systems that can cut off trading at a moments notice to prevent runaway algos, and there are systems that keep track of current asset prices, as well as data warehouses to keep their historic records.

We won’t be covering these today, but Cal Peterson wrote a fascinating post about “Bank Python” which covers some of these systems, and is a great read. One system that is almost ubiquitous in such institutions is something called a Smart Order Router or SOR. The purpose of this system is to deal with liquidity fragmentation, which is a technical term for what we were discussing above, which is liquidity distributed over multiple different exchanges.

The purpose of a SOR in most institutions is to be a (semi) black box into which you send an order, and the SOR will fill it with the best price possible. As such, they are sometimes interchangeable with the concept of a “trading algorithm” since the more advanced the SOR, the less difference there tends to be.

Exchange Selection Factors

A SOR will normally come with an extensive array of configuration options. There are also many factors that can affect which exchanges are chosen and with what weighting. Some of the most important ones are listed below.

Fees

Trading fees are one of the biggest factors affecting exchange selection. In order to do this one can “adjust” the prices in the order book in order to account for fees to calculate fee-adjusted prices. For instance, consider an exchange where the trading fee is 10bps (0.1%) and the best bid/ask is \$40,000/\$40,100.

Adjusting for fees, the spread is (theoretically) widened.

Adjusting for fees, the spread is (theoretically) widened.

Adjusting for fees, the “true” bid is actually $\$40,000 * 0.999 = \$39,960$ and the “true” ask is $\$41,000 * 1.001 = \$41,041$. Intuitively, we can see this because due to the fees you pay more to buy (ask) and get less to sell (bid). So even though an exchange’s prices are attractive, their liquidity may still be unattractive when adjusted for fees.

Latency

Latency is the amount of time taken for an order to get to an exchange and for information to come back. Data from exchanges comes to the client in the form of market data over an electronic channel. Depending on how far away an exchange is geographically, it takes more or less time for information to arrive. Once it does arrive, the client must take into account that their view of the data might be e.g. 50ms behind what the current state of the exchange is.

Latency accounts for the time taken to communicate back and forth between a client and an exchange.

Latency accounts for the time taken to communicate back and forth between a client and an exchange.

When compiling a consolidated order book, the SOR must take into account whether the price levels that it sees currently will still be there when it sends an order. Price prediction is out of scope for this article, but it is quite a wide field with significant historic data requirements to backtest.

Capital Allocation

In order to trade on an exchange, you typically must have capital allocated there. This varies between venues, however in crypto at least if you don’t have USD of some sort on an exchange, you will not be able to make any trades that involve USD (unless you have a margin facility). Therefore, a client must select exchanges based not only on how good their prices are, but also how much it is physically possible for them to trade.

Operational Matters

Certain exchanges may operate in different ways. There may for instance be high deposit or withdrawal fees that make them less attractive. They may also be in an adverse regulatory environment that makes it costly to trade there. Such costs need to be accounted for when routing orders.

Exchanges also will often have rate limits or trading rules which need to be respected, or you risk being cut off or banned. Clients will usually have to keep track of this, and e.g. de-prioritise an exchange if they have sent too many orders already, or are close to violating a trading rule.

Lit and Dark Venues

Most exchanges that people are familiar with are Lit venues, meaning that you can see the level 2 data, and the public market data that they post. There are however other venues which are known as Dark Pools where there is less transparency when placing orders, but with the benefit that you can place a large order without it being publicly visible. Depending on the properties of the order, a SOR may prioritise dark venues in order to keep the order less visible.

Special Relationships

Large market makers may also have special relationships with certain exchanges such as agreements to provide a certain amount of liquidity in exchange for lower fees. In order to respect these agreements, a client may need to prioritise such an exchange in order to meet their obligations.

Smart Order Routers In Crypto

SORs are very popular in traditional finance, however in the crypto space they are making inroads also.

CeFi

In the CeFi (Centralised Finance) world, several different SOR systems have emerged as options for the budding crypto investment bank (gulp). Below are a couple of options that provide a SOR as part of their offering.

DeFi

The DeFi (Distributed Finance) world is arguably perfect for SOR’s, because of how blockchain transactions are atomic. This means that the latency issues disappear, and the prices and states of various AMM’s or pools are fully deterministic.

One of the most popular SORs is Balancer which attempts to try and fill an order using a collection of different pools that it controls. Due to the fact that trading over multiple pools costs gas, Balancer uses an optimiser to attempt to find an optimal trade path for your order.

A visual explanation of how Balancer’s SOR works. Source: Balancer Documentation

A visual explanation of how Balancer’s SOR works. Source: Balancer Documentation

What’s interesting about these solutions is that it is possible for exchanges to “route” a trade via an intermediate token when trying to do a swap on an illiquid pair. This allows users to get a price, even when a pair is not available. This is now a common feature on many AMM platforms, including Uniswap where it is called the “Auto Router”.

An example of the Uniswap Auto Router.

An example of the Uniswap Auto Router.

In the above example I tried to get a quote to swap 100,000 AAVE for DAI. The Uniswap Router suggests for me to swap my AAVE to WETH and then the WETH to DAI in order to get the best execution.

Smart Order Router Demo

As part of writing this article, I also put together a small application that listens to the order books of 5 different centralised exchanges (FTX, Binance, Coinbase, Kraken and OKX). It then compiles a consolidated order book for several popular symbols, and allows you to view the top 10 levels. You can find it on cryptosor.info, as well as the source code on GitHub.

A screenshot of the consolidated order book.

A screenshot of the consolidated order book.

You can select the trading pair you want in the top left, and toggle which exchanges you want to include using the toggles on the right. For instance, in the above screenshot I am excluding Kraken from the book. Any prices that are in red are price levels which are crossed, as mentioned earlier. Before you ask, not all of these exchanges use USD, so in cases where there was no USD pair I chose USDC or BUSD as a substitute.

A screenshot of the consolidated order book.

A screenshot of the consolidated order book.

The bottom panel allows you to simulate executing an order using the SOR. This will show you what your average price would be, as well as how much would be executed on each exchange. This feature will also respect the exchange choices you made in the earlier dialog, so you can exclude any exchanges you don’t like. Keep in mind, that I only have access to the public feeds, meaning that for some exchanges I only have e.g. the top 500 levels, so it may not be fully representative.

The system above is a very simple implementation, and it only takes into account the consolidated book, and no other parameters such as fees, or latency etc. It also goes without saying, but obviously it is not production ready so don’t go trading off of it (not financial advice, etc). I’m also not a designer, so try to ignore my questionable design choices and liberal use of Bootstrap.

If you have any thoughts, or bug reports, feel free to email me or hit me up on Twitter.

Edit Apr 2023: Cleaned up links

Glossary

Aggregate Order Book
See Consolidated Order Book.
Average Price
The volume weighted average price of a series of executions.
Composite Order Book
See Consolidated Order Book
Consolidated Order Book
An order book that combines the individual order books of several different exchanges.
Crossed (Book)
An order book where the best bid is greater or equal to the best ask.
Dark Pool
A type of exchange where there is less publicly visible information about liquidity.
Fee-adjusted Price
The price on an exchange, adjusted for the fees the exchange charges.
Latency
The time taken for messages to travel back and forth between a client and an exchange.
Liquidity Fragmentation
The distribution of liquidity among different exchanges.
Lit (Venue)
A venue where the market data is visible to all participants.
Market Impact
The amount the market price is moved by an order or event.
Not Production Ready
Don’t use this for actual trading.
Over The Counter (OTC)
A peer to peer method of trading between two counterparties without the use of a centralised exchange.
Rate Limit
A limit on how often once can send instructions or orders to an exchange.
Request For Quote (RFQ)
A method where a client will request a quote for a trade, and a counterparty will offer a quote which can then be accepted or rejected by the client.
Smart Order Router (SOR)
A system which uses Liquidity Fragmentation and trading on multiple venues to try and achieve a better price for a large order.
Spread
The difference between the Best Ask Price and the Best Bid Price.
Time To Live (TTL)
The amount of time an OTC quote is valid for, before it expires.
Trading Rules
A set of rules that market participants must follow to trade on an exchange.
Volume Weighted Average Price
A average price with individual prices weighted by the volume that was traded at that price.
Warehouse (Assets)
To store assets with the expectation of using them later.

Subscribe to the mailing list: