# Margin Management

### **Margin Calculations**

The Market Maker Bot features sophisticated margin calculations that account for directional bias and updated exposure tolerances.

**Base Margin Requirements**

**Spot Markets:**

* **Exposure Tolerance**: 8% (increased from 6%)
* **Formula**: `baseMargin = notional × 0.08`
* **Rationale**: Higher tolerance accounts for spot market volatility and margin requirements

**Perpetual Markets:**

* **Formula**: `baseMargin = (notional ÷ leverage) × safetyBuffer`
* **Safety Buffers by Mode:**
  * **Aggressive**: 2.0x safety buffer for higher risk tolerance
  * **Normal**: 1.0x safety buffer for balanced risk management
  * **Passive**: 0.5x safety buffer for conservative trading

**Directional Bias Adjustments**

* **Additional Margin**: Up to 20% more margin for extreme bias
* **Formula**: `adjustedMargin = baseMargin × (1 + |directionalBias| × 0.2)`
* **Examples:**
  * **Neutral (0)**: No additional margin
  * **Moderate Bias (±0.5)**: 10% additional margin
  * **Extreme Bias (±1.0)**: 20% additional margin

**Risk Monitoring**

* **Critical Warning**: Triggered when available margin < 10% of recommended margin
* **Color-coded Indicators:**
  * **Green**: Safe (recommended < available)
  * **Orange**: Caution (recommended ≤ 5× available)
  * **Red**: Insufficient (recommended > 5× available)

**Real-time Updates**

Margin requirements automatically recalculate when you change:

* Notional amount
* Trading pair
* Trading mode
* Directional bias setting
* Account selection

**Best Practices**

* **Conservative Approach**: Use moderate directional bias (±0.3 to ±0.5) to minimize additional margin requirements
* **Adequate Funding**: Maintain available margin at least 20% above recommended margin
* **Mode Selection**: Choose trading modes based on your risk tolerance and available capital
* **Regular Monitoring**: Check margin requirements when market conditions or account balances change


---

# Agent Instructions: 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.tread.fi/bots/market-maker-bot/margin-management.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.
