### 개요

The foundation of the margin calculation uses a parametric VaR approach, also referred to as the variance-covariance method. The advantage of VaR is that the risk and hence required initial margin can be calculated for a portfolio of assets where the correlation/offset between assets are factored into the margin calculation. This is especially relevant for our spread order books. Specifically with this method we have full control over the model inputs allowing the exchange to fully control the amount of allowable leverage per asset whilst retaining the ability to lower the initial margin requirement through portfolio offsets (e.g. long vs short positions).

### Objectives

The Risk Engine serves the following purposes:

- To perform pre-trade validation for incoming client orders. There are three main checks which must be satisfied before an order can be submitted to the trade engine. If these checks are not passed then the incoming order is rejected:
- If the incoming order is a limit order, will the limit price exceed the sanity price bounds? (all incoming market orders will be set a limit price equal to the upper or lower price bound depending if the order is a bid or an ask)
- Will the incoming order exceed the maximum position limit set by the exchange?
- Will the incoming order allow the clients portfolio to remain margin compliant, above the maintenance margin level?

- To perform on-going real time margin risk calculations of every client account. If a clients account no longer satisfies margin compliance then this will trigger a liquidation event for the account.
- To perform a risk check of the source account when a user attempts to withdraw assets off exchange to a destination wallet OR transfer of assets to a different destination sub-account owned by the same user (i.e a user triggered internal transfer).
- To perform a risk check of the account when a user attempts to nominate a position and spot balance for delivery to ensure remaining positions are still margin compliant.

### Sanity Price Bounds (Price Banding)

Price bounds is a mechanism which subjects all incoming orders to price validation and rejects orders outside the given price band to maintain orderly markets. The bands are calculated dynamically for each order book based on an external price index formula defined by the exchange. Thus, if markets quickly move in one direction, the price bands dynamically adjust to accommodate new trading ranges.

### Accounts and Sub-Accounts

Each user’s master account and sub-accounts are margined separately and independently. Balances, collateral and limits are currently not aggregated across accounts, which means that within a single sub-account all positions and working orders are margined as a portfolio using all the balances contained in that sub-account as collateral. This also means that users can only lose collateral from a trade(s) limited to the sub-account itself from which the trade(s) originated from. Therefore if users want isolated margin then its as simple as creating a new sub-account for this self contained trade(s)/position(s) and supporting collateral.

### Margin Calculation

The level of risk in a portfolio is usually measured using standard deviation, which is calculated as the square root of the portfolio variance. The portfolio variance is determined by a weighted combination of the individual variances of each of the positions adjusted by their co-variances. For our purposes the individual variances are replaced by the inverse of the leverage offered by the exchange (e.g. 10x = 0.1). Also, for the purposes of calculating a USD based initial margin figure the weights of the portfolio are the USD valuation of each position in the portfolio.

The full formula is as follows:

For details regarding the leverage and correlation values set by the exchange please see the support pages “3.8 Perpetual Contract Limits”、“3.9 Futures Contract Limits”、“3.10 Correlations”

#### Margin Calculation Example

For a simple portfolio with only two positions:-

Market | Position | Current Mark Price | Max Leverage |

BTC-USD-211231-LIN | +1 | 65,000 | 100x |

BTC-USD-SWAP-LIN | -1 | 60,000 | 100x |

** correlation is 0.7 between these two markets for the 100x leverage tier*

This is an example of a long spread position for the BTC-Dec21 – BTC-Perp spread. Portfolio margin is calculated by the following, derived from the general formula described in the documentation above:-