Skip to main content

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

FlagSeverityDescription
thin_bookWarningLimited liquidity in the order book for this trade size
high_slippageWarningExpected slippage exceeds normal thresholds
extreme_slippageCriticalSlippage would significantly degrade execution quality

Liquidation Flags

FlagSeverityDescription
near_liquidationCriticalPosition would be close to liquidation price
near_backstopCriticalPosition is near the backstop liquidation threshold
high_leverageWarningEffective leverage is elevated relative to the asset's risk profile

Funding Flags

FlagSeverityDescription
funding_anomalyWarningFunding rate is statistically abnormal (z-score > 3)
funding_expensiveWarningProjected annualized funding cost is high
cex_funding_divergenceWarningSignificant gap between Hyperliquid and CEX funding rates

Market Impact Flags

FlagSeverityDescription
high_impactWarningTrade would meaningfully move the market price
low_volumeWarningRecent trading volume is low for this asset

VaR Flags

FlagSeverityDescription
high_varWarning24-hour Value-at-Risk is elevated
limited_historyInfoInsufficient historical data for full statistical analysis
new_listingInfoRecently listed asset with limited trading history

Open Interest Flags

FlagSeverityDescription
oi_at_capCriticalAsset is at the exchange's open interest cap
oi_near_capWarningOpen interest is above 80% of estimated cap

Portfolio Flags

FlagSeverityDescription
concentration_riskWarningOver 50% of portfolio value in a single asset
correlated_exposureWarningMultiple 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