#[non_exhaustive]pub struct PortfolioConfig {
pub base: BacktestConfig,
pub max_allocation_per_symbol: Option<f64>,
pub max_total_positions: Option<usize>,
pub rebalance: RebalanceMode,
}Expand description
Configuration for multi-symbol portfolio backtesting.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.base: BacktestConfigShared per-trade settings (commission, slippage, stop-loss, etc.)
max_allocation_per_symbol: Option<f64>Maximum fraction of initial capital that can be allocated to a single symbol (0.0 – 1.0).
None = no per-symbol cap (default).
max_total_positions: Option<usize>Maximum number of concurrent open positions across all symbols.
When the limit is reached, new entry signals are rejected until a position
closes. Signals are ranked by strength; ties are broken alphabetically.
None = unlimited (default).
rebalance: RebalanceModeCapital allocation strategy when opening new positions.
Implementations§
Source§impl PortfolioConfig
impl PortfolioConfig
Sourcepub fn new(base: BacktestConfig) -> Self
pub fn new(base: BacktestConfig) -> Self
Create a portfolio config wrapping the given single-symbol config.
Sourcepub fn max_allocation_per_symbol(self, pct: f64) -> Self
pub fn max_allocation_per_symbol(self, pct: f64) -> Self
Cap the fraction of initial capital allocated to any single symbol.
Sourcepub fn max_total_positions(self, max: usize) -> Self
pub fn max_total_positions(self, max: usize) -> Self
Limit the number of concurrent open positions across all symbols.
Sourcepub fn rebalance(self, mode: RebalanceMode) -> Self
pub fn rebalance(self, mode: RebalanceMode) -> Self
Set the capital allocation strategy.
Trait Implementations§
Source§impl Clone for PortfolioConfig
impl Clone for PortfolioConfig
Source§fn clone(&self) -> PortfolioConfig
fn clone(&self) -> PortfolioConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PortfolioConfig
impl Debug for PortfolioConfig
Source§impl Default for PortfolioConfig
impl Default for PortfolioConfig
Source§fn default() -> PortfolioConfig
fn default() -> PortfolioConfig
Source§impl<'de> Deserialize<'de> for PortfolioConfig
impl<'de> Deserialize<'de> for PortfolioConfig
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>,
Auto Trait Implementations§
impl Freeze for PortfolioConfig
impl !RefUnwindSafe for PortfolioConfig
impl Send for PortfolioConfig
impl Sync for PortfolioConfig
impl Unpin for PortfolioConfig
impl UnsafeUnpin for PortfolioConfig
impl !UnwindSafe for PortfolioConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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