# Account Margin Management

## browse

This article provides the necessary formulas and explanations to calculate and manage the margin requirements of your leveraged derivatives and spot margin positions.

# Examples

This example will walk you through the terms and formulas presented above, and calculate how much margin is required to open new derivatives and spot margin positions, and also determine at which margin fraction the positions and account would be liquidated.

Assume that your subaccount has \$50,000 USD and 2.5 BTC in collateral, max leverage has been set to 10x, and also spot margin has been enabled. We will open the following positions in this order and finalize the example by calculating our Account IMF and MMF:

2. Short LTC/USD using spot margin
3. Sell ETH-9030 (short)

## Opening and Managing a Futures Position

Before opening the 20 BTC-PERP long position, here’s an overview your account's collateral.

Total Account Value

The account has the following in collateral:

• USD = \$50,000
• BTC = 2.5 (\$50,000 at current prices assuming BTC/USD is trading at \$20,000)
• Total collateral value (in USD) = \$100,000

In theory, your total collateral value in USD is \$100,000 when we add up the USD and the current value of the BTC balance. However, FTX accepts a wide variety of non-USD assets as collateral, and each of them have different collateral weights for opening new positions and managing existing positions (more info here).

In the case of BTC, it has an initial collateral weight of 0.95, which means that for opening new positions, your 2.5 BTC would be worth \$47,500 rather than the full \$50,000 after applying the haircut. However, since spot margin is enabled for this subaccount, BTC’s total weight of 0.975 will be used to determine the value of your collateral to open new positions, as well as when the position is already open once the position is opened (if spot margin is disabled, Total Weight is only used for the latter).

Therefore, the total unused collateral available for opening new positions is \$97,500. Here's a full overview of the account's collateral:

 Collateral Overview Collateral USD BTC Total Amount 50,000 2.5 50,003 Mark Price \$1 \$20,000 - USD Amount \$50,000 \$50,000 \$100,000 Initial Weight 1 0.95 - Initial Collateral \$50,000 \$47,500 \$97,500 Total Weight 1 0.975 - Total Collateral \$50,000 \$48,750 \$98,750

### Calculating IMF - Determining how much collateral/margin is needed to open a position

To calculate the Initial Margin Fraction for the BTC-PERP position, we use the following formula:

Position IMF = MIN (MAX [Base IMF , IMF Factor * sqrt {position open size in tokens}] * IMF Weight, 1 + fee rate * [short size + long size] )

= MIN (MAX [1/10 , 0.002 * sqrt {20} ] * 1, 1 + 0.0005 * [0 + 20] )

= MIN (MAX [0.1 , 0.004], 1.01)

= 0.1 = 10%

So if we want to go long 20 BTC-PERP and each BTC-PERP is trading at \$20,000, for a Position Notional of \$400,000, we will need at least \$40,000 in collateral to open the position.

The account has enough collateral, so we go ahead and open the position.

Note about factors that influence IMF:

Keep in mind that your position’s IMF can increase (i.e. reducing your max leverage to open that position) based on the factors included in the formula, including position size, IMF factor, and IMF weight.

As an example, imagine you’re trying to open a 5000 BTC-PERP short position worth \$100,000,000 (assuming BTC-PERP is trading at \$20,000). Using the same formula:

Position IMF = MAX (1/10 , 0.002 * sqrt [5000] ) = MAX (0.1 , 0.141 )

Position IMF = 0.141 = 14.1%

So, even though your max leverage is 10x (making your Base IMF 10%), because you are trying to open a large position worth \$100,000,000, your initial margin requirement increases to 14%. There can be cases where the IMF is above 100%. Keep in mind however, that this is only possible with short positions, as the IMF for long positions is capped at 100%.

### Managing Position - Calculating Maintenance Margin Fraction

After opening the 20 BTC-PERP position, your Margin Fraction is as follows:

= Total Account Value / Total Position Notional

= \$98,750 / \$400,000

= 24.69%

Now, let's calculate your Maintenance Margin Fraction to understand at which point the position would start getting liquidated (assuming that’s the only open position in the account. We will explore how multiple positions affect your account's MMF and IMF later on in this example).

MMF = max(3%, 0.6 * IMF Factor * sqrt [position open size in tokens]) * MMF Weight

= max (3%, 0.6 * 0.002 * sqrt[20] )) * 1

= 3%

### Opening and Managing Spot Margin Position

Next, we’re now going to short 200 LTC @ \$50 on the LTC/USD market using spot margin. Keep in mind that IMF formula for spot margin positions is different than the formula for derivatives.

Calculating Spot Margin IMF

Because you're shorting LTC, that means that you're going to borrow LTC in order to sell it. When borrowing non-USD assets, the Spot Margin Base IMF formula is as follows:

= max ( 1 / max account leverage, 1.1 / Total Weight - 1 )

= max (0.1, 1.1 / 0.95 - 1)

= 15.79%

Now that we know the Base IMF, we can go ahead and calculate the Spot Margin Position's IMF:

= max( Spot Margin Base IMF, IMF factor * sqrt [position size in tokens] ) * IMF Weight

= max (15.79%, 0.0004 * sqrt [200] ) * 1

= max (15.79%, 0.4%)

= 15.79%

This means that we need \$1,579 in collateral in order to open the 200 LTC @ \$50 spot margin short.

Calculating Spot Margin MMF

Because you’re borrowing LTC in this case and not USD, we use the following formula:

= max ( 1.03 / Total Weight - 1, 0.6 * IMF factor * sqrt [position size in tokens] ) * MMF Weight

= max ( 1.03 / 0.95 - 1, 0.6 * 0.0004 * sqrt [200] )

= max (8.42%, 0.34%)

= 8.42%

## Calculating Free Collateral

Let's see how much collateral your two positions are currently taking up and ultimately how much free collateral there is in the account for opening another position.

Starting with the 20 BTC-PERP, assuming each BTC-PERP is still trading at \$20,000, this is how much collateral the position is currently taking up:

Collateral Used = Position IMF * Position Notional

= 10% * \$400,000

= \$40,000

The same is done with the LTC/USD spot margin short:

= 15.79% * \$10,000 = \$1,579

How Spot Margin positions affect collateral and margin

By opening the 200 LTC/USD spot margin short, you are borrowing 200 LTC, which creates a negative spot balance of -200 LTC. In addition to requiring margin, negative spot positions also decrease your account collateral value (more information can be found in this article). Also, because you essentially sold 200 LTC at a price of \$50, your USD balance also increased by \$10,000.

This is how your balance currently looks after opening the BTC-PERP and LTC/USD spot margin positions:

 Current Collateral Overview Asset Size Mark Price Initial Weight Initial Collateral Total Weight Total Collateral USD 60,000 \$1 1 \$50,000 1 \$50,000 BTC 2.5 \$20,000 0.95 \$47,500 0.975 \$48,750 LTC (borrow) -200 \$50 - -\$10,000 - -\$10,000 Total Collateral 49,803 - - \$97,500 - \$98,750

Now, let’s see how much free collateral there is currently on the account:

 Market Position Size Mark Price Position Notional IMF % MMF Collateral Used BTC-PERP 20 \$20,000 \$400,000 10% 3% \$40,000 LTC/USD 200 \$50 \$10,000 15.79% 8.42% \$1,579 Total (sum) 220 - \$410,000 - - \$41,579

 Total Collateral \$98,750 Total Collateral Used \$41,579 Free Collateral \$57,171

This means that there is \$57,171 in free collateral after deducting the amount of collateral being used by your open positions, as well as the negative balance from our LTC/USD spot margin short.

Before calculating the Account IMF and MMF, let’s long 25 ETH-0930 contracts using the remaining free collateral in the subaccount. Assuming each contract is trading at \$2000, the Position Notional would be \$50,000.

Same as before, let’s calculate the Position IMF:

Position IMF = MIN (MAX [Base IMF , IMF Factor * sqrt {position open size in tokens}] * IMF Weight, 1 + fee rate * [short size + long size] )

= MIN (MAX [1/10 , 0.0004 * sqrt {25} ] * 1, 1 + 0.0005 * [0 + 25] )

= MIN (MAX [0.1 , 0.002], 1.0125

= 0.1 = 10%

That means there must be at least \$5,000 in collateral in order to open the position. There is enough collateral, so we go ahead and open the position. Now, let's calculate the position's MMF.

Position MMF:

= max (3%, 0.6 * 0.0004 * sqrt[25] )

= 3%

## Account IMF and Account MMF

At this point, we have 3 positions open, equalling to a Total Position Notional of \$460,000. The Total Account Value remains at \$98,750 (we're assuming prices haven't changed at all).

### Calculating Account IMF and Account MMF

These will be equal to the average IMF/MMF of all our open positions within the subaccount, weighted by their position notional size.

To do that, we first calculate the Weighted IMF and MMF for each position:

= (Position notional / total position notional) * Position IMF or MMF

As an example, let’s calculate the Weighted IMF for our BTC-PERP position:

= (\$400,000 / \$460,000) * 10%

= 8.7%

After we calculate that for each of the positions, we then sum the results. Here’s the final result:

 Market Position Size Mark Price Position Notional IMF % MMF Collateral Used Weighted IMF Weighted MMF BTC-PERP 20 \$20,000 \$400,000 10% 3% \$40,000 8.70% 2.61% LTC/USD 200 \$50 \$10,000 15.79% 8.42% \$1,579 0.34% 0.18% ETH-0930 25 \$2,000 \$50,000 10% 3% \$5,000 1.09% 0.33% Total (sum) 245 - \$460,000 - - \$46,579 10.13% 3.12%

Here’s a summary of our account after opening the three positions:

 Total Collateral \$98,750 Margin Fraction 21.47% Total Collateral Used \$46,579 Account IMF 10.13% Free Collateral \$52,171 Account MMF 3.12%

### Auto-Close Margin Fraction (ACMF)

ACMF is the margin fraction at which your account would be completely liquidated. To calculate this, we use this formula:

ACMF = max(MMF / 2, MMF - 0.06)

= max( 0.036 / 2, 0.036 - 0.06 )

= 1.53%

So, if your Margin Fraction drops below 1.53%, all of your positions within the subaccount would be instantly liquidated.

### Zero Price

Zero Price (ZP) is the price that would cause your account to get completely liquidated.

ZP = Mark Price * (1 - Margin Fraction) if long, Mark Price * (1 + Margin Fraction) if short.

BTC-PERP Long = \$20,000 * (1 - 21.47%) = \$16,141

LTC/USD Short = \$50 * (1 + 21.47%) = \$60

ETH-0930 Short = \$2000 * (1 + 21.47%) = \$1,614

## Open Orders & Open Margin Fraction

In all of the examples above, we had no open (unfilled) orders before we tried to open new positions. Open orders affect your free collateral and margin, so it’s important to understand the role they play here. To do this, let’s calculate your Open Margin Fraction.

Let’s assume your 3 positions are still open and prices have not changed at all, which means that your Free Collateral is still \$52,171.

Now, we’re going to open the following BTC-PERP limit orders:

• Long 2 BTC-PERP @ \$19,500 (\$39,000 notional)
• Sell 5 BTC-PERP @ \$21,000 (\$105,000 notional)

To start, let’s calculate the Open Position Size:

= MAX (ABS [position size + open long orders], ABS [position size - open short orders] )

= MAX ( ABS [20 + 2] , ABS [20 - 5] )

= 22

Using the current mark price for BTC-PERP, we calculate the Position Open Notional:

= Open Position Size * Mark Price

= 22 * \$20,000

= \$440,000

Then, we aggregate all open orders and open positions in the subaccount to calculate the Total Open Position Notional:

Position Open Notional:

• BTC-PERP = \$440,000 (includes our Open Position Size, as explained in the example above)
• LTC/USD = \$10,000 (no open orders here, so stays the same)
• ETH-0930 = \$50,000 (no open orders here, so stays the same)

Total Open Position Notional = \$500,000

Now, using what we calculated above, let’s calculate the Open Margin Fraction (OMF):

= MAX (0, MIN [Total Account Value, Collateral] ) / Total Open Position Notional

= MAX (0, MIN [\$98,750, \$98,750] ) / \$500,000

= \$98,750 / \$500,000

= 19.75%

The OMF (your Margin Fraction with open orders included) is 19.75%. The Account IMF is 10.13%, which means that you can still open more positions.

## Notes:

• sum(value1, value2,..) = sum total of the values within the data set provided
• max(value1, value2,..) = the maximum value within the data set provided
• min(value1, value2,..) = the minimum value within the data set provided
• abs(value) = the absolute value of the data provided
• Open position means that the position has been filled and has not been closed yet. Open order means that that the order has been submitted, but has not been filled yet.
• Mark price = median of best ask, best bid, and last traded price.