Use case · Monitor

Track an open spread's health and Greeks

compute_saved_spread_analytics returns live position Greeks for a saved spread; compute_health_components grades it against its plan and rolls the worst case into one status. This is the post-fill half of the engine — the same monitoring that drives the position views in Spread Foundry and MeridianScope.

When to use it

  • You have an open, saved spread and need its current net and per-leg Greeks, theta decay, and progress toward target — not a fresh candidate score.
  • You want a typed health readout that flags when a position needs attention (time stop, max loss, stale thesis, thinning liquidity).
  • You need a single aggregate status and an alarm count to drive a dashboard or an alert.

Example

use ferro_spread::{
    compute_saved_spread_analytics, compute_health_components,
    aggregate_status, alarmed_count, HealthStatus,
};

// Position analytics for a saved spread
let pos = compute_saved_spread_analytics(&inputs)?;
println!("net delta {}  theta/day {}", pos.position.delta, pos.theta_decay_per_day);
println!("target progress {}", pos.target_progress);
println!("short-strike dist {}%", pos.short_strike_distance_spot_pct);
for leg in &pos.per_leg {
    // leg.delta / .gamma / .theta / .vega
}

// Health scoring against the position's plan
let health = compute_health_components(&hc_inputs);
let status = aggregate_status(&health);        // Ok | Watch | Alarm
if status == HealthStatus::Alarm {
    // surface the alarmed components (alarmed_count(&health)) to the UI
}
# Ok::<(), Box<dyn std::error::Error>>(())

Position analytics

SavedSpreadAnalyticsDescription
positionNet PositionGreeks for the spread — delta, gamma, theta, vega.
per_legVec<LegGreeks> — the same sensitivities broken out per leg.
theta_decay_per_dayExpected time decay of the position value per calendar day.
short_strike_distance_spot_pctHow far the short strike sits from spot, in percent.
target_progressProgress toward the planned profit target, in [0, 1].

Health components

compute_health_components returns a Vec<HealthComponent>, one per HealthComponentKind; aggregate_status reduces them to the worst status and alarmed_count counts the ones firing:

HealthComponentKindDescription
PlanTargetProgress toward the plan’s profit target.
MaxLossDistance to the plan’s max-loss line.
TimeStopDTE against the plan’s time stop.
TriggerFiredWhether any defined exit trigger has fired.
ThesisStaleHow stale the original thesis has become.
LiquidityDegradedWhether the position is still liquid enough to manage.

Notes

  • Fail-loud, like the rest of the engine: a missing mark or IV yields an Unavailable confidence rather than a fabricated Greek. See the conventions.
  • HealthStatus carries a .worse() combinator (Alarm > Watch > Ok), so aggregate_status always reflects the most urgent component.
  • Monitoring consumes a saved spread — the output of the construct/rank path once a candidate has been taken.
Lifecycle

Construct → Rank → Explain gets you into a position; compute_saved_spread_analytics + compute_health_components are what watch it afterward.