How to calculate margin?

Introduction

Margin = Collateral + uGnL + eGnL

uGnL :Unrealized Gains and Losses; eGnL :Estimated Gains and Losses.

  • Margin Requirements are requirements on margins for the user to perform certain actions.
  • Initial Margin is required to increase a position.
  • Maintenance Margin to keep a position.

Margin Impacts

Positions and orders all require a certain amount of margin and, at the same time(同时), impact(影响) available margin. In the table above, we categorize positions and orders and show how their requirements and impacts are determined when considered separately.

Under margin impact, we further classify different impacts into 3 sub-categories: settled, unsettled, and probable.

  • Settled margin impacts have already been settled. So to calculate available margin, settled margin impacts should be left out(忽略,不考虑), as they have already been incorporated(合并的) into collateral balance.

  • Unsettled margin impacts are unrealized PnL, accrued interests, and fee, unsettled, but payable if a settlement occurs right away.

  • Probable margin impact consider a probable scenario or a possible scenario where most negative impact happens.


Container

A container is a collection of positions and open orders under the same Portfolio, sharing the same margin pool in their common settlement currency.

Under a portfolio, positions settled in the same currency will be collected into the same container with a communal margin shared among them. A winning position’s unrealized profit adds to collateral, bolsters(支持,支撑) the shared margin, and helps avoid liquidation of other losing positions in the container.

To segregate positions settled in a common currency, consider allocate them to different portfolios.

Aggregate(总体的,合计的) Requirements & Impacts

Aggregating margin requirements and impacts at the portfolio level isn’t simply adding them up. Instead, it is another exercise of finding out the worst scenario(情形,情况) that demands the most collateral. The aggregation is done at 2 layers.

Contract Level

At the contract level, we collect all orders and position for the contract and then:

  1. Convert incoming market orders into incoming limit orders;
  2. Categorize open orders and incoming limit orders buy orders and sell orders;
  3. With everything else (market price, model price, etc.) held equal, consider 2 scenarios
    1. All buy orders filled at their limit prices;
    2. All sell orders filled at their limit prices;

Given current position holdings, either of the scenarios where a bigger collateral is demanded shall be considered in checking margin sufficiency and determining free collateral.

In the expression above, subscript o denotes orders on either buy or sell side. The scenario under which the expression evaluates to be bigger, In the following calculation.

At contract level, the required margin and margin impact are the following formula evaluated in the worse scenario.

Portfolio Level

At the portfolio level, contracts are grouped by their settlement currency into containers. So the Required Margin and Margin Impact for a portfolio and specific settlement currency, is the summations of contract level RM and MI.

Margin Sufficiency

When checking for margin sufficiency at portfolio level (i.e. container level), we simply evaluate the inequality below across contracts under the container in question.

The left hand side is simply collateral adjusted by margin impacts from positions and their related orders in the container.

The right hand side of the inequality computes the required margin for the container by summing up the required margin for each contract.

Free Collateral

Free collateral is the amount of collateral that can be removed from a container. Removing such amount must not:

  • Immediately cause liquidation or auto deleveraging of positions in the container;
  • Cause the container to be insufficient for the initial margin requirement;
  • Exceed the total collateral in the container.

So the free collateral value for a container is the smaller of the 2 values below:

Margin Coverage

Margin coverage ratios show how much margin one has to cover the margin requirements imposed on a container. They are defined as IMC and MMC.

When a container’s IMC falls below 1, a trader will not be able to increase the size of positions in it. And so on our trading terminal, when IMC falls lower than 1, its indicator will lit up in red.

When a container’s MMC falls towards 1, a liquidation looms imminent. Unlike IMC, which can stay below 1 for a period, once MMC touches 1, liquidation kicks in and almost instantly brings MMC above 1. To warning users about the approaching liquidation, we lit the MMC indicator in red when the following ratio falls below 1.