Module Algostream_risk_management.Monitor

Risk Monitor — top-level facade aggregating drawdown + circuit breaker + correlation breakdown + exposures + VaR + risk-limit breach detection.

Strategies hold a Monitor.t alongside their Portfolio, and feed it the latest snapshot + recent returns + any updated pair correlations on each tick or bar. The Monitor publishes a fresh Risk_snapshot.t via Atomic.set on each update so other Domains read race-free.

type stats = {
  1. n_updates : int;
  2. n_breaches : int;
  3. n_circuit_trips : int;
}
type t
val create : limits:Risk_limits.t -> circuit_config:Circuit_breaker.config -> ?initial_equity:float -> unit -> t
val update : t -> portfolio:Portfolio.portfolio -> returns:float array -> ?correlation_updates:(string * string * float) list -> ?garch:Garch11.t -> ts_ns:int64 -> unit -> Risk_snapshot.t

Ingest a portfolio snapshot + recent returns + optional correlation feed + optional GARCH state. Recomputes VaR / drawdown / exposures / circuit / correlation status, publishes a fresh Risk_snapshot.t, and returns the same snapshot.

val snapshot : t -> Risk_snapshot.t
val snapshot_atomic : t -> Risk_snapshot.t Stdlib.Atomic.t
val circuit_breaker_state : t -> Circuit_breaker.state
val reset_circuit : t -> ts_ns:int64 -> unit
val realized_vol : t -> float

Last realized volatility computed during update (sample stddev of returns). Feeds Proprietary_models.compute_score.

val baseline_vol : t -> float

Baseline volatility — initialized from the first update's returns, sticky thereafter so vol spikes are measured against a stable reference.

val stats : t -> stats