pub struct GridSearch { /* private fields */ }Expand description
Exhaustive grid-search optimiser for backtesting strategy parameters.
Evaluates every combination of the supplied parameter ranges in parallel.
Use BayesianSearch instead when the cartesian product would exceed
a few thousand combinations or when float ranges without a step are needed.
§Overfitting Warning
Results are in-sample only. Follow up with WalkForwardConfig or a
held-out test window to obtain an unbiased out-of-sample estimate.
Implementations§
Source§impl GridSearch
impl GridSearch
Sourcepub fn param(self, name: impl Into<String>, range: ParamRange) -> Self
pub fn param(self, name: impl Into<String>, range: ParamRange) -> Self
Add a named parameter range to sweep.
Parameters are expanded in cartesian-product order: the last parameter added cycles fastest (inner loop).
Sourcepub fn optimize_for(self, metric: OptimizeMetric) -> Self
pub fn optimize_for(self, metric: OptimizeMetric) -> Self
Set the metric to optimise for (defaults to OptimizeMetric::SharpeRatio).
Sourcepub fn run<S, F>(
&self,
symbol: &str,
candles: &[Candle],
config: &BacktestConfig,
factory: F,
) -> Result<OptimizationReport>
pub fn run<S, F>( &self, symbol: &str, candles: &[Candle], config: &BacktestConfig, factory: F, ) -> Result<OptimizationReport>
Run the grid search.
symbol is used only for labelling in the returned results.
factory receives the current parameter map and returns a strategy
instance. Combinations that exceed the strategy’s warmup period are
silently skipped.
Returns an error when the grid is empty or all combinations were skipped.
Trait Implementations§
Source§impl Clone for GridSearch
impl Clone for GridSearch
Source§fn clone(&self) -> GridSearch
fn clone(&self) -> GridSearch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GridSearch
impl Debug for GridSearch
Source§impl Default for GridSearch
impl Default for GridSearch
Source§fn default() -> GridSearch
fn default() -> GridSearch
Auto Trait Implementations§
impl Freeze for GridSearch
impl RefUnwindSafe for GridSearch
impl Send for GridSearch
impl Sync for GridSearch
impl Unpin for GridSearch
impl UnsafeUnpin for GridSearch
impl UnwindSafe for GridSearch
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