synthetic_backtesting
Subject
Section titled “Subject”Sampling, Validation and ML Diagnostics
Why This Module Exists
Section titled “Why This Module Exists”AFML Chapter 13 shows that selecting PT/SL rules on a single historical path is prone to overfitting; synthetic path ensembles let us evaluate rule robustness under calibrated process dynamics.
Mathematical Foundations
Section titled “Mathematical Foundations”Discrete O-U (AR(1))
Section titled “Discrete O-U (AR(1))”
Equilibrium Level
Section titled “Equilibrium Level”
OTR Objective over Rule Mesh
Section titled “OTR Objective over Rule Mesh”
Usage Examples
Section titled “Usage Examples”End-to-end synthetic OTR workflow
Section titled “End-to-end synthetic OTR workflow”use openquant::synthetic_backtesting::{run_synthetic_otr_workflow, StabilityCriteria, SyntheticBacktestConfig};
let cfg = SyntheticBacktestConfig { initial_price: historical_prices[historical_prices.len() - 1], n_paths: 10_000, horizon: 128, seed: 42, profit_taking_grid: vec![0.5, 1.0, 1.5, 2.0, 3.0], stop_loss_grid: vec![0.5, 1.0, 1.5, 2.0, 3.0], max_holding_steps: 64, annualization_factor: 1.0, stability_criteria: StabilityCriteria::default(),};
let out = run_synthetic_otr_workflow(&historical_prices, &cfg)?;if out.diagnostics.no_stable_optimum { println!("Skip OTR optimization: {}", out.diagnostics.reason);} else { println!("Best PT/SL: {:?}", out.best_rule);}API Reference
Section titled “API Reference”Rust API
Section titled “Rust API”calibrate_ou_paramsgenerate_ou_pathsevaluate_rule_on_pathssearch_optimal_trading_ruledetect_no_stable_optimumrun_synthetic_otr_workflow
Implementation Notes
Section titled “Implementation Notes”- Near-random-walk estimates (|phi| close to 1) often produce flat Sharpe heatmaps where any selected rule is unstable out-of-sample.
- Calibrating to process parameters and evaluating many synthetic paths reduces single-path lucky-fit risk compared to brute-force historical optimization.