# Margin of Coin-margined Swaps

- Coin-M Perpetual Guides

Contracts margin is a good-faith deposit, or an amount of capital one needs to post or deposit to control a futures contract.

**Cross-margin mode is available in HTX Perpetual Swaps**

The position margin required varies with the price movements.

** **

**Calculation of Margin**

Position margin = (contract face value * quantities of contracts) / latest price / leverage ratio.

E.g.1 : If the user opens long 10 lots of BTC contracts (with contract face value of 100 USD/lot), the latest price is 5000 USD/BTC and leverage ratio is 10x, then,

Position Margin = (100*10)/5000/10=0.02BTC.

E.g.2 : If the user opens long 10 lots of EOS contracts (with contract face value of 10 USD/lot), the latest price is 5 USD/EOS and leverage ratio is 10x, then,

Position Margin =(10*10)/5/10=2 EOS.

**Differentiate Margin System**

In order to maintain the stability of the contract market and reduce the risk of large positions, HTX Futures uses a differential margin system. When the user chooses 20x or more than 20x leverage, and the user's account equity exceeds a certain range, the available margin will change. Choosing 10x and lower leverage will not be influenced by differential margin system. Details are showed as follow:

Unit: underlying asset

* As a example for BTC

**[searching trading limit of more trading pairs]**

【The above data and indicator contents may be adjusted in real time according to market conditions, and the adjustments will be made without further notice.】

For example, if the user's account equity is 50BTC, choosing 20x leverage, the available margin shall be 30 BTC. Therefore，the maximum amount of BTC that the user can use to open positions is 30.

Note: For maximum scale of Differentiate Margin System,

Available coefficient = 1 / Corresponding leverage

**Locked Margin Optimization Scheme**

To improve asset utilization and to reduce position margin for users, HTX Perpetual Swap implements locked margin optimization scheme when users have swaps with both long and short positions for the same coin.

When users have swaps contracts with both long and short positions for the same coin. →（same types asset）, locked margin optimization scheme could reduce part of users’ position margin. The formula is as below:

**New position margin for a single token = Long position margin for a single token + Short position margin for a single token - Optimization ratio for this token * Locked margin for a single token**

- Long position margin for a single token= abs [long position quantity of a single token* contract face value / contract latest price / leverages]
- Short position margin for a single token= abs [short position quantity (cont) of a single token * contract face value / contract latest price / leverages]
- Locked margin for a single token = min (Long position margin for a single token, Short position margin for a single token)
- The optimization ratio of locked margin is 100%.

Example:

Tom holds a long position of 1000 conts BTC Swap and a short position of 800 conts of BTC Swap both in 20x leverage. The face value of each contract is 100 USD. Assume the latest price of BTC Swap is 8000, the new position margin of Tom is calculated as following:

- Calculate Tom’s long and short position margin. According to the formula, Position margin = Face value * Position quantity / Latest price / leverage, then the Long position margin is 100 * 1000 / 8000 / 20 = 0.6250 BTC, and the short position margin is 100 * 800 / 8000 / 20 = 0.5000 BTC.
- Calculate Tom’s locked margin. According to the formula, Locked margin = min (Long position margin, Short position margin), then the locked margin is min ( 0.6250, 0.5000 ) = 0.5000 BTC.
- Calculate Tom’s new position margin. According to the formula, New position margin = Long position margin+ Short position margin – locked margin * optimization ratio of locked margin=0.6250 + 0.5000 - 0.5000 *100% = 0.6250 BTC.
- From above calculation we can get that in this optimization mechanism, the new position margin of Tom is 0.6250 BTC, which is much lower than its original 0.6250 + 0.5000 = 1.125 BTC.

**Calculation of Available Asset for Transfer**

**Available asset for transfer = max {0, Current-period initial equity + Current-period transfer_in quantity - Current-period transfer_out quantity + min (Realized PnL, 0) +min (Unrealized PnL, 0) - max [ 0, f(Occupied) - max (0, Realized PnL)]} + max {0, [Realized PnL - f (Occupied)]} * Available coefficient of realized PnL.**

Note: The available coefficient of assets settled periodically is 0, and the available coefficient of assets settled in real-time is 1.

Example 1: Assume Tom’s initial equity in BTC/USD swaps account was 1BTC, and bought 100 conts swaps of a long position with leverage 5X and open price of 10,000USD. When the latest price rises to 12,000USD, the available asset for transfer are calculated as below (transaction fees will be negligible):

Unrealized PnL = (1 / 10,000 - 1 / 12,000) * 100 * 100 = 0.1667 BTC;

f(Occupied) =Occupied margin= (100 * 100) / 12,000 / 5 = 0.1667 BTC;

Available asset for transfer = max [0, 1+0-0+0+0-0.1667] + 0 = 0.8333 BTC.

Example 2: Assume Tom’s initial equity in BTC/USD swaps account was 5BTC, and bought 10,000 conts swaps of a long position with leverage 100X and open price of 10,000USD. When the latest price reached 12,000USD, he closed 5,000 conts. Then the price declines to 9,000USD, at this time, the available asset for transfer are calculated as below (transaction fees will be negligible):

Unrealized PnL = (1 / 10,000 - 1 / 9,000) * 5,000 * 100 = -5.5556 BTC;

Realized PnL = (1 / 10,000 - 1 / 12,000) * 5,000 * 100 = 8.3333 BTC;

Occupied margin = (5,000 * 100）/ 9,000 / 100 = 0.5556 BTC;

However, when using the leverage 100X, the available margin is limited by the tiered margin and the corresponding available coefficient turns to be 20.00%, then the actual f(Occupied) needs to be calculated as below:

f(Occupied) =0.6 + (0.5556 - 0.4) / 20.00% = 1.3780 BTC;

Available asset for transfer = max [0, 5+0-0+0-5.5556-0] + [8.3333 - 1.3780] = 6.3997 BTC.

In conclusion, when the account equity exceeded a certain range and larger leverage used, the available margin will be restricted by the tiered margin. Then the occupied margin actually required becomes more, and the available asset for transfer becomes relatively less.

**Margin Ratio**

Margin Ratio is an indicator used to assess assets risk；

Margin Ratio = (Account Equity / Used Margin) * 100% - Adjustment Factor；

The lower of Margin Ratio, the higher risk of the account will be. When the Margin Ratio is ≤0%, liquidation will be triggered.