pub struct BayesianSearch { /* private fields */ }Expand description
Sequential model-based (Bayesian) parameter optimiser.
Finds near-optimal strategy parameters in a fraction of the evaluations
required by exhaustive [GridSearch], making it practical for
high-dimensional spaces or continuous float ranges.
Returns the same OptimizationReport as [GridSearch], so the two are
drop-in interchangeable and both work with WalkForwardConfig.
§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 BayesianSearch
impl BayesianSearch
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 search over.
Use ParamRange::int_bounds / ParamRange::float_bounds for
continuous ranges (recommended) or any ParamRange variant.
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 max_evaluations(self, n: usize) -> Self
pub fn max_evaluations(self, n: usize) -> Self
Maximum total strategy evaluations, including the initial LHS phase (default: 100).
Sourcepub fn initial_points(self, n: usize) -> Self
pub fn initial_points(self, n: usize) -> Self
Number of initial random (LHS) samples before the surrogate is fitted (default: 10).
Clamped to [2, max_evaluations]. More initial points improve surrogate
quality at the cost of fewer sequential refinement steps.
Sourcepub fn ucb_beta(self, beta: f64) -> Self
pub fn ucb_beta(self, beta: f64) -> Self
UCB exploration–exploitation coefficient β (default: 2.0).
Higher values drive broader exploration of uncertain regions; lower values concentrate search near already-good parameter sets.
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 Bayesian search.
symbol is used only for labelling in the returned results.
factory receives the current parameter map and returns a strategy
instance. Parameter sets incompatible with the candle series (warmup
too long) are silently skipped.
Returns an error only when no parameters are defined or every evaluation was skipped due to insufficient data.
Trait Implementations§
Source§impl Clone for BayesianSearch
impl Clone for BayesianSearch
Source§fn clone(&self) -> BayesianSearch
fn clone(&self) -> BayesianSearch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BayesianSearch
impl Debug for BayesianSearch
Source§impl Default for BayesianSearch
impl Default for BayesianSearch
Source§fn default() -> BayesianSearch
fn default() -> BayesianSearch
Auto Trait Implementations§
impl Freeze for BayesianSearch
impl RefUnwindSafe for BayesianSearch
impl Send for BayesianSearch
impl Sync for BayesianSearch
impl Unpin for BayesianSearch
impl UnsafeUnpin for BayesianSearch
impl UnwindSafe for BayesianSearch
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