Crypto liquidity; price is not what it seems.

Share:

So I have been building automated trading algorithms for a number of years now and one of the first things I learned when I made my first automated trade was that the price I was expecting to pay for my coin was not the price I actually paid. The reason for this is down to two things: timing and order matching.

Firstly the timing effect is due to the fact that prices can fluctuate between the time at which you — or your algorithm — decide that a trade should be made and the time the order is matched and filled at the exchange. Therefore to reduce this effect your code should be optimised to run as efficiently as possible and to reduce network latency times, your hardware infrastructure should be located as close as geographically possible to the exchange servers. The aim is to minimise the time between the decision to place an order and the order being matched, however, once there are no more improvements to be gained through code optimisation and hardware infrastructure then there isn’t much else that can be done to address the timing effects.

It’s worth saying that we are talking about market orders here which are orders which are immediately matched with the best buy or sell prices in the order book, rather than limit orders which are not matched immediately and sit within the order book until they are, or canceled.

Secondly, and in my mind more significantly in my view, is the order matching effect or liquidity effect which can be best illustrated by a simple example (with some made-up figures):

The best buy price for BTC at exchange A is 23,000 USD per BTC, i.e a seller at exchange A is asking for 23,000 USD per BTC.

The best buy price for BTC at exchange B is 24,000 USD per BTC, i.e a seller at exchange B is asking for 24,000 USD per BTC.

So at first glance, it would make the most sense to purchase from exchange A since this offers the best (i.e. cheapest) price per BTC. However bearing in mind that a buyer of BTC needs to be matched with one or more sellers of the same coin (and vice versa), here is some additional information given that we want to purchase 1 BTC:

The two sellers offering the most competitive prices for their BTC at exchange A are willing to sell 0.2 BTC at 23,000 USD/BTC and 0.8 BTC at 27,000 USD/BTC. These are the top two sell orders sitting in the order book at exchange A and the prices they are asking for.

The two sellers offering the most competitive prices for their BTC at exchange B are willing to sell 0.4 BTC at 24,000 USD/BTC and 0.6 BTC at 25,000 USD/BTC. Again, these are the top two sell orders sitting in the order book at exchange B.

So which exchange should we buy from? If we bought from exchange A we would pay 26,200 USD (= 0.2 x 23,000 + 0.8 x 27,000) to purchase 1 BTC whereas if we bought from exchange B we would pay 24,600 USD (= 0.4 x 24,000 + 0.6 x 25,000). Therefore in fact it would be cheaper to purchase 1 BTC from exchange B, notwithstanding fee costs etc.

Hence, the price paid (or received) is a function of how much quote currency you want to purchase (or sell) and looking at price alone does not tell the whole story. Depending on your trading strategy it may be the case that you need to look at the order book itself to determine the anticipated price paid or received given the amount you want to trade.

Similar analysis can also be carried out by looking at historical trade data which will be the subject of a future post.

I’d be interested to hear your thoughts/experiences? In your own strategies, how do you take these liquidity effects into account, if at all?

This article was originally published here: https://www.fluidcrypto.com/2022/05/19/crypto-liquidity/