pub struct GuidanceThresholds {
pub stop_loss_ratio: f64,
pub take_profit_ratio: f64,
}Expand description
Threshold ratios used by compute_guidance. Decoupled from
OptimizedParams so callers can supply optimizer-derived values when
available and fall back to conservative defaults otherwise.
Fields§
§stop_loss_ratio: f64Negative ratio of notional at which to exit on a loss (e.g. -0.02
= exit when unrealized loss reaches 2% of entry_price * qty).
take_profit_ratio: f64Positive ratio of notional at which to reduce on profit (e.g. 0.05
= trim when unrealized gain reaches 5% of entry_price * qty).
Implementations§
Source§impl GuidanceThresholds
impl GuidanceThresholds
Sourcepub fn from_optimized_params(params: &OptimizedParams) -> Self
pub fn from_optimized_params(params: &OptimizedParams) -> Self
Derive thresholds from optimizer-tuned params.
Both stop_loss_ratio and take_profit_ratio are now learnable
via OptimizedParams::stop_loss_pct and
OptimizedParams::take_profit_pct respectively.
stop_loss_pct is stored as a positive percentage (e.g. 2.0)
and converted to a negative ratio here (-0.02).
Sourcepub fn widen_for_volatility(self, atr_pct: f64, atr_multiplier: f64) -> Self
pub fn widen_for_volatility(self, atr_pct: f64, atr_multiplier: f64) -> Self
Loosen the stop-loss so it sits outside normal ATR-sized noise.
atr_pct is recent ATR as a percentage of price (the volatility
hint carried on PositionEvent); atr_multiplier is how many
ATRs the optimizer places its trailing stop (reused here so the
band matches the strategy’s own notion of “normal” movement). If
the ATR band (atr_multiplier * atr_pct) is wider than the
configured stop, the stop is widened to match — otherwise the
configured stop is already conservative and is kept.
Take-profit is intentionally left untouched: it’s a target, not noise protection. Non-positive inputs are a no-op, so callers can pass values straight through without pre-checking.
Sourcepub fn tighten_stop_for_fear(self, fear: f64) -> Self
pub fn tighten_stop_for_fear(self, fear: f64) -> Self
Tighten the stop toward break-even in proportion to elevated fear.
The inverse of [widen_for_volatility]: under amygdala stress we
want a losing position on a shorter leash. fear is expected in
the elevated band [FEAR_ELEVATED_LEVEL, FEAR_EXIT_LEVEL); the
stop magnitude scales linearly from full width (at the bottom of
the band) down to [STOP_TIGHTEN_FLOOR] of its width (at the top).
It never reaches zero, so a position isn’t exited on the first
tick of an adverse move. Fear below the elevated band is a no-op.
Trait Implementations§
Source§impl Clone for GuidanceThresholds
impl Clone for GuidanceThresholds
Source§fn clone(&self) -> GuidanceThresholds
fn clone(&self) -> GuidanceThresholds
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GuidanceThresholds
impl Debug for GuidanceThresholds
Source§impl Default for GuidanceThresholds
impl Default for GuidanceThresholds
Source§impl PartialEq for GuidanceThresholds
impl PartialEq for GuidanceThresholds
Source§fn eq(&self, other: &GuidanceThresholds) -> bool
fn eq(&self, other: &GuidanceThresholds) -> bool
self and other values to be equal, and is used by ==.