#[non_exhaustive]pub enum PositionSizing {
FixedFraction,
Atr {
risk_pct: f64,
atr_period: usize,
atr_multiple: f64,
},
VolatilityTarget {
target_vol_pct: f64,
lookback: usize,
},
FractionalKelly {
kelly_fraction: f64,
lookback_trades: usize,
},
}Expand description
How an entry’s size is derived from available equity.
Every scheme targets a fraction of equity clamped to the risk budget
(BacktestConfig::position_size_pct, raised by
BacktestConfig::max_leverage when levered), and falls back to that budget
when its inputs are unavailable.
Scale-in signals carry an explicit fraction of their own and are not sized by the active scheme.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
FixedFraction
Commit BacktestConfig::position_size_pct of equity on every entry.
Atr
Risk a fixed fraction of equity across an ATR-derived stop distance.
Wider ranges produce smaller positions, holding currency risk per trade roughly constant.
Fields
VolatilityTarget
Scale exposure inversely to realized volatility.
Fields
FractionalKelly
Size by a fraction of the Kelly-optimal bet implied by recent trades.
A trade count is not a bar count, so unlike the other schemes this one cannot extend the warmup period. Entries before the window holds both a win and a loss fall back to the risk budget.
Trait Implementations§
Source§impl Clone for PositionSizing
impl Clone for PositionSizing
Source§fn clone(&self) -> PositionSizing
fn clone(&self) -> PositionSizing
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PositionSizing
Source§impl Debug for PositionSizing
impl Debug for PositionSizing
Source§impl Default for PositionSizing
impl Default for PositionSizing
Source§fn default() -> PositionSizing
fn default() -> PositionSizing
Source§impl<'de> Deserialize<'de> for PositionSizing
impl<'de> Deserialize<'de> for PositionSizing
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PositionSizing
impl PartialEq for PositionSizing
Source§impl Serialize for PositionSizing
impl Serialize for PositionSizing
impl StructuralPartialEq for PositionSizing
Auto Trait Implementations§
impl Freeze for PositionSizing
impl RefUnwindSafe for PositionSizing
impl Send for PositionSizing
impl Sync for PositionSizing
impl Unpin for PositionSizing
impl UnsafeUnpin for PositionSizing
impl UnwindSafe for PositionSizing
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more