Selects optimal training epochs per-fold in Walk-Forward Optimization using Walk-Forward Efficiency as the objective. Computes efficient frontiers for epoch-performance trade-offs and carries priors across folds.
Ships in quant-research. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Machine-readable reference for adaptive epoch selection within Walk-Forward Optimization (WFO). Optimizes training epochs per-fold using Walk-Forward Efficiency (WFE) as the objective.
Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.
Use this skill when:
from adaptive_wfo_epoch import AWFESConfig, compute_efficient_frontier
# Generate epoch candidates from search bounds and granularity
config = AWFESConfig.from_search_space(
min_epoch=100,
max_epoch=2000,
granularity=5, # Number of frontier points
)
# config.epoch_configs → [100, 211, 447, 945, 2000] (log-spaced)
# Per-fold epoch sweep
for fold in wfo_folds:
epoch_metrics = []
for epoch in config.epoch_configs:
is_sharpe, oos_sharpe = train_and_evaluate(fold, epochs=epoch)
wfe = config.compute_wfe(is_sharpe, oos_sharpe, n_samples=len(fold.train))
epoch_metrics.append({"epoch": epoch, "wfe": wfe, "is_sharpe": is_sharpe})
# Select from efficient frontier
selected_epoch = compute_efficient_frontier(epoch_metrics)
# Carry forward to next fold as prior
prior_epoch = selected_epoch
Per-fold adaptive epoch selection where:
| Concept | Citation | Key Insight |
|---|---|---|
| Walk-Forward Efficiency | Pardo (1992, 2008) | WFE = OOS_Return / IS_Return as robustness metric |
| Probabilistic Sharpe Ratio | Bailey & López de Prado (2012) | Sharpe significance for one rule |
| Pareto-Optimal HP Selection | Bischl et al. (2023) | Multi-objective hyperparameter optimization |
| Warm-Starting | Nomura & Ono (2021) | Transfer knowledge between optimization runs |
See references/academic-foundations.md for full literature review.
def compute_wfe(
is_sharpe: float,
oos_sharpe: float,
n_samples: int | None = None,
) -> float | None:
"""Walk-Forward Efficiency - measures performance transfer.
WFE = OOS_Sharpe / IS_Sharpe
Interpretation (guidelines, not hard thresholds):
- WFE ≥ 0.70: Excellent transfer (low overfitting)
- WFE 0.50-0.70: Good transfer
- WFE 0.30-0.50: Moderate transfer (investigate)
- WFE < 0.30: Severe overfitting (likely reject)
The IS_Sharpe minimum is derived from signal-to-noise ratio,
not a fixed magic number. See compute_is_sharpe_threshold().
Reference: Pardo (2008) "The Evaluation and Optimization of Trading Strategies"
"""
# Data-driven threshold: IS_Sharpe must exceed 2σ noise floor
min_is_sharpe = compute_is_sharpe_threshold(n_samples) if n_samples else 0.1
if abs(is_sharpe) < min_is_sharpe:
return None
return oos_sharpe / is_sharpe
All parameters are derived from first principles or data characteristics. AWFESConfig provides unified configuration with log-spaced epoch generation, Bayesian variance derivation from search space, and market-specific annualization factors.
See references/configuration-framework.md for the full AWFESConfig class and compute_is_sharpe_threshold() implementation.
No trial-count corrections (operator rule, 2026-10-15): never compute, report, rank by or cite the Deflated Sharpe Ratio, the minimum backtest length (MinBTL) or any other trial-count correction (FWER/FDR procedures such as Holm or Benjamini-Yekutieli, e-LOND and other online multiple testing). Epoch-selection risk is handled by judging parsimony on the model itself (a small, pre-declared candidate set), by registration before runs and by unused data, and each rule reports its own statistics (Sharpe, PSR, MinTRL). The former DSR guardrail was removed on purpose; do not re-add it.
2/sqrt(n) adapts to sample sizeSee references/guardrails.md for full implementations of all guardrails.
Under the null hypothesis, WFE follows a Cauchy distribution (no defined mean). Always prefer median or pooled methods:
See references/wfe-aggregation.md for implementations and selection guide.
Pareto-optimal epoch selection: an epoch is on the frontier if no other epoch dominates it (better WFE AND lower training time). The AdaptiveEpochSelector class maintains state across folds with adaptive stability penalties.
See references/efficient-frontier.md for the full algorithm and carry-forward mechanism.
| Anti-Pattern | Symptom | Fix | Severity |
|---|---|---|---|
| Expanding window (range bars) | Train size grows per fold | Use fixed sliding window | CRITICAL |
| Peak picking | Best epoch always at sweep boundary | Expand range, check for plateau | HIGH |
| Insufficient folds | effective_n < 30 | Increase folds or data span | HIGH |
| Ignoring temporal autocorr | Folds correlated | Use purged CV, gap between folds | HIGH |
| Overfitting to IS | IS >> OOS Sharpe | Reduce epochs, add regularization | HIGH |
| sqrt(252) for crypto | Inflated Sharpe | Use sqrt(365) or sqrt(7) weekly | MEDIUM |
| Single epoch selection | No uncertainty quantification | Report confidence interval | MEDIUM |
| Meta-overfitting | Epoch selection itself overfits | Limit to 3-4 candidates max | HIGH |
CRITICAL: Never use expanding window for range bar ML training. See references/anti-patterns.md for the full analysis (Section 7).
See references/epoch-selection-decision-tree.md for the full practitioner decision tree.
Start
│
├─ IS_Sharpe > compute_is_sharpe_threshold(n)? ──NO──> Mark WFE invalid, use fallback
│ │ (threshold = 2/√n, adapts to sample size)
│ YES
│ │
├─ Compute WFE for each epoch
│ │
├─ Any WFE > 0.30? ──NO──> REJECT all epochs (severe overfit)
│ │ (guideline, not hard threshold)
│ YES
│ │
├─ Compute efficient frontier
│ │
├─ Apply AdaptiveStabilityPenalty
│ │ (threshold derived from WFE variance)
└─> Return selected epoch
This skill extends rangebar-eval-metrics:
| Metric Source | Used For | Reference |
|---|---|---|
sharpe_tw | WFE numerator (OOS) and denominator (IS) | range-bar-metrics.md |
n_bars | Sample size for aggregation weights | metrics-schema.md |
psr, min_trl | Final acceptance criteria | sharpe-formulas.md |
prediction_autocorr | Validate model isn't collapsed | ml-prediction-quality.md |
is_collapsed | Model health check | ml-prediction-quality.md |
| Extended risk metrics | Deep risk analysis (optional) | risk-metrics.md |
rangebar-eval-metrics:compute_metrics.pysharpe_tw as primary signalpsr > 0.85 and enough data for min_trl before deploymentis_collapsed and prediction_autocorr for model healthAWFES uses Nested WFO with three data splits per fold (Train 60% / Val 20% / Test 20%) with 6% embargo gaps at each boundary. The per-fold workflow: epoch sweep on train, WFE computation on validation, Bayesian update, final model training on train+val, evaluation on test.
See references/oos-workflow.md for the complete workflow with diagrams, BayesianEpochSelector class, and apply_awfes_to_test() implementation. Also see references/oos-application.md for the extended reference.
Bayesian updating (recommended) provides principled, uncertainty-aware smoothing. Alternatives include EMA and SMA. Initialization via AWFESConfig.from_search_space() derives variances from the epoch range automatically.
See references/epoch-smoothing-methods.md for all methods, formulas, and initialization strategies. See references/epoch-smoothing.md for extended mathematical analysis.
Three-tier metric hierarchy for test evaluation:
sharpe_tw, hit_rate, cumulative_pnl, positive_sharpe_folds, wfe_testmax_drawdown, calmar_ratio, profit_factor, cvar_10pctpsr, binomial_pvalue, hac_ttest_pvalueSee references/oos-metrics-implementation.md for full metric tables, compute_oos_metrics(), and fold aggregation code. See references/oos-metrics.md for threshold justifications.
CRITICAL (v3 fix): TEST must use prior_bayesian_epoch (from prior folds only), NOT val_optimal_epoch. The Bayesian update happens AFTER test evaluation, ensuring information flows only from past to present.
See references/look-ahead-bias-v3.md for the v3 fix details, embargo requirements, validation checklist, and anti-patterns. See references/look-ahead-bias.md for detailed examples.
| Topic | Reference File |
|---|---|
| Academic Literature | academic-foundations.md |
| Mathematical Formulation | mathematical-formulation.md |
| Configuration Framework | configuration-framework.md |
| Guardrails | guardrails.md |
| WFE Aggregation | wfe-aggregation.md |
| Efficient Frontier | efficient-frontier.md |
| Decision Tree | epoch-selection-decision-tree.md |
| Anti-Patterns | anti-patterns.md |
| OOS Workflow | oos-workflow.md |
| OOS Application | oos-application.md |
| Epoch Smoothing Methods | epoch-smoothing-methods.md |
| Epoch Smoothing Analysis | epoch-smoothing.md |
| OOS Metrics Impl | oos-metrics-implementation.md |
| OOS Metrics Thresholds | oos-metrics.md |
| Look-Ahead Bias (v3) | look-ahead-bias-v3.md |
| Look-Ahead Bias Examples | look-ahead-bias.md |
| Feature Sets | feature-sets.md |
| xLSTM Implementation | xlstm-implementation.md |
| Range Bar Metrics | range-bar-metrics.md |
| Troubleshooting | troubleshooting.md |
| Skill | Relationship |
|---|---|
| sharpe-ratio-non-iid-corrections | Generalized Sharpe variance, PSR, MinTRL |
| opendeviation-eval-metrics | Metric definitions consumed by WFE |
After this skill completes, check before closing:
Only update if the issue is real and reproducible — not speculative.
references/academic-foundations.md (opens in a new tab)references/anti-patterns.md (opens in a new tab)references/configuration-framework.md (opens in a new tab)references/efficient-frontier.md (opens in a new tab)references/epoch-selection-decision-tree.md (opens in a new tab)references/epoch-smoothing-methods.md (opens in a new tab)references/epoch-smoothing.md (opens in a new tab)references/evolution-log.md (opens in a new tab)references/feature-sets.md (opens in a new tab)references/guardrails.md (opens in a new tab)references/look-ahead-bias-v3.md (opens in a new tab)references/look-ahead-bias.md (opens in a new tab)references/mathematical-formulation.md (opens in a new tab)references/oos-application.md (opens in a new tab)references/oos-metrics-implementation.md (opens in a new tab)references/oos-metrics.md (opens in a new tab)references/oos-workflow.md (opens in a new tab)references/range-bar-metrics.md (opens in a new tab)references/troubleshooting.md (opens in a new tab)references/wfe-aggregation.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
8 skills in this plugin
/backtesting-py-oraclebacktesting.py configuration for SQL oracle validation and range bar pattern backtesting. Use when running backtesting.py against./evolutionary-metric-rankingMulti-objective evolutionary optimization for per-metric percentile cutoffs and intersection-based config selection./exchange-session-detectorDST-aware exchange session detection using exchange_calendars. Holiday & lunch break handling. TRIGGERS - exchange session, trading hours/odb-microstructure-forensicsInvestigate why ODB bars are oversized, have zero duration, or show anomalous price ranges by forensically analyzing Parquet./opendeviation-eval-metricsevaluating open deviation bar signal quality, computing Sharpe ratios with non-IID bars, running PSR/MinTRL statistical tests, or assessing ODB strategy performance./sharpe-ratio-non-iid-correctionsSharpe ratio inference for ONE strategy under non-Normal, serially correlated returns. Implements the ρ-corrected (AR(1), skew, kurtosis) Sharpe variance of López de Prado, Lipton & Zoonekynd (2026, Eq 2-3) and the single-test tools built on it: PSR, MinTRL, critical Sharpe ratio and test power. Numba JIT. Use when computing Sharpe significance, a Sharpe confidence band, minimum track record length or power with autocorrelation and fat tails. TRIGGERS - PSR, probabilistic sharpe ratio, MinTRL, minimum track record length, sharpe variance, non-iid sharpe, autocorrelated sharpe, sharpe significance, sharpe power./quant-research:adaptive-wfo-epochfrom quant-research
npx claudepluginhub terrylica/cc-skills --plugin quant-research