> For the complete documentation index, see [llms.txt](https://tradewithonyx.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tradewithonyx.gitbook.io/docs/trading/margining.md).

# Margining

### Margin Modes

When opening a position, users must choose a margin mode:

* Isolated Margin (default)

  Collateral is confined to a single asset. If the position is liquidated, it does not impact other positions. Losses from elsewhere also won’t affect this position.
* Cross Margin&#x20;

  Collateral is shared across all cross-margin positions, maximizing capital efficiency. Losses or gains from one position can affect others under the same mode.

***

### **Initial Margin & Leverage**

* Users can set leverage anywhere from 1x up to the asset’s maximum.

* The margin required to open a position is:

  > **Initial Margin = (Position Size × Mark Price) ÷ Leverage**

* In cross margin, the initial margin is locked and cannot be withdrawn.

* In isolated margin, users can adjust margin (add/remove) even after the position is opened.

For cross positions, unrealized PnL can be reused as margin for new positions. For isolated positions, unrealized PnL adds to that position’s margin.

Once a position is open, leverage is not automatically re-evaluated. Users must monitor their risk and can adjust by:

* Closing part or all of the position
* Adding margin (if isolated)
* Depositing USDC (if cross)

***

### **Maintenance Margin & Liquidation**

* Cross positions are liquidated if your total account value (including unrealized PnL) falls below the maintenance margin, which is half of the initial margin at max leverage.
* Isolated positions follow the same logic, but the calculation is limited to the margin and notional value of the individual position only.


---

# 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://tradewithonyx.gitbook.io/docs/trading/margining.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.
