> For the complete documentation index, see [llms.txt](https://docs.afx.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.afx.xyz/trading-rules/margin-modes.md).

# Margin Modes

AFX supports two margin modes: **Cross Margin** and **Isolated Margin**. The margin mode is configured per trading pair and can be switched even when positions or orders are open.

## Cross Margin

In Cross Margin mode, the entire available balance in your account is shared across all cross-margin positions. This provides more flexibility and reduces the risk of individual position liquidation, but a liquidation event will affect your entire account.

**Key characteristics:**

* Margin is shared across all cross-margin positions for the same settlement currency.
* Unrealized profit from one position can offset unrealized loss in another.
* Unrealized profit can be used to open new positions (both cross and isolated).
* Unrealized profit **cannot** be withdrawn or transferred.
* Cross margin is the **default** mode.

**Available Balance (Cross):**

```
Available = Balance - In Order & Position + Cross Unrealized PNL
```

## Isolated Margin

In Isolated Margin mode, margin is allocated individually to each position. If a position is liquidated, only the margin assigned to that specific position is at risk — your remaining account balance is protected.

**Key characteristics:**

* Each position has its own dedicated margin.
* You can manually add or remove margin for an isolated position.
* Unrealized profit only affects the current position.
* Unrealized profit **cannot** be used for other positions or orders.

**Available Balance (Isolated):**

```
Available = Balance - In Order & Position + Cross Unrealized PNL * α
```

Where `α` is the unrealized PNL liquidity coefficient, configured per trading pair based on asset liquidity. For example, BTC has `α = 0.98`, ETH has `α = 0.90`.

## Switching Margin Modes

You can switch between Cross and Isolated margin on a per-pair basis at any time, including when you have open positions. When switching from Cross to Isolated on an existing position, the system will calculate and allocate the appropriate initial margin.


---

# 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:

```
GET https://docs.afx.xyz/trading-rules/margin-modes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
