# Risk Management

### Overview

Lune includes a comprehensive **risk management suite** with every connection plan at no additional cost. Risk rules are strictly enforced at the platform level across all execution paths, including manual orders, Auto Trader, and Copy Trading. To ensure users always maintain control over their open exposure, exit orders will consistently bypass all risk checks, allowing you to close a position at any time.

### Limits

The Limits tab allows users to define strict profit and loss boundaries for their connected accounts. P\&L is calculated dynamically as the sum of Realized P\&L (closed trades) and Unrealized P\&L (open positions).

#### Daily Limits

| Setting                 | Range            | Description                                         |
| ----------------------- | ---------------- | --------------------------------------------------- |
| **Daily Loss Limit**    | $0 to $1,000,000 | The maximum financial loss allowed per trading day. |
| **Daily Profit Target** | $0 to $1,000,000 | The desired profit target for the trading day.      |

#### Weekly Limits

| Setting                  | Range            | Description                                          |
| ------------------------ | ---------------- | ---------------------------------------------------- |
| **Weekly Loss Limit**    | $0 to $5,000,000 | The maximum financial loss allowed per trading week. |
| **Weekly Profit Target** | $0 to $5,000,000 | The desired profit target for the trading week.      |

#### On Limit Breach

Users can select from three specific actions to trigger when a profit or loss limit is breached:

* **Alert Only (Default):** Blocks the new trade entry and displays a warning message. The account remains unlocked for future manual intervention.
* **Lock Account:** Blocks all non-exit trades by locking the account. Users can configure the lock duration:
  * **Manual (Default):** Requires the user to manually unlock the account.
  * **6 hours / 12 hours:** Automatically unlocks after the specified timeframe.
  * **Session:** Automatically unlocks at a designated market session boundary (e.g., New York Open, London Close).
  * **Custom:** Automatically unlocks at a specified daily time (using a 24-hour HH:MM format in your local trading timezone).
* **Flatten and Lock:** Immediately closes all open positions at the market price, then locks the account using the same duration options listed above.

#### Enforce Lock

When a lock duration other than "Manual" is selected, users can enable Enforce Lock. This strict feature prevents the user from manually unlocking the account before the designated lock expiry time has passed.

#### Sync Divergence Guard

Enabled by default, this guard automatically pauses automation if positions disappear during a broker sync. This protects the account in scenarios where positions are externally flattened (e.g., by a prop firm or broker) while the platform is offline.

### Trading Hours

The Hours tab allows traders to restrict trade entries to specific times of the day, helping to avoid illiquid or highly volatile sessions.

| Setting         | Format      | Default           | Description                                                                |
| --------------- | ----------- | ----------------- | -------------------------------------------------------------------------- |
| **Start Time**  | HH:MM (24h) | 09:30             | The earliest allowed time for trade entries.                               |
| **End Time**    | HH:MM (24h) | 16:00             | The latest allowed time for trade entries.                                 |
| **Timezone**    | Dropdown    | America/New\_York | Selectable timezones including Eastern, Central, Pacific, UTC, and London. |
| **Active Days** | Day buttons | Mon to Fri        | Toggles for each day of the week to enable or disable trading.             |

*Note: The system supports overnight windows (e.g., 18:00 to 09:00). Exit orders will always bypass trading hour restrictions.*

#### Exit Before Event (Auto Flatten)

When enabled, the system will automatically flatten open positions a specified number of minutes (1 to 120, default is 5) before a blackout window begins or trading hours close.

### Blackouts

Blackout periods prevent new trade entries during specific news events or market conditions.

* One-Time Blackouts: Configured with a custom name (e.g., "FOMC Decision"), a specific start date and time, and an end date and time.
* Recurring Blackouts: Configured to repeat every week on a selected day, with a specific start time and end time.

*Note: Blackout times utilize your configured trading hours timezone. Exit orders always bypass blackout restrictions.*

### Positions

The Positions tab provides granular control over contract sizing and total market exposure.

#### Global Position Controls

| Setting                     | Range       | Description                                                                                                                           |
| --------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **Max Contracts Per Order** | 1 to 10,000 | The maximum number of contracts allowed in a single order execution.                                                                  |
| **Max Position Size**       | 1 to 10,000 | The maximum cumulative contract size allowed for a single symbol. Prevents adding to a position if the total would exceed this limit. |
| **Max Open Positions**      | 1 to 100    | The total count of distinct symbols allowed to be open simultaneously.                                                                |

#### Contract Rules

Users can toggle and configure per-symbol rules for strict asset management.

* **Symbol:** The canonical ticker symbol (e.g., ES, NQ, GC).
* **Mode:**
  * **Block:** Prevents all new entries for the specified symbol.
  * **Cap:** Limits the maximum number of contracts per order for the specified symbol.
* **Max Contracts:** Configurable from 1 to 10,000 (applies only when Cap mode is selected).

### Kill Switch

The emergency Kill Switch is located in the top right corner of the Risk Management page. It provides immediate, sweeping risk mitigation in case of an emergency.

1. Click the "Emergency kill switch" button.
2. Type FLATTEN to confirm the action.
3. The system will instantly close ALL open positions and lock ALL connected accounts.
4. A summary report will display the targeted accounts, successful or failed flatten attempts, and successful or failed lock attempts.

### Quote Health Settings

Accessible via the Settings icon in the Risk header, these parameters dictate how the system handles delayed or missing market data.

| Setting                   | Options                          | Default | Description                                                                                 |
| ------------------------- | -------------------------------- | ------- | ------------------------------------------------------------------------------------------- |
| **Quote Health Policy**   | Strict Block Entries / Warn Only | Strict  | Determines if entries are entirely blocked or if a warning is issued when quotes are stale. |
| **Stale Quote Threshold** | 1 to 300 seconds                 | 20s     | The maximum age a quote can reach before the system considers it stale.                     |

### How Risk Checks Work

Before any order is executed, the Lune platform runs it through a strict sequential validation process. If an order fails any condition, it is blocked. The validation sequence is as follows:

1. Is the account locked? (Blocks if locked)
2. Is the account enabled? (Blocks if disabled)
3. Is the current time within allowed trading hours? (Blocks if outside)
4. Is there an active blackout period? (Blocks if active)
5. Is the quote data healthy? (Blocks or warns based on policy)
6. Does the order exceed position limits? (Blocks if exceeded)
7. Does the order exceed daily or weekly profit/loss limits? (Blocks or triggers breach action if exceeded)
8. Do specific contract rules block this symbol? (Blocks if restricted)
9. If all checks pass, the order is executed.

*Important Note: Exit orders are designed to bypass all the above checks, guaranteeing that you can always flatten your exposure in the market.*


---

# 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.lunefi.com/lune-platform/risk-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.
