Calibration and Selection
How Q7 searches each configuration's parameters with layered Bayesian optimisation, scores them on a day-clustered lower confidence bound, and chooses what ships by net profit with cross-validated evidence
Q7 AEGIS AI · CALIBRATION METHODOLOGY · S1 EDGEX · S1 GTRADE · S5 GTRADE
Methodology edition · November 2026 · Quant7 Alpha, LLC
Abstract
Each of Q7's forty-eight trading configurations — three algorithms, four assets, four timeframes — carries its own set of about 420 calibrated parameters. This paper sets out how those values are found and how the one set that ships is chosen. The population of parameters is declared in advance from the Python engine itself, with every range written down and every risk rule held fixed. The search is Bayesian optimisation with a tree-structured Parzen estimator, run in stages that follow the causal chain of a trade, each carrying the best settings found so far, and ending with a joint stage over every parameter. A trial is scored on the optimisation window only, by its net profit per trade less one day-clustered standard error, times the number of trades; win rate, profit factor and a quarterly loss limit are constraints, not score terms. Selection replays the 200 best trials once over the optimisation and validation windows, scores them on fifteen purged and embargoed cross-validation test pairs, reports the deflated Sharpe ratio and the probability of backtest overfitting, and ships the candidate with the highest net profit, with its out-of-sample evidence published beside it as a label. A sealed holdout is read by neither stage.
1 · What calibration must deliver
Calibration has one purpose: parameters that make money after every cost, chosen without looking at the data used to judge them. Three requirements follow, and each is enforced in code:
- The engine is the authority. The parameters searched are exactly those the Python engine reads. A searched parameter the engine never reads stops the run; a parameter the engine reads but the search does not cover is held at a declared value and listed.
- Nothing held out leaks in. The search reads only the optimisation window. Selection reads the optimisation and validation windows. The sealed holdout is read by neither.
- Evidence travels with the choice. Every shipped configuration carries its validation result, its cross-validated stability, its deflated Sharpe ratio and its probability of backtest overfitting, so the order in which capital is armed is set by evidence.
┌─────────────────┐ ┌────────────────────────┐ ┌─────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
│ POPULATION │ │ LAYERED SEARCH │ │ SHORTLIST │ │ REPLAY · CPCV │ │ CHOICE │
│ 420 parameters │ ──> │ TPE · 16–18 stages │ ──> │ 200 best trials │ ──> │ opt + validation │ ──> │ highest net profit │
│per configuration│ │ + joint stage │ │ by search score │ │ 15 test pairs │ │ + evidence label │
│ declared ranges │ │ optimisation window │ │ de-duplicated │ │ purged · embargoed │ │ every config ships │
└─────────────────┘ └────────────────────────┘ └─────────────────┘ └──────────────────────┘ └──────────────────────┘
[ WHAT ] [ SEARCH ] [ CANDIDATES ] [ EVIDENCE ] [ DECISION ]
Figure 1. The calibration pipeline for one configuration. The population is declared; the layered search explores it on the optimisation window; the 200 best trials are replayed and cross-validated; the candidate with the highest net profit ships with its evidence label. The search reads only the optimisation window — the sealed holdout is read by neither the search nor selection.
2 · The population of parameters
Every parameter of a configuration is named by the configuration it belongs to, i_<ASSET>_<TF>_<stem>, so no value is shared between configurations by assumption. The population is the set of stems the engine reads, enumerated from the Python code, never from a downstream copy. For each algorithm a range authority declares every stem's status — searched, held or derived — and, for each configuration, its range or held value with its source; a classification assigns each stem to a family; and a search design pins both by cryptographic hash. A run refuses to start unless the authority and the engine's parameter registry cover each other exactly.
Three kinds of parameter are never searched: the risk rules (drawdown budgets, daily and weekly loss limits, the liquidation guard, the account ceiling), the shape of the four-leg exit ladder, and parameters a ruling has retired. A retired parameter is held at a declared value and marked inactive in the engine, so the engine proves at run time that it does not read it. When the stop was redesigned to be computed from each trade's own information, for example, its leverage exponent and volatility ceiling were retired, and so was the margin fraction, which is now derived from each trade.
| Algorithm | Searched per Configuration | Search Stages |
|---|---|---|
| S1 EdgeX | 416 | 16 + joint |
| S1 gTrade | 421 | 17 + joint |
| S5 gTrade | 423 | 18 + joint |
Table 1. Searched parameters per configuration at the time of writing. Each algorithm has sixteen configurations; each run records its own population in its study files.
3 · Data windows
Each configuration's history is cut into three consecutive windows. The search optimises on the first; selection judges on the first two; the third is sealed for forward evaluation.
| Algorithm | Optimisation Window | Validation Window | Sealed Holdout |
|---|---|---|---|
| S1 gTrade | 19 Aug 2024 – 30 Jun 2026 | 1 Jul – 7 Oct 2026¹ | from 8 Oct 2026 |
| S1 EdgeX | 16 May – 7 Sep 2026² | 8 – 30 Sep 2026 | from 8 Oct 2026 |
| S5 gTrade | per asset, from Dec 2025 – Apr 2026³ | last fifth of each asset's span, to 30 Jun 2026 | from 1 Jul 2026 |
Table 2. Data windows at the time of writing; each run's design records its own, and each algorithm paper states its current windows. ¹ 1–7 Oct 2026 was read once for a venue price comparison; it is excluded from scoring and disclosed. ² XRP from its listing on 28 May 2026. ³ Each asset begins on the first day of the tape of record (gold 11 Dec 2025, silver 7 Jan, platinum 30 Jan, crude 1 Apr 2026).
The validation windows have been read in earlier research cycles, so they are a check rather than independent proof; the sealed holdout and forward paper trading are the independent evidence. Every input at a bar is computed from that bar and earlier bars only, and every data set is pinned by the hash of its checksum file.
4 · One trial
A trial is one complete set of parameter values for one configuration. It is run once through the same engine that trades live, with the same fill model: a target fills only when price trades through it, a stop pays the measured 90th-percentile slippage, a bar that touches both a stop and a target is resolved against the trade, and a level set on a bar takes effect only from that bar's close. Every cost — fees, spread, funding and borrowing — is charged.
Each of the four entry engines is also run on its own. The trial's book is the set of engines that each make money on the optimisation window with at least 30 trades of their own; if none qualifies, the book is every engine that is switched on, so a losing trial is still scored at its true result. The book is what is scored and what selection later replays.
5 · The objective
The search maximises a lower confidence bound on profit rather than profit itself, so a few lucky trades cannot outrank a steady record. For a book with $n$ trades of net profit $x_i$ (in dollars, after all costs) entered on $G$ distinct calendar days:
$$S = (\bar{x} - k \cdot \text{SE}_{\text{day}}) \cdot n, \quad k = 1 \tag{1}$$
$$\text{SE}{\text{day}} = \frac{1}{n} \sqrt{\frac{G}{G - 1} \sum{g} \left( \sum_{i \in g} (x_i - \bar{x}) \right)^2} \tag{2}$$
$\text{SE}_{\text{day}}$ is the standard error of the mean trade, clustered by the calendar day of entry [12], so twenty trades taken on one volatile afternoon count as one piece of evidence, not twenty. $S$ grows with the number of trades only when the edge per trade is consistent; with fewer than two trading days it is zero.
Three conditions are constraints, handled by the sampler's feasibility model rather than added to the score [4]:
- Win rate above 55%, judged on the win rate shrunk toward 50% by five trades on each side, $(\text{wins} + 5) / (n + 10)$ [13]: 8 wins in 10 counts as 65%, 1 win in 1 as 55% — not enough.
- Profit factor above 1.10, gross profit over gross loss.
- No calendar quarter losing more than 15% of the configuration's capital, its drawdown budget.
An infeasible trial is scored below every feasible one, by how far it misses: its net if negative, less $10,000 per point of win-rate shortfall and $100,000 per unit of profit-factor shortfall. The search can therefore climb toward feasibility, and a trial that does not trade is never rewarded. A book with fewer than five trades ranks below everything. There is no minimum trade count and no reward for trading more.
6 · The sampler
The search uses the tree-structured Parzen estimator (TPE) [1, 2, 3] of the Optuna framework [5]. TPE splits the trials so far into a good and a poor group by score and proposes the next values where the density of the good group is high relative to the poor one. Three options matter:
- Multivariate TPE models the parameters jointly, so interacting values — a stop and its target — are learned together.
- Grouped TPE handles parameters that exist only when a switch is on.
- The constant liar [6] lets parallel workers propose without duplicating each other, by treating trials still running as poor.
Feasibility enters through the constrained variant of TPE [4]: feasible trials always rank above infeasible ones when the groups are formed.
Each stage begins with a random phase — the smaller of its parameter count and a quarter of its budget, at least ten trials — before TPE takes over. The seed is derived from the algorithm, the configuration and the run, so a study is reproducible on the pinned toolchain (Python 3.12, Optuna 5.0.0, NumPy 1.26.4).
7 · The layered search
About 420 parameters cannot be calibrated well in a single stage within a working day: the useful region is too small in so many dimensions. The search therefore follows the causal chain of a trade, one layer at a time, and ends with every parameter together.
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ L1a │ │ L1b │ │ L1c │ │ L2 │ │ L3 │ │ L4 │ │ L5 │ │ L6 │ │ L7 │
│entry engines │ ──> │ confluence │ ──> │ regime gates │ ──> │ order flow + │ ──> │ stop + │ ──> │ targets │ ──> │ trade │ ──> │ size │ ──> │ every │
│ │ │ │ │ │ │ research │ │ leverage │ │ │ │ management │ │ │ │ parameter │
└──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
◄────────────────── STAGES L1–L6: ~22 TRIALS PER PARAMETER, PATIENCE STOP ──────────────────► ◄────────────── L7: 30% OF TIME ─────────────►
Figure 2. The search stages. Each stage searches its own parameters with the rest held at a carried vector; L1 and L2 are split into sub-stages of at most 40 parameters. The joint stage L7 searches every parameter around the best vectors found.
- Stages. Each parameter is placed in exactly one stage by a fixed rule on its name: entry engines, confluence and regime gates (L1); one stage per family of order-flow and research evidence (L2); stop and leverage (L3); profit targets (L4); trade management (L5); size and the risk budget (L6). A parameter no rule places stops the run. A stage holds at most forty parameters; a larger one is split along family lines, keeping parameters whose order is enforced — a lower before an upper threshold — together.
- Carry. The five best feasible parameter vectors so far form a pool. A stage draws its own parameters together with a choice of which pooled vector supplies all the others, so TPE learns which context its values work in. After the stage the pool is the five best of the incoming pool and the stage's trials: a stage that improves nothing leaves it unchanged. The pool starts from a trading base vector and from warm-start vectors of earlier runs, each re-scored under this run's objective — a score is never copied.
- Budget. Each stage plans about 22 trials per parameter, at least 200; the joint stage plans 30% of the total, at least 1,200, and begins from every stage's five best trials. The run has a wall-clock deadline: each stage receives its planned share of the time remaining when it starts, and the joint stage is never skipped. A stage also stops once 300 trials have run and the last 220 have not improved its best (twice both numbers for the entry stage, which on earlier runs produced most of the gain). The entry engines are held on until the joint stage, which alone may switch one off.
- Record. Every trial — its values, book, net, trades, win rate, profit factor, drawdown, quarterly results and score — is written to an append-only journal. An interrupted study is resumed from its journal, never restarted, and refuses to resume if the engine, design or stage rules differ by one byte.
8 · Selection
Selection is a separate step that reads the finished study and never changes it.
- Shortlist. Every completed trial is de-duplicated by its parameter vector and ranked by the score it gave the search, feasible trials first. The 200 best form the shortlist.
- Replay. Each shortlisted book is run once over the optimisation and validation windows together, with exactly its own engines, and its trade list is kept. Everything that follows is computed from those trade lists; nothing is re-fitted.
- Cross-validation. The span is cut into six contiguous groups of equal time, and every pair of groups serves as a test set: $C(6, 2) = 15$ test pairs [7]. A trade counts in a group only if it enters and exits inside it; a trade that crosses a boundary is purged. After the start of each test block, trades entering within an embargo are dropped; the embargo is the candidate's own longest holding time over the span, which for a fixed set of parameters is the exact bound on leakage across the boundary. Each candidate receives fifteen test-pair results — net, win rate, profit factor and trades — with their median, minimum, maximum and the share that are profitable.
9 · Overfitting statistics
- Probability of backtest overfitting (PBO). The six groups are split into every pair of halves, twenty splits in all [9]. In each, the candidate best on one half is ranked on the other; the probability of backtest overfitting is the share of splits in which it ranks at or below the median. Near zero, the best in-sample candidate stays good out of sample; near one, the ranking does not carry over. It varies widely across configurations, which is itself a reason not to rely on any single ranking.
- Deflated Sharpe ratio (DSR). The deflated Sharpe ratio [8] asks how likely a candidate's Sharpe ratio is to exceed the best that luck alone would produce among $N$ trials. On the daily series of return on risk — each day's trade profits divided by each trade's worst-case loss — with $T$ days, Sharpe ratio $\text{SR}$, skewness $\gamma_3$ and kurtosis $\gamma_4$:
$$\text{SR}_0 = \sqrt{V} \cdot \left[ (1 - \gamma)\Phi^{-1}(1 - 1/N) + \gamma\Phi^{-1}(1 - 1/(N e)) \right] \tag{3}$$
$$\text{DSR} = \Phi\left( \frac{(\text{SR} - \text{SR}_0)\sqrt{T - 1}}{\sqrt{1 - \gamma_3 \text{SR} + \frac{\gamma_4 - 1}{4}\text{SR}^2}} \right) \tag{4}$$
$\gamma$ is Euler's constant, $\Phi$ the standard normal distribution, $N$ the study's completed trials and $V$ the variance of the Sharpe ratio across trials [8, 10].
10 · The choice
Every configuration ships. Among its 200 candidates, the one with the highest net profit over the replayed span is chosen (founder, 9 November 2026: "we need net P&L — we are trying to make money"; "rank by net P&L first"). Its evidence is published as a label, which sets the order in which capital is armed and never removes a configuration:
| Label | Evidence on the Validation Window and the Test Pairs |
|---|---|
| PASS | validation net > 0; profit factor > 1.10; median test-pair net > 0; at least 60% of test pairs profitable |
| FLEX | validation net > 0; profit factor > 1.0; median test-pair net > 0 |
| NET+ | validation net > 0, missing a profit-factor or test-pair condition |
| NO-EVIDENCE | no trade in the validation window |
| PAPER-ONLY | validation net at or below zero |
Table 3. Evidence labels. There is no win-rate floor in the labels (founder, 9 November 2026); win rate is reported.
Each shipped configuration reports its win rate, profit factor, net profit, deflated Sharpe ratio, probability of backtest overfitting and trades, over the span and over the validation window. Ranking by net profit over the whole span favours the candidates that fitted the optimisation window best, so the validation result is the first figure to read: a configuration whose span profit is large but whose validation result is negative is labelled PAPER-ONLY and proves itself in forward paper trading before capital is armed.
10.1 The per-trade risk budget
The per-trade risk budget — the loss at the stop as a share of capital — is searched per configuration between 0.5% and 15%. What a configuration can carry depends on its own edge. A block bootstrap [11] of three configurations' own trade sequences (measured in November 2026) gave:
| Configuration | Trades | Win Rate | Kelly Fraction | $P(\text{Drawdown} \ge 15%)$ at 2.5% / 5.0% / 7.5% |
|---|---|---|---|---|
| S5 XAU 15-min | 62 | 64.5% | 6.3% | 0.4% / 33% / 82% |
| EdgeX BTC 15-min | 151 | 43.0% | negative | 99% / 100% / 100% |
| gTrade XRP 15-min | 1,841 | 44.0% | negative | 100% at every budget |
Table 4. The budget a configuration can carry is set by its own edge; no single fixed value is supported. Kelly fraction [14] from the configuration's own trades.
Each selected budget is reported beside the configuration's own Kelly fraction, and a budget far above half of it is flagged before shipping.
11 · Governance and limits
Each run is bound to a frozen copy of the code, identified by its git tree id, and to a search design and data sets pinned by hash; a pre-flight check refuses to launch if any differs, or if the machine lacks the memory for its workers. The party that builds a run does not certify it: an independent verifier signs off changes to the engine, and only the founder arms capital. Every selected configuration is replayed from its stored record on the pinned engine before packaging and must reproduce it trade for trade [15].
- Few trades. Several configurations have only a handful of trades in the validation window; their labels rest on little evidence, and forward trading is the test.
- In-sample span. Span profit includes the window the search tuned on and is optimistic by construction; the validation result and the sealed holdout are the honest figures.
- Re-read windows. The validation windows have been read in earlier cycles.
- Venue prices. S5 is calibrated on the underlying futures and trades on gTrade's prices, which track them closely but not exactly.
Risk & Supervisory Disclosure
Trading leveraged perpetual contracts carries a high risk of loss, including the loss of all capital allocated. Calibration and selection describe how parameters are chosen on historical data; they do not guarantee any outcome, and historical results do not predict future returns. This document describes methodology only and is not an offer, a solicitation or investment advice. Parameter values are calibrated per configuration and are not published here.
References
- J. Bergstra, R. Bardenet, Y. Bengio and B. Kégl (2011). Algorithms for hyper-parameter optimization. Advances in Neural Information Processing Systems 24.
- J. Bergstra, D. Yamins and D. Cox (2013). Making a science of model search: hyperparameter optimization in hundreds of dimensions for vision architectures. Proceedings of ICML, PMLR 28(1), 115–123.
- S. Watanabe (2023). Tree-structured Parzen estimator: understanding its algorithm components and their roles for better empirical performance. arXiv:2304.11127.
- S. Watanabe and F. Hutter (2023). c-TPE: tree-structured Parzen estimator with inequality constraints for expensive hyperparameter optimization. Proceedings of IJCAI; arXiv:2211.14411.
- T. Akiba, S. Sano, T. Yanase, T. Ohta and M. Koyama (2019). Optuna: a next-generation hyperparameter optimization framework. Proceedings of KDD, 2623–2631.
- D. Ginsbourger, R. Le Riche and L. Carraro (2010). Kriging is well-suited to parallelize optimization. In Computational Intelligence in Expensive Optimization Problems, Springer, 131–162.
- M. López de Prado (2018). Advances in Financial Machine Learning. Wiley.
- D. H. Bailey and M. López de Prado (2014). The deflated Sharpe ratio: correcting for selection bias, backtest overfitting and non-normality. Journal of Portfolio Management 40(5), 94–107.
- D. H. Bailey, J. M. Borwein, M. López de Prado and Q. J. Zhu (2017). The probability of backtest overfitting. Journal of Computational Finance 20(4), 39–69.
- D. H. Bailey and M. López de Prado (2012). The Sharpe ratio efficient frontier. Journal of Risk 15(2), 3–44.
- D. N. Politis and J. P. Romano (1994). The stationary bootstrap. Journal of the American Statistical Association 89(428), 1303–1313.
- A. C. Cameron, J. B. Gelbach and D. L. Miller (2011). Robust inference with multiway clustering. Journal of Business & Economic Statistics 29(2), 238–249.
- B. Efron and C. Morris (1975). Data analysis using Stein's estimator and its generalizations. Journal of the American Statistical Association 70(350), 311–319.
- J. L. Kelly (1956). A new interpretation of information rate. Bell System Technical Journal 35(4), 917–926.
- C. R. Harvey and Y. Liu (2015). Backtesting. Journal of Portfolio Management 42(1), 13–28.

