Skip to main content

rustrade_risk/
lib.rs

1#![warn(missing_docs)]
2
3//! # rustrade-risk
4//!
5//! Generic risk primitives for trading bots:
6//!
7//! - [`CircuitBreaker`] — sliding-window loss breaker (ported from the
8//!   kucoin bot's `circuit_breaker.rs`).
9//! - [`SessionPnl`] — daily PnL tracker with drawdown cap and automatic
10//!   00:00 UTC rollover.
11//! - [`PositionSizer`] — notional-based sizing from margin + leverage +
12//!   price + contract multiplier (ported from kucoin's `sizing.rs`).
13//!
14//! Nothing here is strategy- or exchange-specific. If you find yourself
15//! needing to special-case a particular strategy, the logic belongs in
16//! the `Brain` implementation, not here.
17
18pub mod circuit_breaker;
19pub mod clock;
20pub mod session_pnl;
21pub mod sizing;
22
23pub use circuit_breaker::{CircuitBreaker, CircuitBreakerConfig, CircuitBreakerSnapshot};
24pub use clock::{Clock, ManualClock, SystemClock};
25pub use session_pnl::{SessionPnl, SessionPnlConfig, SessionPnlSnapshot};
26pub use sizing::{PositionSizer, SizingConfig};