#[non_exhaustive]pub struct WalkForwardConfig {
pub grid: GridSearch,
pub config: BacktestConfig,
pub in_sample_bars: usize,
pub out_of_sample_bars: usize,
pub step_bars: Option<usize>,
}Expand description
Configuration for a walk-forward parameter optimisation test.
Build with WalkForwardConfig::new, configure window sizes with the
builder methods, then call WalkForwardConfig::run.
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.grid: GridSearchGrid search to use for optimising in-sample windows
config: BacktestConfigBase backtest configuration (capital, commission, slippage, …)
in_sample_bars: usizeNumber of bars in each in-sample (training) window
out_of_sample_bars: usizeNumber of bars in each out-of-sample (test) window
step_bars: Option<usize>Number of bars to advance the window each step.
Defaults to out_of_sample_bars (non-overlapping OOS windows).
Implementations§
Source§impl WalkForwardConfig
impl WalkForwardConfig
Sourcepub fn new(grid: GridSearch, config: BacktestConfig) -> Self
pub fn new(grid: GridSearch, config: BacktestConfig) -> Self
Create a new walk-forward config.
Defaults: in_sample_bars = 252, out_of_sample_bars = 63, step_bars = None.
Sourcepub fn in_sample_bars(self, bars: usize) -> Self
pub fn in_sample_bars(self, bars: usize) -> Self
Set the number of bars for each in-sample (training) window.
Sourcepub fn out_of_sample_bars(self, bars: usize) -> Self
pub fn out_of_sample_bars(self, bars: usize) -> Self
Set the number of bars for each out-of-sample (test) window.
Sourcepub fn step_bars(self, bars: usize) -> Self
pub fn step_bars(self, bars: usize) -> Self
Set the step size (bars to advance between windows).
Defaults to out_of_sample_bars for non-overlapping OOS windows.
Sourcepub fn run<S, F>(
&self,
symbol: &str,
candles: &[Candle],
factory: F,
) -> Result<WalkForwardReport>
pub fn run<S, F>( &self, symbol: &str, candles: &[Candle], factory: F, ) -> Result<WalkForwardReport>
Run the walk-forward test.
symbol is used only for labelling. factory receives the parameter
map selected by each in-sample optimisation and must return a fresh
strategy instance.
Returns an error if there is not enough data for at least one complete window pair, or if the grid search fails on every window.
Trait Implementations§
Source§impl Clone for WalkForwardConfig
impl Clone for WalkForwardConfig
Source§fn clone(&self) -> WalkForwardConfig
fn clone(&self) -> WalkForwardConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for WalkForwardConfig
impl !RefUnwindSafe for WalkForwardConfig
impl Send for WalkForwardConfig
impl Sync for WalkForwardConfig
impl Unpin for WalkForwardConfig
impl UnsafeUnpin for WalkForwardConfig
impl !UnwindSafe for WalkForwardConfig
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