> For the complete documentation index, see [llms.txt](https://docs.koo.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.koo.xyz/risk-and-liquidations/continuous-risk-limit-and-margin-check.md).

# Continuous Risk Limit & Margin check

The **Continuous Risk Limit** framework utilizes a dynamic maximum open position algorithm that directly links allowable position sizes to total account margin and selected leverage. This implements a **continuous (non-tiered) risk limit model**:

* **Higher Leverage → Scaled Position Capacity:** As available margin increases and leverage rises, the maximum open position size scales up smoothly.
* **Seamless Automation:** Users no longer need to manually select or upgrade risk limit tiers. The system automatically computes maximum allowable position sizes based on total account margin and selected leverage, delivering a more flexible and efficient trading experience.

***

### 1. Maximum Open Position Quantity

#### 1.1 Calculation Formula

$$\text{Max Position Size} = k \cdot \ln\left(\frac{(C - F) \cdot \text{Lev}}{P \cdot k} + 1\right) - \text{Same Diretion Orders/Positions Size} + \text{Opposite Diretion Positions Size}$$

**Parameter Definitions:**

<table><thead><tr><th width="179.29296875">Parameter</th><th>Meaning</th></tr></thead><tbody><tr><td>C</td><td>Total account margin.</td></tr><tr><td>F</td><td>Margin occupied by positions and active orders in other trading pairs (C - F) represents available margin for the current pair).</td></tr><tr><td>Lev</td><td>Maximum allowable leverage for the target trading pair.</td></tr><tr><td>P</td><td>Estimated execution price (approximated by limit price; actual engine calculations incorporate order book depth and fee rates).</td></tr><tr><td>k</td><td>Scaling coefficient ensuring that position size increases with leverage at a diminishing rate for a given available margin. $k$ is set and adjusted per pair by the platform.</td></tr></tbody></table>

***

#### 1.2 Calculation Example

**Conditions:**

* **Contract:** BTCUSDC
* **Order Price (P):** 60,000 USDC
* **Leverage (Lev):** 10×
* **Account Margin (C):** 100,000 USDC
* **Other Pairs Margin Occupied (F):** 0 USDC
* **BTCUSDC k Factor:** 490
* **Open Order/Position Size: 0**

**Calculation Process:**

$$\text{Max Position Size} = 490 \times \ln\left(\frac{100{,}000 \times 10}{60{,}000 \times 490} + 1\right) \approx 16.39 \text{ BTC}$$

*Note: The relationship curve between available margin and max open position size scales smoothly following a logarithmic growth pattern*

<figure><img src="/files/zTT0VaFgPIY9c85hfPhK" alt=""><figcaption></figcaption></figure>

***

### 2. Initial Margin Rate (IMR) & Maintenance Margin Rate (MMR)

Under this continuous algorithm, IMR and MMR calculations adjust dynamically and smoothly alongside position and order scaling, eliminating abrupt step-wise tier jumps.

#### 2.1 Initial Margin Rate (IMR)

In most scenarios, IMR correlates inversely with leverage:

$$\text{IMR} = \frac{1}{\text{Leverage}}$$

To prevent IMR from sitting too close to MMR (which could cause minor market fluctuations to immediately trigger forced liquidation), IMR must also satisfy $\text{IMR} \ge 1.3 \times \text{MMR}$:

$$\text{IMR} = \max\left(\frac{1}{\text{Lev}}, 1.3 \times \text{MMR}\right)$$

> **📌 Key Takeaway:** As position size grows, MMR increases, which dynamically scales up IMR. Consequently, the effective maximum leverage will naturally taper below the theoretical maximum leverage for larger positions.

***

#### 2.2 Maintenance Margin Rate (MMR)

MMR is primarily determined by a user's open position size and active order volume. As position/order volume scales up, MMR increases continuously.

**Formula:**

$$\text{MMR} = \left(1 + \frac{N}{m}\right) \times \frac{1}{2 \times \text{Lev}}$$

**Parameters:**

* **N:** Current total quantity held by the user (open positions + active open orders).
* **m:** Upper limit coefficient configured per trading pair.

**Example:**

If a user holds **1 BTC** at **100× leverage** with m = 300:

$$\text{MMR} = \left(1 + \frac{1}{300}\right) \times \frac{1}{2 \times 100} \approx 0.5017%$$

***

### 3. Dynamic MMR & Liquidation Optimization

The continuous risk limit framework uses a dynamic MMR mechanism to significantly reduce unnecessary force-liquidations:

* **MMR Capped at 50%:** As long as total account equity remains healthy, normal market noise will not trigger premature forced liquidations.
* **Lower MMR Requirements for Major Assets:** Capital efficiency is maximized for high-liquidity assets (e.g., BTC, ETH) by reducing unnecessary margin lockups.
* **Equity Recovery Protection:** Smooth, continuous MMR adjustments prevent scenarios where post-partial liquidation account equity fails to recover naturally.

***

> **⚠️ Risk Warning:** Trading digital asset derivatives carries substantial risk. While continuous risk limits reduce margin slippage and tier-jump shocks, high leverage still amplifies both gains and losses. Please manage your risk responsibly.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.koo.xyz/risk-and-liquidations/continuous-risk-limit-and-margin-check.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
