MCPcopy Create free account
hub / github.com/Open-Quant/openquant / fmt

Method fmt

crates/openquant/src/bet_sizing.rs:15–28  ·  view source on GitHub ↗
(&self, f: &mut fmt::Formatter<'_>)

Source from the content-addressed store, hash-verified

13//! `"power"` (`m(x) = sgn(x) |x|^w`, which needs the price divergence `x` scaled into
14//! `[-1, 1]`). Any other name is [`BetSizingError::InvalidFunction`].
15//!
16//! A bet `(t0, t1)` is live on the half-open interval `[t0, t1)`.
17//!
18//! ```
19//! use openquant::bet_sizing::{get_signal, get_target_pos, get_w, limit_price};
20//!
21//! # fn main() -> Result<(), openquant::bet_sizing::BetSizingError> {
22//! // Probability to size for a two-class model: no edge at 1/K, saturating towards 1.
23//! let sizes = get_signal(&[0.5, 0.7, 0.9], 2, None);
24//! assert!(sizes[0].abs() < 1e-12);
25//! assert!((sizes[1] - 0.3374).abs() < 1e-4 && (sizes[2] - 0.8176).abs() < 1e-4);
26//!
27//! // Calibrate the sigmoid so a price gap of 2.0 is a 0.9 bet, then size a 50-lot book.
28//! let w = get_w(2.0, 0.9, "sigmoid")?;
29//! let target = get_target_pos(w, 101.5, 100.0, 50.0, "sigmoid")?;
30//! let limit = limit_price(target, 0.0, 101.5, w, 50.0, "sigmoid")?;
31//! assert_eq!(target, 42.0);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected