# AegisTrade AI — Risk Policy & Mathematical Formulation

## 1. Prime Directive: Capital Preservation

AegisTrade AI is engineered for positive net expectancy under real-world market friction. The risk engine operates as an independent gatekeeper with unconditional veto power over all trade generation.

---

## 2. Quantitative Guardrails

### 2.1 Position Sizing (Fixed Fractional Risk)
For every proposed trade $i$:
$$\text{Risk Budget}_i = \text{Current Equity} \times f_{\text{risk}}$$
where default $f_{\text{risk}} = 0.0025$ ($0.25\%$).

The required position quantity $Q_i$ is determined by:
$$\Delta P_{\text{stop}} = |\text{Entry Price} - \text{Stop Loss Price}|$$
$$\text{Friction Per Unit} = \text{Entry Price} \times (2 \times \text{Fee}_{\text{taker}} + \text{Slippage}_{\text{est}})$$
$$\text{Effective Loss Per Unit} = \Delta P_{\text{stop}} + \text{Friction Per Unit}$$
$$Q_i = \left\lfloor \frac{\text{Risk Budget}_i}{\text{Effective Loss Per Unit}} \right\rfloor_{\text{step\_size}}$$

### 2.2 Small-Account Protection Rules
1. **Exchange Minimum Notional Check**:
   $$\text{Notional}_i = Q_i \times \text{Entry Price}$$
   If $\text{Notional}_i < \text{MinNotional}_{\text{symbol}}$:
   - **MANDATORY ACTION**: **REJECT TRADE**.
   - **STRICT PROHIBITION**: Never increase $Q_i$ to satisfy the minimum notional, as this would breach the $0.25\%$ risk budget.
2. **Maximum Concurrent Positions**:
   $$\sum_{j} \mathbb{I}(\text{Position}_j \text{ is open}) \le 2$$
3. **Daily Loss Threshold**:
   $$\text{Daily PnL} = (\text{Current Equity} - \text{StartOfDay Equity}) / \text{StartOfDay Equity}$$
   If $\text{Daily PnL} \le -0.010$ ($-1.0\%$):
   - Trigger intraday trading circuit breaker.
   - Halt all new order entries for the remainder of the UTC trading day.
4. **Maximum Drawdown Circuit Breaker**:
   $$\text{Drawdown} = (\text{Current Equity} - \text{Peak Equity}) / \text{Peak Equity}$$
   If $\text{Drawdown} \le -0.050$ ($-5.0\%$):
   - Trip system emergency halt.
   - Set `KILL_SWITCH_ACTIVE = True`.
   - Require manual operator intervention to re-enable.
5. **Leverage Limit**:
   - Live and Demo leverage is fixed at **1.0x** (No borrowed capital / isolated linear margin).

---

## 3. Order Protection Invariants
- **Mandatory Protective Stop**: No trade may be placed without an explicit Stop Loss order.
- **Asymmetric Risk-Reward**: Minimum reward-to-risk ratio:
  $$\frac{|\text{Take Profit} - \text{Entry}|}{|\text{Stop Loss} - \text{Entry}|} \ge 1.5$$
- **No Averaging Down**: Adding to a losing position is barred at the OMS layer.
- **No Martingale**: Increasing size after a loss is strictly prohibited.
