Liquidation and Deleveraging

Shanky
LEVERJ
Published in
13 min readOct 17, 2020

--

Leveraged futures trading allows a trader to punch above one’s weight. A trader could control large amounts in trade by depositing a much smaller amount of capital. Therefore, risk management is one of the most important pillars of leveraged futures trading.

Risks at High Leverage

At 20x leverage a trader is putting down only 1/20th of the notional value of a futures product. For the sake of illustration let’s assume the price of this futures product is $100 at the moment. At 20x, a trader deposits only $5 to buy, or go long, 1 unit of this product. $15 could give the trader control over 3 units or $300 worth of this futures product.

If the price goes up to $150, the trader could make a nice $50 profit per unit. By putting down only $5 for each of these units a $50 per unit profit is outstanding returns of 1000% on capital. Unbelievable, isn’t it! While, these types of 50% upward price movement doesn’t happen everyday, it’s certainly possible.

Putting this in a mathematical equation, positive returns for these types of long trades at leverage are as follows:

Percentage Returns = (Increase in Price/Initial Capital)*100

or in other words

Percentage Returns = Percentage Increase in Price*Leverage

Traders tend to be optimistic about price increase when they buy a futures instrument, i.e. when they go long. However, they do not control the prices or the way it varies. What if the price starts dropping instead? When the price is down by $1, the trader has an unrealized loss of $1. Continuing with our example, a price drop to $95 erodes the entire initial capital deposit of $5. At this moment it’s extremely risky to let the trader have his or her long position open. You could either ask for more capital deposit or you need to close the position.

In the world of derivatives, it’s customary to ask for additional deposit as the losses pile up. This deposit is commonly known as margin and the ask for additional deposit is termed “margin call”. It’s legally binding and traders agree to these terms when they decide to trade using leverage. In the world of crypto enforcing margin calls has been perceived as a challenging endeavor. Given that, on crypto derivatives platforms, a trader’s position is closed when it’s too risky.

In reality, one doesn’t wait for the entire capital to dry up but issues a margin call or closes a position when the margin or deposit is extremely low. How low is extremely low? This varies among exchanges and venues but its customary to consider values falling below maintenance margin as points when such actions are triggered.

Maintenance Margin

It’s the minimum amount of capital a trader needs to keep one’s position open. Anything below this value indicates risks beyond acceptable thresholds, leading to closing of the position.

Margin at Leverj

Now that you have looked at the essential ideas of leveraged trading and the risks involved in it, let’s get into the specifics of how Leverj Futures models and manages it.

On Leverj, there are currently two perpetual swaps, namely BTCUSD and ETHUSD, listed and available to trade. BTCUSD allows for a maximum leverage of 100x whereas ETHUSD goes as far as 50x.

Let’s consider the current price of ETHUSD to be around 366. You go long 1 contract of ETHUSD at a limit price of 366.6.

1 contract long at 366.6

Since there is an offer at that price you should see a match and will see a new position open for you.

Entering a long at 366.6

If you look at the far right of the image that depicts the newly opened position, you will find two columns that show values for margin. The “Initial Margin” column depicts what you initially put down and “Maintenance” depicts the required maintenance margin. You entered at 20x so the math is straightforward, 366.6/20 is 18.33. That’s the amount you put down, your initial margin.

ETHUSD allows maximum leverage of 50x. This means you could possibly have entered into this position for as low as 7.332.

At Leverj, every position you enter gets assessed for risks. Two important waterlines are measured and factored into the calculation of maintenance margin. These two levels are named, bankruptcy price and liquidation price.

Bankruptcy occurs when there is no margin left. That means, for the position you entered it is close to 348.27 (366.6 -18.33). 366.6 is the price you entered your position at and 18.33 is your initial margin. Why isn’t it exactly 348.27? The ETHUSD perpetual allows for a tick size of 0.1 so this value is adjusted for any dust cutoff and set at 348.3. Behind the scenes a lot of heavy lifting is done using high precision math and this calculation is dynamic basis the instrument’s supported tick size parameters.

Liquidation price is the second level and occurs a little before you reach bankruptcy. The maximum leverage allowed on the instrument affects this level. For ETHUSD, the maximum leverage is 50x. This means it’s way too risky when the margin mirrors a situation that is close to the hypothetical case of twice this maximum leverage. At this hypothetical case of 100x leverage (twice the maximum possible leverage), the margin required is 366.6/100, which is 3.666. Leverj’s risk engine rounds up this number to the nearest integer and subtracts it from your initial margin to calculate the liquidation price. That means liquidation price is around 14.33 away from your entry price. How did we get 14.33? Initial margin was 18.33 and at the hypothetical 100x leverage margin was 3.666. When you rounded up this hypothetical margin to the nearest integer, you get 4 and the difference between 18.33 and 4 is 14.33. The liquidation price is therefore around 352.27. Again adjustments are made for dust cutoff and the nearest integral value of 352 becomes the liquidation price.

If you see the image above (labeled “Entering a long at 366.6”), you will see a column called “Liquidation” with a value of 352 in it.

You now know the two important levels for the position in this example. Bankruptcy price at 348.3 and liquidation price at 352. To calculate the maintenance margin you use this simple and intuitive formula:

Maintenance Margin = ((Liquidation price - Bankruptcy price)/(Entry price Bankruptcy price))*Initial margin

In this particular example maintenance margin is equal to the following:

((352 - 348.3)/(366.6 - 348.3))*18.33 = 3.7060655 ~3.7061

If you look at the image above (labeled “Entering a long at 366.6”), you see exactly this number in the maintenance column.

Liquidation

Now that you understand the risks and the concepts of maintenance margin, bankruptcy price, and liquidation price, you are ready to dive into the mechanics of liquidation.

A liquidation engine is at the heart of the liquidation process. This liquidation engine assess the risks of all open positions across all users continuously and determines if any of them are deep in the water and a possible candidate for liquidation.

In our example, if the price moves and the index is at 352, then the liquidation engine will assess that this position is a candidate for liquidation. At that moment the liquidation engine will take over the losing position and close it. Once the liquidation engine takes over the position, it would put it on the order book and try and find an appropriate match.

To understand this better, let’s look at some historical records in the ledger and see an example where this played out. A great source to look at historical liquidation data is the Gluon explorer. Here is an image showing some liquidations.

Sample liquidation data from Gluon Explorer

If you notice this image carefully you will see that one side of the liquidation entry shows 0x0000000000000000000000000000000000000000 as the address. This is the liquidation engine and not the address 0 or the genesis address on Ethereum. 15.33 contracts of ETHUSD were liquidated as per this entry.

If you look into the details of the entry that records the liquidation for the account with address 0xE239Caeb4A6eCe2567fa5307f6b5D95149a5188F, you will notice the price at which it was liquidated. In this particular example the 15.33 contracts were liquidated at unit price of 358.36. Here is a portion of the screen showing this information.

Liquidation at 358.36

Within a second of liquidation, the liquidation engine found counter parties to trade that position off. The total position was 15.33 contracts, which was filled in two separate trades of 15.1 and 0.23.

Trades for the position liquidated

If you click through the details of the two trades, you will find that 15.1 was traded at a unit price of 358.9 and 0.23 was traded at a unit price of 359.6. Here are portions from the details screen that show the fill information.

15.1 filled at 358.9
0.23 filled at 359.6

Simple math reveals that while the liquidation engine paid 5493.6588 (15.33x358.36) it actually collected 5502.098 (15.1x358.9 + 0.23x359.6). In this particular case, the liquidation engine in its attempt to find the best match possible came out positive and was left with a small profit of 8.4392. Where does this one-off profit go? This sort of a profit is accumulated in an insurance fund that is to be used towards closing losing positions in future and avoiding the extreme case of deleveraging, where position is closed at the bankruptcy price. Insurance fund will be discussed in a subsequent post of its own. For now, its minuscule and not enough to save the day!

If you are left wondering what deleveraging is, the next topic will explain the concept and illustrate how it works with the help of an example.

Deleveraging

The liquidation engine makes all effort to find a good match for a position that is getting liquidated. It puts it on the order book and tries to find a suitable counter-party to trade with. However, it cannot keep looking endlessly for a match because prices change and the losing position may be getting further in the red. After a few seconds, if there is no match at the liquidation price or better, the position becomes a candidate for deleveraging, sometimes also referred to as auto-deleveraging or ADL for short.

When a position is way in the red and finds no match at liquidation price and continues to drop towards the bankruptcy price it is deleveraged. In order to do this successfully, the liquidation engine needs to find a counter-party to close this trade out. The obvious question is which counter-party should the liquidation engine pick and on what basis?

All open positions are ranked and the one that has the biggest profit with the highest leverage becomes a candidate for taking profits and becoming the counter-party. Let’s dig in a bit deeper to understand the specifics.

Long Positions

If the price is trending upwards and those in the short are getting liquidated and deleveraged then a corresponding long position with profit is identified as the opposing party. All long positions are ranked based on a formula that takes into account the entry price, which effectively determines how much of a profit they are in, and the amount of leverage they are using for this position. Remember, profit is the difference between current market price and the entry price. This ranking system implies that if there are two positions with the same entry price and the same profit, but one is at 20x leverage and another at 40x, then the one at 40x will be selected as the opposing party to close a position that is being deleveraged.

If you recall, the liquidation engine sometimes makes a profit and keeps that aside in an insurance fund. The engine makes a small contribution towards each closing deleveraged position to try and get a price better than the absolute rock bottom bankruptcy price for the trade.

Short Positions

When prices are falling and those with a long position are getting liquidated and deleveraged, it’s the short positions that are in the money. It is their turn to become the counter-party in a possible deleveraged trade. In a way, analogous to the situation described in the section on long positions, short positions are ranked basis entry price and leverage. Again, if you have two positions with same profit then the one with higher leverage gets picked as the counter-party.

In a deleveraged trade, the losing position is force closed and the chosen counter-party is forced to take profit and close their position.

Impact of Funding Payments

If you end up paying funding costs, please keep in mind that the amount impacts the notional value of your position. This means, every time you incur funding cost your notional value is proportionately increased and it impacts your liquidation price.

Let’s take a simple example and some approximate values to illustrate this impact. For exact calculations one will need to account again for dust cutoff basis the instrument’s supported tick size and any possible rounding off. Approximate values are very close to actual values and easier to illustrate so let’s stick with it for now.

Assume that you entered a long position at a notional value of 10,000 at 20x leverage. Then your initial margin is 500 (10,000/20) and your maintenance margin is around 50 (0.5% of the notional amount if the maximum possible leverage is 100x). Your liquidation price therefore is close to notional amount - net margin, which in this case is about 9550. Net margin is initial margin - maintenance margin.

Liquidation price is also impacted by maximum possible leverage for an instrument. This example assumes maximum leverage of 100x.

Given this position and the margin, if you incur a funding cost of 5 , then your new notional value becomes 10005. Your effective margin then becomes 450.225. This is obtained exactly the same way as in the previous paragraph. Margin becomes 500.25 and maintenance margin becomes about 50.025, net of which is 450.225. Your new liquidation price is 10005 - 450.225, which is 9554.775. After the funding cost of 5 , your new liquidation price therefore has moved by 4.775 against you in this specific example.

More about funding rates and payments is covered in a separate blog post. This same example was covered in that post as well.

Entering and Exiting Positions Over Time

For each perpetual swap on Leverj, you maintain only 1 net position at a given point in time. As you enter into newer trades for the same instrument, your actions get accumulated against this single net position. What does this have to do with liquidation? Well, if you enter different trades for the same instrument with different levels of leverage, then the effective margin at a given point in time is used to calculate your effective leverage. In addition, your entry price becomes the average of the different entry prices. We will attempt to illustrate the journey of a trader’s multiple trades and impact on leverage during the course of these actions in a subsequent post.

Adding and Removing Margin (or Changing Leverage)

Leverj empowers a trader to change leverage for an existing position. Let’s run through an example. Consider that your current position has an effective leverage of 21x. You feel it’s riskier than you would like it to be so you want to reduce it down to 15x. You can do this easily using the Leverj UI. See the images below.

21x leverage
15x leverage

This change of leverage causes your liquidation price to change from 352.5 to 346.3. That’s great! Now you have a bit more breathing room for this position to last through varying prices.

However, no such change is possible without adding additional margin. Remember that leverage and margin deposited are inversely related. Greater the leverage, lesser the margin and vice versa. By making this change, a user grants permission to draw additional margin from the balance. Leverj is a self custodial system, where only a user can move one’s assets. Therefore, this explicit step is necessary. Behind the scenes, a signed request is sent to withdraw additional margin. What happens if there isn’t sufficient balance to withdraw this additional margin? The request to change leverage of course fails in that case.

If a trader decides to increase leverage the effects are opposite. It may then be determined that you have more margin than you need to allocate to a particular position. Additional margin in that case will be credited to your Gluon account and you will see an increase in balance for the corresponding amount.

Summary

By now, you have most of the core concepts of liquidation and deleveraging in place. You also understand the mechanics of how liquidation and deleveraging works on Leverj. Remember, that leveraged futures trading involves effective risk management. Make sure to keep an eye on the liquidation price as your position risk changes through the underlying price movements. Set appropriate points to take profit or cut losses depending on your risk appetite and trading strategy.

Don’t hesitate to drop us a note in our Telegram channel if you have any questions.

Please keep in mind

US Persons are not allowed to trade on Leverj. Users from sanctioned country or Specially Designated National (SDN) as per OFAC are also not allowed to use the system.

Before you trade, please make sure you are legally permitted to trade cryptocurrencies, derivatives, and any other instruments offered on this platform from your home jurisdiction.

Nothing in this article constitutes an offer, solicitation, or investment advise. The content is for educational purposes only. Images and screenshots may be from our test environments and do not represent data on the live system.

Follow us:

Website | Twitter | Telegram | Reddit

--

--