The Validation API sits at the gate between research and production: a strategy must pass rigorous out-of-sample validation before it can be promoted to live trading. Two complementary methods are exposed. Walk-forward analysis retrains the model and re-runs the signal pipeline on successive out-of-sample windows (rolling, expanding, or anchored), measuring whether performance holds up across folds and whether in-sample fit is inflated relative to out-of-sample results. Combinatorial Purged Cross-Validation (CPCV) goes further by generating all C(n, k) combinations of test folds, applying label-overlap purging and serial-correlation embargo to eliminate data leakage, and producing a distribution of OOS paths rather than a single estimate — enabling rigorous overfitting detection via the Probability of Backtest Overfitting (PBO) and the Deflated Sharpe Ratio. Every run is automatically logged to MLflow and linked to anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/najmulhossainnj/Hedge-fund-backend/llms.txt
Use this file to discover all available pages before exploring further.
Experiment row so the full history is retrievable by strategy.
Walk-Forward Analysis
Run Walk-Forward Validation
POST /api/v1/validation/walk-forward
Assembles the feature/target dataset for the specified strategy, splits it into train and test folds using the configured window method, trains the model plugin on each fold’s training window, generates OOS predictions, constructs a synthetic equity curve from the prediction sign, and computes out-of-sample metrics for every fold. The engine then evaluates four promotion gates and marks the strategy as validated in the database if all gates pass. The full result is logged to MLflow.
Request Body
UUID of the strategy being validated. Must exist in the database.
Key of the model plugin to use (e.g.
"gradient_boosting", "logistic_regression"). The key must be registered in the model plugin registry.Hyperparameter dict passed directly to the plugin constructor. Use the same params you would pass to
BacktestRunConfig.signal_plugin_params for the corresponding signal.List of feature UUIDs to include as model inputs. The dataset assembler fetches and aligns all listed features before splitting.
Ticker or instrument identifier used for market data alignment (e.g.
"AAPL", "BTC-USD").Bar size. Must match the resolution of the features (e.g.
"1d", "1h").Inclusive start of the dataset window. ISO-8601 format:
"2018-01-01T00:00:00".Exclusive end of the dataset window. ISO-8601 format:
"2024-01-01T00:00:00".Forward-return horizon in bars. A value of
1 means the target is the next bar’s return. Larger values produce multi-period labels.Used for annualising Sharpe and other metrics.
252 for daily, 52 for weekly, 12 for monthly.Optional validation and walk-forward configuration. All nested fields have defaults.
Response — WalkForwardResponse
UUID of the validated strategy.
true if all four promotion gates passed. The strategy’s database status is set to "validated" when this is true.Map of gate name to result object. Keys:
"oos_sharpe", "oos_max_drawdown", "profitable_folds", "overfit_ratio".Aggregate OOS statistics across all folds. Common keys:
| Key | Description |
|---|---|
mean_oos_sharpe | Mean Sharpe ratio across OOS folds |
std_oos_sharpe | Standard deviation of Sharpe across folds |
min_oos_sharpe | Worst single-fold Sharpe |
mean_oos_return | Mean total return across OOS folds |
std_oos_return | Standard deviation of returns across folds |
mean_oos_max_drawdown | Mean maximum drawdown across OOS folds |
worst_oos_drawdown | Worst single-fold drawdown |
n_profitable_folds | Number of folds with positive total return |
n_folds | Total number of folds evaluated |
Per-fold detail. One entry per fold that generated valid OOS metrics.
true when the coefficient of variation of OOS Sharpe ratios across folds is below 0.5 (std / |mean| < 0.5). Unstable Sharpe suggests the strategy is sensitive to the chosen evaluation window.true when the mean OOS Sharpe is positive.Ratio of mean IS directional accuracy to mean OOS Sharpe. Values near 1 indicate balanced in/out-of-sample performance. Values substantially above 1 indicate overfitting.
ID of the MLflow run where all fold metrics and aggregate statistics were logged. Use this to navigate directly to the run in the MLflow UI.
Dispatch Walk-Forward Async
POST /api/v1/validation/walk-forward/async
Accepts the same WalkForwardRequest body as the synchronous endpoint but immediately dispatches it as a Celery task and returns a task_id. Use this when the dataset is large or n_splits is high enough that synchronous execution would time out.
Request Body — identical to POST /api/v1/validation/walk-forward.
Response
Combinatorial Purged Cross-Validation (CPCV)
Probability of Backtest Overfitting (PBO) — introduced by Lopez de Prado in Advances in Financial Machine Learning (Ch. 14), PBO measures the fraction of OOS performance paths that underperform the median in-sample performance. A PBO near 0 means most OOS paths outperform IS, which is the opposite of overfitting. A PBO near 1 means the strategy almost always looks worse OOS than IS — a strong signal of overfitted parameters. The default gate rejects strategies with PBO > 0.6.Deflated Sharpe Ratio (DSR) — the best observed Sharpe ratio across multiple trials is an upwardly biased estimate because of selection bias: we naturally pick the best result. The DSR adjusts the best OOS Sharpe for the number of paths evaluated and the skewness/kurtosis of the Sharpe distribution, producing a more conservative estimate. The default gate requires DSR ≥ 0.1.
Run CPCV Validation
POST /api/v1/validation/cpcv
Runs Combinatorial Purged Cross-Validation on the assembled feature/target dataset. For each of the C(n_splits, n_test_splits) fold combinations, the engine trains the model plugin on the remaining folds (after purging and embargo), predicts on the test folds, and computes OOS metrics. The resulting distribution of OOS performance paths is used to compute PBO and the Deflated Sharpe Ratio. Three promotion gates are evaluated: minimum mean OOS Sharpe, maximum PBO, and minimum Deflated Sharpe.
Request Body
UUID of the strategy being validated.
Model plugin key (e.g.
"gradient_boosting", "logistic_regression").Hyperparameter dict passed to the plugin constructor.
Feature UUIDs included as model inputs.
Ticker or instrument identifier for market data alignment.
Bar size matching the feature resolution.
Inclusive start of the dataset window. ISO-8601:
"2018-01-01T00:00:00".Exclusive end of the dataset window. ISO-8601:
"2024-01-01T00:00:00".Forward-return horizon in bars. Used by the purging step to remove training samples whose label window overlaps with the test window.
Annualisation factor for Sharpe and other metrics.
CPCV splitting configuration.
Promotion gate: computed PBO must be ≤ this value. Values above 0.6 indicate unacceptable overfitting probability.
Promotion gate: Deflated Sharpe Ratio must be ≥ this value. Ensures the best observed OOS Sharpe survives selection-bias adjustment.
Promotion gate: mean OOS Sharpe across all CPCV paths must be ≥ this value.
Response
UUID string of the validated strategy.
true if all three CPCV promotion gates passed. The strategy’s status is set to "validated" in the database when this is true.Map of gate name to result. Keys:
"mean_oos_sharpe", "pbo", "deflated_sharpe".ID of the MLflow run where fold path metrics and aggregate stats were logged.
Echo of the CPCVConfig used:
n_splits, n_test_splits, embargo_pct, purge, target_horizon.Number of OOS performance paths evaluated. Equal to C(
n_splits, n_test_splits) minus any paths skipped due to insufficient data.Probability of Backtest Overfitting (0.0–1.0). Fraction of OOS paths whose Sharpe underperforms the median IS Sharpe proxy. Lower is better.
Deflated Sharpe Ratio. Best observed OOS Sharpe adjusted for selection bias across all paths. Higher is better; negative values indicate strong evidence of overfitting.
Aggregate statistics across all OOS paths.
Per-path detail. One entry per C(n, k) combination evaluated.
Dispatch CPCV Async
POST /api/v1/validation/cpcv/async
Accepts the same CPCVRequest body as the synchronous CPCV endpoint but dispatches immediately as a Celery task. Use for large datasets where C(n_splits, n_test_splits) produces many paths and synchronous execution would exceed request timeouts.
Request Body — identical to POST /api/v1/validation/cpcv.
Response
Validation History
Get Strategy Validation History
GET /api/v1/validation/strategies/{strategy_id}
Returns every validation experiment row associated with a strategy, ordered by creation time. Each entry represents one walk-forward or CPCV run. Where an MLflow run ID is present, the entry is enriched with the run_type tag from MLflow (e.g. "rolling", "expanding", "cpcv").
Path Parameters
UUID of the strategy whose validation history to retrieve.
Response
UUID string of the strategy.
Ordered list of validation experiment records. Most recent runs appear last.