---
title: "Sentinel"
description: "Always-on portfolio risk monitoring: correlation alerts, graduated drawdown response, tail risk hedging, regime-aware risk budgets."
icon: "shield-halved"
---

<Warning>
  **Ultra Feature.** Requires an Ultra subscription. [Get started at api.mathematicalcompany.com](https://api.mathematicalcompany.com)
</Warning>

# Sentinel

Continuous portfolio risk surveillance that runs inside `hz.run()` or standalone. Monitors correlations, manages drawdowns with graduated responses, detects regime changes, and suggests hedges.

<CardGroup cols={2}>
  <Card title="Drawdown Management" icon="arrow-trend-down">
    4-level graduated response: alert → reduce → pause → exit.
  </Card>
  <Card title="Regime Detection" icon="chart-line">
    Classifies volatility regime and adjusts risk budget multiplier.
  </Card>
  <Card title="Correlation Alerts" icon="diagram-project">
    Ledoit-Wolf shrinkage detects correlation spikes across positions.
  </Card>
  <Card title="Hedge Suggestions" icon="umbrella">
    Delta-based hedge recommendations from prediction Greeks.
  </Card>
</CardGroup>

---

## Standalone Report

```python
import horizon as hz

engine = hz.Engine()
report = hz.sentinel_report(engine)
print(report.regime)          # "normal", "high_vol", "crisis", etc.
print(report.var_95)          # Cornish-Fisher VaR at 95%
print(report.risk_budget)     # Budget utilisation with regime multiplier
```

---

## Hedge Suggestions

```python
hedges = hz.suggest_hedges(engine, max_hedges=3, min_reduction_pct=5.0)
for h in hedges:
    print(f"{h.market_id}: {h.side} {h.size} @ {h.price} → {h.risk_reduction_pct}% reduction")
```

---

## Pipeline Mode

```python
hz.run(
    name="guarded-strategy",
    markets=["mkt-a", "mkt-b"],
    pipeline=[
        hz.sentinel(config=hz.SentinelConfig(
            auto_deleverage=True,
            drawdown_thresholds=[
                (-0.05, "alert"),
                (-0.10, "reduce"),
                (-0.20, "pause"),
                (-0.30, "exit"),
            ],
        )),
        model,
        quoter,
    ],
    interval=1.0,
)
```

Injects `ctx.params["sentinel_report"]` every N cycles.

---

## Graduated Drawdown Response

| Threshold | Action | Behaviour |
|-----------|--------|-----------|
| `-5%` | `alert` | Log warning only |
| `-10%` | `reduce` | Cancel 50% of open orders (largest first) |
| `-20%` | `pause` | Cancel all open orders |
| `-30%` | `exit` | Cancel all + submit exit orders for all positions |

---

## Regime Detection

Portfolio volatility determines the regime and risk budget multiplier:

| Regime | Volatility | Multiplier |
|--------|-----------|------------|
| `low_vol` | < 5% | 1.5× (take more risk) |
| `normal` | 5-15% | 1.0× |
| `high_vol` | 15-30% | 0.5× (reduce risk) |
| `crisis` | > 30% | 0.25× (minimal risk) |

---

## SentinelConfig

| Parameter | Default | Description |
|-----------|---------|-------------|
| `drawdown_thresholds` | `[(-0.05,"alert"), ...]` | Graduated response levels |
| `correlation_spike_threshold` | `0.3` | Flag when correlation jumps by this |
| `auto_hedge` | `False` | Automatically execute hedge suggestions |
| `auto_deleverage` | `True` | Automatically reduce positions on drawdown |
| `regime_sensitivity` | `1.0` | Scaling factor for regime thresholds |
| `var_confidence` | `0.95` | VaR confidence level |
| `lookback_returns` | `100` | Rolling window for return calculations |
| `risk_budget_total` | `10000.0` | Total risk budget in USDC |
