Risk Flags
The flags array in the response identifies specific risk conditions detected for the trade. Use flags to understand why a score is elevated and to make targeted decisions in your agent logic.
Flag Reference
Order Book Flags
| Flag | Severity | Description |
|---|---|---|
thin_book | Warning | Limited liquidity in the order book for this trade size |
high_slippage | Warning | Expected slippage exceeds normal thresholds |
extreme_slippage | Critical | Slippage would significantly degrade execution quality |
Liquidation Flags
| Flag | Severity | Description |
|---|---|---|
near_liquidation | Critical | Position would be close to liquidation price |
near_backstop | Critical | Position is near the backstop liquidation threshold |
high_leverage | Warning | Effective leverage is elevated relative to the asset's risk profile |
Funding Flags
| Flag | Severity | Description |
|---|---|---|
funding_anomaly | Warning | Funding rate is statistically abnormal (z-score > 3) |
funding_expensive | Warning | Projected annualized funding cost is high |
cex_funding_divergence | Warning | Significant gap between Hyperliquid and CEX funding rates |
Market Impact Flags
| Flag | Severity | Description |
|---|---|---|
high_impact | Warning | Trade would meaningfully move the market price |
low_volume | Warning | Recent trading volume is low for this asset |
VaR Flags
| Flag | Severity | Description |
|---|---|---|
high_var | Warning | 24-hour Value-at-Risk is elevated |
limited_history | Info | Insufficient historical data for full statistical analysis |
new_listing | Info | Recently listed asset with limited trading history |
Open Interest Flags
| Flag | Severity | Description |
|---|---|---|
oi_at_cap | Critical | Asset is at the exchange's open interest cap |
oi_near_cap | Warning | Open interest is above 80% of estimated cap |
Portfolio Flags
| Flag | Severity | Description |
|---|---|---|
concentration_risk | Warning | Over 50% of portfolio value in a single asset |
correlated_exposure | Warning | Multiple positions with high correlation in the same direction |
Using Flags in Agent Logic
Flags let you build nuanced responses beyond just checking recommendation:
result = canon.validate(...)
# Block on critical flags
critical = [f for f in result.flags if f in ["extreme_slippage", "near_liquidation", "oi_at_cap"]]
if critical:
agent.abort(f"Critical risk: {critical}")
# Adjust for warnings
if "thin_book" in result.flags:
# Reduce size to match available liquidity
size = min(size, result.slippage.depth_at_50bps * 0.5)
if "funding_expensive" in result.flags:
# Only enter if expected alpha exceeds funding cost
if expected_return < result.funding.annualized_pct:
agent.skip("Funding cost exceeds expected return")
if "correlated_exposure" in result.flags:
# Already exposed to this direction, reduce allocation
size *= 0.5