@@ -30,13 +30,12 @@ use crate::tools::response_types::{
3030 AggregatePricesResponse , BenchmarkAnalysisResponse , CointegrationResponse , CorrelateResponse ,
3131 DistributionResponse , DrawdownAnalysisResponse , FactorAttributionResponse , HypothesisParams ,
3232 HypothesisResponse , MonteCarloResponse , PortfolioOptimizeResponse , RegimeDetectResponse ,
33- RollingMetricResponse , WalkForwardResponse ,
33+ RollingMetricResponse ,
3434} ;
3535use params:: {
3636 tool_err, validation_err, AggregatePricesParams , BenchmarkAnalysisParams , CointegrationParams ,
3737 CorrelateParams , DistributionParams , DrawdownAnalysisParams , FactorAttributionParams ,
3838 MonteCarloParams , PortfolioOptimizeParams , RegimeDetectParams , RollingMetricParams ,
39- WalkForwardToolParams ,
4039} ;
4140use sanitize:: SanitizedResult ;
4241
@@ -589,66 +588,12 @@ impl OptopsyServer {
589588 . map_err ( |e| format ! ( "Failed to read scripting reference: {e}" ) )
590589 }
591590
592- /// Run walk-forward optimization: split data into train/test windows, optimize parameters
593- /// on each training window, and validate on the out-of-sample test window.
594- ///
595- /// **When to use**: After finding a profitable strategy via backtest + sweep, to verify
596- /// that optimized parameters generalize to unseen data. The efficiency ratio (OOS/IS metric)
597- /// measures how well the strategy avoids overfitting.
598- ///
599- /// **Output**: Per-window IS/OOS metrics, best params per window, stitched OOS equity curve,
600- /// and efficiency ratio.
601- ///
602- /// **Example**:
603- /// ```json
604- /// {
605- /// "strategy": "short_put",
606- /// "symbol": "SPY",
607- /// "capital": 100000,
608- /// "params_grid": {
609- /// "DELTA_TARGET": [0.20, 0.30, 0.40],
610- /// "DTE_TARGET": [30, 45, 60]
611- /// },
612- /// "n_windows": 5,
613- /// "objective": "sharpe"
614- /// }
615- /// ```
616- #[ tool( name = "walk_forward" , annotations( read_only_hint = true ) ) ]
617- async fn walk_forward (
618- & self ,
619- Parameters ( params) : Parameters < WalkForwardToolParams > ,
620- ) -> SanitizedResult < WalkForwardResponse , String > {
621- SanitizedResult (
622- async {
623- params
624- . validate ( )
625- . map_err ( |e| validation_err ( "walk_forward" , e) ) ?;
626- tools:: walk_forward:: execute (
627- & self . cache ,
628- self . adjustment_store . clone ( ) ,
629- & params. strategy ,
630- & params. symbol ,
631- params. capital ,
632- params. params_grid ,
633- params. objective ,
634- Some ( params. n_windows ) ,
635- params. mode ,
636- Some ( params. train_pct ) ,
637- params. start_date ,
638- params. end_date ,
639- params. profile ,
640- )
641- . await
642- . map_err ( tool_err)
643- }
644- . await ,
645- )
646- }
647-
648591 /// Run a backtest or parameter sweep. Pass a saved strategy by display name.
649592 ///
650593 /// Omit `sweep_params` for a single backtest (returns full equity curve, trade log, metrics).
651- /// Provide `sweep_params` for a grid/bayesian sweep (returns ranked results).
594+ /// Provide `sweep_params` for a grid/bayesian sweep. By default, sweeps run the
595+ /// full analysis pipeline: sweep -> significance gate -> walk-forward ->
596+ /// `oos_data_gate` -> monte carlo. Set `pipeline=false` to return sweep-only results.
652597 /// Results are persisted to the runs database.
653598 ///
654599 /// **Example (single backtest)**:
@@ -659,15 +604,16 @@ impl OptopsyServer {
659604 /// }
660605 /// ```
661606 ///
662- /// **Example (parameter sweep)**:
607+ /// **Example (parameter sweep with full pipeline )**:
663608 /// ```json
664609 /// {
665610 /// "strategy": "short_put",
666611 /// "params": { "symbol": "SPY", "CAPITAL": 50000 },
667612 /// "sweep_params": [
668613 /// { "name": "DELTA_TARGET", "start": 0.10, "stop": 0.40, "step": 0.05 },
669614 /// { "name": "DTE_TARGET", "param_type": "int", "start": 30, "stop": 60, "step": 5 }
670- /// ]
615+ /// ],
616+ /// "pipeline": true
671617 /// }
672618 /// ```
673619 #[ tool( name = "backtest" , annotations( read_only_hint = false ) ) ]
@@ -726,7 +672,7 @@ impl ServerHandler for OptopsyServer {
726672 \n - factor_attribution — decompose returns into factor exposures\
727673 \n - benchmark_analysis — compare vs. benchmark (alpha, beta, capture ratios)\
728674 \n - distribution — P&L or return distribution + normality tests\
729- \n - walk_forward — walk -forward optimization to validate parameter robustness \
675+ \n - Walk -forward validation runs automatically as part of the backtest pipeline \
730676 \n \
731677 \n ### 4. Market Analysis Tools\
732678 \n - aggregate_prices — seasonal/time-bucket return patterns\
0 commit comments