Backtesting & Optimization
Backtesting and optimization are core validation stages within KEK.
Strategies must demonstrate historical robustness and risk awareness before progressing to paper trading or becoming eligible for optional execution.
This process exists to reduce execution risk — not to maximize headline performance.
What this page covers
- Backtesting methodology
- Optimization approach
- Risk evaluation metrics
- Overfitting avoidance and robustness checks
- Where this stage fits in the KEK lifecycle
Why backtesting exists in KEK
Backtesting evaluates how a strategy would have behaved across historical market conditions. The goal is to understand:
- consistency across environments
- failure modes
- drawdown behavior
- sensitivity to assumptions
Backtesting is the practice of simulating a trading strategy using historical data to evaluate risk and performance before risking capital.
Historical results are treated as validation signals — not predictions.
Backtesting engines used in KEK
KEK uses two complementary backtesting systems to maximize efficiency and accuracy, depending on the stage of evaluation:
VectorBT (high-speed research + large-scale validation)
KEK uses VectorBT for rapid, large-scale strategy evaluation and parameter exploration.
VectorBT is designed for quantitative analysis and vectorized backtesting on pandas/NumPy, and is accelerated by Numba to test large strategy spaces quickly.
Best for:
- fast iteration and research loops
- scanning thousands of variants
- sensitivity mapping and robustness screening
Nautilus Trader (high-fidelity simulation + execution realism)
KEK uses Nautilus Trader for high-accuracy simulation and execution realism where event-driven behavior matters.
NautilusTrader backtesting simulates trading activity using a full system implementation (engines, portfolio, message bus, and backtest engine driven by historical data streams).
Best for:
- realistic order/position lifecycle modeling
- event-driven execution behavior
- backtest-to-live parity and operational correctness
Backtesting methodology
Historical simulation
Strategies are tested against historical market data to evaluate:
- trade behavior and signal quality
- drawdowns and tail risk behavior
- volatility sensitivity
- performance differences across regimes
- failure modes in adverse environments
The focus is repeatability and risk behavior, not best-case returns.
Walk-forward analysis (generalization testing)
KEK uses sequential testing windows to reduce overfitting and improve generalization.
Walk-forward optimization repeatedly trains (in-sample) and evaluates (out-of-sample) across rolling periods to assess robustness.
This helps validate that a strategy is not dependent on one specific historical window.
Stress testing (fragility detection)
Stress testing evaluates strategy behavior under extreme or adverse conditions, such as:
- high volatility
- rapid regime shifts
- liquidity gaps / higher costs (modeled)
Stress testing is a technique used to evaluate stability under adverse conditions.
This stage is designed to identify fragile strategies before they ever reach paper trading.
Optimization approach
Optimization refines strategy parameters within defined constraints.
KEK emphasizes robustness over curve-fitting.
Parameter tuning (sensitivity + stability)
Parameters are systematically adjusted to measure:
- outcome stability across nearby values
- sensitivity cliffs and breakpoints
- regimes where performance collapses
The objective is not to "find the best number," but to find stable parameter regions that remain viable across changing conditions.
Multi-objective optimization (no single metric wins)
Strategies are evaluated across multiple dimensions, including:
- risk-adjusted returns
- drawdown behavior
- trade frequency and consistency
- exposure control and stability
- robustness across regimes
No single metric determines success.
Robustness checks (discard narrow strategies)
A strategy must demonstrate stability across:
- parameter ranges (not one perfect setting)
- market regimes (trend, range, high volatility)
- time periods (multiple windows)
Strategies that rely on narrow conditions are discarded.
Risk evaluation metrics
KEK evaluates strategies using multiple risk-aware measures, including:
- Maximum drawdown (loss depth and recovery burden)
- Sharpe / risk-adjusted performance
- Profit factor and payoff asymmetry
- Win rate (with context)
- Consistency across time windows and regimes
- Trade frequency and exposure behavior
Metrics are used for comparison and validation — not marketing.
Overfitting avoidance
KEK actively discourages overfitting through:
- walk-forward evaluation (rolling out-of-sample testing)
- stress testing under adverse conditions
- parameter stability requirements (robust regions, not exact values)
- regime-aware analysis (performance conditional on environment)
Strategies that only succeed in one historical pocket are discarded.
Overfitting is treated as a primary failure mode because it creates false confidence and fragile live behavior.
How this fits into the strategy lifecycle
Backtesting and optimization occur after strategy generation and before paper trading:
KEK Mix → Backtesting & Optimization → Paper Trading → Monitoring → Optional Execution
No strategy progresses without completing this stage.
Why this matters
This stage exists to ensure:
- capital is never exposed to unvalidated logic
- strategy risks are understood before deployment
- fragile strategies are filtered early
- strategy development remains systematic and repeatable
Backtesting is required to earn the right to proceed. Execution remains optional.