Introduction

Slippage data is a crucial metric that many traders use to measure liquidity. In the cryptocurrency markets, measuring liquidity across pairs or exchanges is a common method of assessing the risk level of a particular pair or exchange. Additionally, it can help traders identify pairs or exchanges that may offer better order-fill prices. Two other common and simpler methods for evaluating liquidity are bid/ask spreads and volume. While these metrics can give traders a general idea of market liquidity, they don't offer the same level of detail as slippage data.

Orderbook slippage refers to the situation where a trader places a large market order on an

exchange and incurs an additional cost, known as slippage, over and above the commissions paid

(commissions are separate from the slippage calculation). This cost arises when there needs to be more liquidity in the market to fill the entire order at the best available price. For example, if a trader placed a $100k market buy order on an exchange, the order may not be filled at the lowest ask price, but at a slightly higher market price, leading to negative slippage costs.

As shown in the previous order book figure, generated using Amberdata's Snapshots Historical Orderbooks Endpoint from our Spot Market Data API, a market buy order of $100k for ETH/USD would likely result in a higher price than the lowest ask due to the order's size, demonstrating the impact of slippage.

Now that we understand what slippage is, let's take a closer look at how it is calculated. By understanding the formula and variables that impact slippage, traders can better prepare for and mitigate the costs associated with executing large market orders. In the following section, we'll use the same endpoint from our Spot Market Data API to compute slippage for a particular exchange and currency.

## Calculating Slippage

Rather than relying on the average order fill price of an order book, which can be a rough and

non-weighted representation of the fill price, we utilize a quantity-based distribution that removes any assumptions of the price distribution. The use of an average price-based approach, without considering quantity, may overlook the actual size in which an order is filled. In contrast, our quantity-based approach accounts for the distribution of the amount received for each market price level, allowing us to reference the real amount of a security received in exchange for a currency. As a result, this approach enables us to obtain real historical slippage values instead of projected historical slippage values.

These are two formulas for calculating percent slippage for buy and sell orders on an exchange.

Slippage is the difference between the expected trade price (lowest ask price or highest bid price) and the actual execution price of the filled portion of the trade.

### Buy Order Slippage % Calculation:

### Sell Order Slippage % Calculation:

### Percent slippage is calculated in a few steps:

The first formula is used when buying a security. If the amount of money that a crypto trader is willing to spend (the "Initial Capital") minus the total cost of purchasing the desired amount of the security (the "Ask Size" times the "Ask Price" at each time) is less than zero, the trader has incurred slippage. In this case, the formula calculates the percentage of slippage as a fraction of the initial capital, and it takes into account the total amount of a security purchased (the "Ask Size") as well as the difference between the initial capital and the total cost of the security purchased. Specifically, the formula computes the ratio of the initial capital to the minimum ask price and divides that by the sum of the ask sizes and the difference between the initial capital and the total cost of the security purchased divided by the asking price. If the trader did not incur slippage, the formula outputs 0.

The second formula is used when selling a security. If the amount of money that a trader would

receive from selling the desired amount of the security (the "Bid Size" times the "Bid Price" at each time) minus the amount of money the trader expects to receive (the "Initial Capital") is less than zero, the trader has incurred slippage. In this case, the formula calculates the percentage of slippage as a fraction of the initial capital, and it takes into account the total amount of security sold (the "Bid Size") as well as the difference between the initial capital and the total revenue from selling the security. Specifically, the formula computes the ratio of the initial capital to the maximum bid price and divides that by the sum of the bid sizes and the difference between the initial capital and the total revenue from selling the security divided by the bid price. If the trader did not incur slippage, the formula outputs 0.

## Visualizing Slippage

Having discussed how slippage is calculated, we will now explore various ways to analyze slippage data in cryptocurrency markets. In the following examples, we will examine the slippage for $1 million buy/sell orders on Binance for the ETH/USDT trading pair.

In this figure, order book slippage is visualized historically over 4-hour intervals from January

2022 to today. The slippage data is aggregated using the mean values of 1-minute granularities. Sell slippage is plotted in red, while buy slippage is plotted in green. It is worth noting the historical spikes in slippage that have occurred in the past. These spikes may indicate periods of extreme market volatility or at least volatility for the ETH/USDT trading pair. In periods of extreme market volatility, it is typically the case that one or more of the following conditions hold true: high trading volumes, rapid price movements, and low market liquidity.

## Visualizing Slippage, Volume, Hist. Volatility and Imp. Volatility via Heatmaps

These heatmap plots evaluate the time of day vs. the day of the week where buy/sell slippage

values are highest. These plots reveal a clear pattern in which slippage is generally higher on weekdays than on weekends, given that the heatmaps are darker during the week, especially during US market hours (between 13:30 UTC and 20:00 UTC). Both buy and sell order slippage values appear to be very similar to one another. The lower slippage on weekends may suggest that order books are tighter during those periods, resulting in larger orders being filled with less slippage. Overall, these findings suggest that weekends may offer more favorable trading conditions for traders who are seeking to minimize slippage. To validate these results, we will examine heatmaps for trade volume, historical volatility, 24-hour historical volatility (365-day annualized Parkinson volatility), and implied volatility, which will enable us to visually assess our findings.

Both volume, 24-hour historical volatility (Parkinson), and at-the-money 7-day implied volatility

all follow a similar pattern, with higher deviated values occurring during the week instead of the

weekend. Given the visual correlation between slippage, volume, historical, and implied volatilities,

slippage likely represents a decent gauge for market price volatility. In order to test statistical correlation,

however, we must evaluate regression plots.

## Regression Analysis

After analyzing the relationship between slippage and 24-hour historical volatility (Parkinson) through two standard regression plots, it's evident that there is a strong correlation between the two

variables. The correlation coefficient between % sell order slippage and historical volatility is 0.734, while for % buy slippage, it's 0.732. The correlation coefficient is a statistical measure that indicates the strength and direction of a linear relationship between two variables. It ranges from -1 to 1, with -1 indicating a perfect negative correlation, 1 indicating a perfect positive correlation, and 0 indicating no correlation. In this case, the high positive correlation coefficients suggest that there is a strong positive relationship between slippage and historical volatility, yet this does not prove causation.

Similarly, there is also a strong positive correlation between slippage and at-the-money 7-day implied volatility, which calculates the 7-day implied volatility of Deribit’s ETH options market. The

correlation coefficients between % sell and buy slippage and implied volatility were 0.707 and 0.706, respectively. This indicates that slippage and implied volatility have a strong positive relationship, which can be useful in understanding a volatile market.

Contrary to initial expectations, the correlation between slippage and trading volume was not as

strong. The correlation coefficients for volume against % sell and buy order slippage were only 0.426 and 0.435, respectively. This suggests that factors other than trading volume may be contributing to slippage in the market.

## Underlying Market Price Comparison

Given that slippage is highly correlated to historical and implied volatility, next we’ll compare each of the correlated results to the ETH/USDT 1-hour close prices. Rather than directly overlapping line charts against one another, the close price will be filled and color-coded using percentiles to give us a general glimpse of ETH/USDT performance during different periods of slippage, historical, and implied volatility.

This plot yields a very interesting narrative. When we compare buy order slippage against 1-hour

close prices, a common trend appears in both low and high-percentile areas. For low-percentile areas, percentiles less than or equal to 25%, ETH/USDT tends to rally or signal an upcoming rally. Notably, during April 2022, October 2022, and January 2023, all of these conditions hold true. Whereas, high-percentile areas, percentiles greater than or equal to 75%, tend to indicate a short-term market bottom. In this case, February 2022, May 2022, June 2022, and November 2022 held these “market-bottoming” conditions true as well.

The results for sell order slippage, which is similar to the buy order slippage shown in the previous plot, are nearly identical. Markets with low slippage tend to rally, while those with high slippage tend to experience troughs. Given that both buy and sell order slippage tend to align with momentum in ETH/USDT, it may be quite valuable to align this metric with other indicators to forecast short-term market direction.

## Volatility Comparison

Comparing buy order slippage to the 24-hour historical volatility (Parkinson), slippage tends to also be low during periods of low historical volatility. For volatility traders, low buy order slippage data might be a worthy signal of shorting volatility. Not to mention, on an execution aspect, volatility traders are likely to receive better fill prices on their orders during low-slippage events due to tighter order book depths and increased liquidity.

Similar to the previous buy order slippage plot against 24-hour historical volatility (Parkinson), sell order slippage compared to 24-hour historical volatility also yields a similar result with increased periods of volatility during high-percentile periods and decreased periods of volatility during low-percentile periods.

At-the-money 7-day implied volatility, similar to the previous 24-hour historical volatility described in the previous plots, tells the same story. When the % sell order slippage is below the 25th percentile, implied volatility remains flat. Whereas, when the % sell order slippage is above the 75th percentile, volatility is heightened.

% Buy order slippage, just like % sell order slippage, also yields a similar plot, where low slippage occurs when at-the-money 7-day implied volatility is suppressed, and where high slippage occurs when implied volatility is heightened.

Conclusion

In conclusion, order book slippage is a valuable metric that crypto traders can use to measure liquidity and assess risk in the cryptocurrency markets. By understanding the calculation of slippage and analyzing it in various ways, traders can better prepare for and mitigate the costs associated with executing large market orders.

The findings of this article reveal a strong correlation between slippage and historical volatility and implied volatility, suggesting that slippage can potentially be used as a gauge for market volatility. Additionally, the analysis of buy and sell order slippage in comparison to 24-hour historical volatility and at-the-money 7-day implied volatility show that low slippage tends to occur during periods of low price volatility, while high slippage is associated with heightened volatility. Coupled with other indicators, these results suggest that slippage can be a useful tool for traders in forecasting short-term market direction.

Access to Code

In order to further the understanding of this report, the Python code used for this analysis can be accessed from the following GitHub repository:

Link:

https://github.com/tprahm/tyler-blog-posts/blob/main/orderbook_slippage_aggregation.ipynb

This Jupyter Notebook includes all the necessary code and comments to help you understand how the data was collected, how the analysis was performed, and how the visualizations were created. Feel free to explore, modify, and use this code as a basis for your own investigations.