Software · Quant research
SPD Parameter Optimizer FakeSPD 参数 × 合约对 优化
Every tradable calendar spread, at every setting, replayed tick by tick. It ranks the most profitable, and the desk traded its picks live.
01System architecture
One search loop around a validated backtest engine, with an independent re-run before anything is reported.
Two constraints shaped it. It runs on a standard office PC with a standard-library Python and no numerical packages. And a single evaluation is a full tick-by-tick replay of one trading day, so every wasted evaluation costs minutes.
Market data
Tick database
Every tick of every contract, and the spread contracts the exchange lists.
Read-only
One-click data pull
Self-dating: a window of recent settled trading days for every product in the cycle.
Office PC · 16 worker processes
Optimizer
Builds the pairings, applies the tradability rules, runs the staged search, checkpoints every stage.
Called unchanged
FakeSPD backtest engine
Replays one pair on one day, tick by tick. About 0.45 s per replay.
Independent driver
Verification battery
A separate fixed-pair driver re-runs every frontier and menu row on all days. A mismatch is flagged, never published.
HTML reports
Frontier and menu
Per product: the Pareto frontier and the top 3 spreads × 5 settings, with market share, day-by-day stability and shared legs flagged.
The desk
Live spread engine
Traders choose which menu rows to trade.
Simplified: the live progress page, the stage checkpoints that let a run resume after a restart, and the side-run tools for other exchanges are left out.
Why the engine is called unchanged
The engine is Shuo’s FakeSPD backtester, already reconciled against the desk’s reference. The optimizer only filters the day’s ticks to one pair before each call, so a search result and a hand-run backtest are the same number.
Lessons become constraints
When a result depends on something the backtest gets for free, the fix goes into every stage of the search as a hard constraint, not into a footnote of the report. A backtest that closes flat every session carries inventory at no cost, so every setting the search tries must now lean against its inventory.
Runs unattended
A waiter starts the cycle when the pull lands, each stage is checkpointed, a crashed or restarted run resumes, and a live page shows per-worker progress and a time estimate.
02The story
Thousands of combinations per commodity, every one backtested. The desk traded its picks.
Which calendar spreads should a market-making desk quote, and at what settings? There are thousands of combinations per commodity, and judging a single one means replaying weeks of market data tick by tick. Shuo conceived, designed and built from scratch, on his own initiative, a program that tests them all, ranks the most profitable and re-verifies every result before reporting it. The desk traded its picks.1
01
The problem
The desk is a market maker: it continuously posts a price to buy and a price to sell, and earns the gap between them. A calendar spread is the price gap between two delivery months of one commodity, say January and May palm oil, and the desk quotes both sides of that gap too. Two choices decide whether it makes money: which pair of months to quote, and how: how far from fair value to quote, when to pull a quote, how hard to lean against inventory, and how much history the fair value averages.
Until this project, every test used one pair per product, the two busiest months, at one default set of settings. Shuo suspected the settings, not the idea, and a sweep of his own showed it: the backtested result swung with the quote distance, and the best values sat well away from the default.
- Several live contracts per product, paired in both leg orders, with four continuous settings: thousands of combinations
- Each one needs every tick of every day replayed; a brute-force grid would take about 14 hours per product on one core
02
What he built
In his words: for a commodity such as palm oil, run the strategy backtest on every spread the exchange lists and every candidate parameter value, and take the most profitable one. Profit maximization by exhaustive optimization.2
Think of a kitchen testing every dish on the menu at every oven temperature, but tasting after the first few days and only cooking on with the recipes that are still in the running. Nothing is skipped; weak candidates just stop consuming days.
The first version was running, and reproducing a reference backtest to the last lot, the same morning he asked the question (Sep 4, 2026). He presented its first results in a meeting that afternoon. The design decisions are his:
- Two scores, not one. A market maker’s volume is limited by exchange rules and risk limits, so profit per lot matters as much as total profit. The result is a frontier of best trade-offs, not a single winner.
- Only what can be traded. One product’s first winner was a pair the exchange does not list as a spread. He caught it that night and made tradability a constraint of the search.
- A menu, not an answer. A product can run several spreads at once, so each gets its top three spreads with five settings apiece.
- Nothing reported unchecked. Every row is re-run by a separate program and must match: 747 of 747.3
- Fast enough to use. Weak candidates stop early and 16 processes run in parallel, so a six-product cycle of about 200,000 day-replays finishes unattended on one office PC.4
03
What changed
The desk traded its picks. Configurations from the optimizer’s menus went into the desk’s live spread engine; each was a row of the optimizer’s output, and the desk chose which to trade.1
A blind spot became a rule. A backtest that closes flat every session carries inventory for free, so an unconstrained search favors settings that never lean against their own inventory: a shopkeeper who never marks down overstocked goods looks profitable until the stockroom overflows. Shuo made “always lean against inventory” a hard constraint in every stage of the search. It split the field cleanly: spreads that earn from quoting kept most of their result, while the ones that had only looked good by holding a position lost most of theirs.5
It held up on data it had never seen. In a formal hold-out, every recommended setting was replayed unchanged on earlier trading days the search never saw, and all of them stayed profitable. The widest-quote settings decayed most, and a longer lookback that won in sample lost on the hold-out and was rejected.6
It became the desk’s spread-research tool. Colleagues brought it their own questions from the day it first ran, including a side run on another exchange that was searched and reported the morning it was requested. In its first two months it searched 16 commodities on three exchanges.7
It says no when the answer is no. On one exchange the search’s own winners looked large. Shuo’s two follow-up checks traced the profit to a data-timing artifact and to spreads that cannot be quoted as one contract, and his report recommended not trading them.
Putting its picks live also led Shuo to ship Strategy Console 2.0, which writes all of a strategy’s files in one checked save that rolls back on any failure.
03Evidence
One rule split quoting income from inventory bets; unseen days confirmed the picks.
Both charts are drawn from synthetic data, generated to show the shape of each result. The method is as built; the desk’s own figures are confidential.
One rule split quoting income from position-taking
A backtest that closes flat every session makes inventory free, so an unconstrained search favors settings that never lean against it. With leaning against inventory required in every stage, spreads that earn from quoting kept most of their result; the ones that had only looked good by holding a position lost most of theirs.
Best backtested result per spread, before and after the floor
Spreads that earn from quoting kept most of their result under the floor; spreads that had earned by carrying inventory kept a small fraction.
Show the dataHide the data
| Spread | Without the floor | With the floor | Change |
|---|---|---|---|
| Spread A | 100% | 82% | −18% |
| Spread B | 100% | 78% | −22% |
| Spread C | 100% | 74% | −26% |
| Spread D | 100% | 69% | −31% |
| Spread E | 100% | 64% | −36% |
| Spread F | 100% | 14% | −86% |
| Spread G | 100% | 14% | −86% |
| Spread H | 100% | 13% | −87% |
| Spread I | 100% | 12% | −88% |
Every recommended setting stayed profitable on days the search never saw
The menu was chosen on the search window; then every row was replayed unchanged on earlier trading days the search never saw.
Recommended rows: in sample and on the hold-out
All of them stayed profitable on the unseen days, and the ranking largely held: the settings that earned most in sample also tended to earn most out of sample.
Show the dataHide the data
| Series | Daily profit in sample (index) | Daily profit on the hold-out (index) |
|---|---|---|
| Recommended rows | 76.9 | 16.9 |
| Recommended rows | 64.6 | 10.2 |
| Recommended rows | 47.8 | 8.1 |
| Recommended rows | 37.4 | 2.0 |
| Recommended rows | 85.1 | 12.7 |
| Recommended rows | 71.5 | 10.1 |
| Recommended rows | 53.7 | 6.8 |
| Recommended rows | 40.6 | 13.1 |
| Recommended rows | 34.4 | 9.9 |
| Recommended rows | 61.0 | 16.1 |
| Recommended rows | 49.1 | 12.6 |
| Recommended rows | 40.6 | 8.8 |
| Recommended rows | 38.7 | 4.1 |
| Recommended rows | 30.2 | 2.8 |
| Top row | 100.0 | 30.6 |
04Functions
From a database pull to a verified menu
A
Pull the data in one click
One click fetches everything a cycle needs, read-only, and dates itself.
- A window of recent settled trading days of ticks for every product in the cycle
- The exchange’s own list of spread contracts, day by day
- A shorter window is cut from a pull already on disk in 34 seconds, with no second trip to the database
B
Build every pairing that can be traded
The most-traded contracts plus the market-maker-designated ones, paired in both leg orders, then filtered by what the desk can actually quote.
- Only spreads the exchange lists; ids normalized near month first so a tradable pair is never rejected by its spelling
- Contracts in, or about to enter, their delivery month are excluded
- Tick size and session hours are inferred from the data and checked against the database
C
Search the whole grid, spend days only on contenders
Every listed pair and every grid cell is backtested; after each block of days the weaker settings stop and the survivors run on.
- Both scores vote at each cut: top half by total profit, plus top half by profit per lot
- Half-step refinement around each pair’s leaders
- A leader on the edge of the grid pushes the grid outward, up to four passes
D
Read a frontier and a menu
Per product: the Pareto frontier of total profit against profit per lot, and the top three spreads with five settings each.
- Each row shows its share of market volume, profitable days and profit in four consecutive blocks of days
- Spreads that share a leg are flagged; subtotals are stated as upper bounds
- Rows pinned to the volume floor are marked as not tradable at scale
Frontier of one search
There is no single best setting: along the frontier, several times the profit per lot costs most of the total.
Show the dataHide the data
| Series | Profit per lot (index) | Total profit (index) |
|---|---|---|
| Frontier settings | 30.95 | 100.00 |
| Frontier settings | 35.04 | 96.18 |
| Frontier settings | 38.36 | 88.57 |
| Frontier settings | 42.38 | 81.67 |
| Frontier settings | 43.46 | 76.90 |
| Frontier settings | 43.85 | 76.89 |
| Frontier settings | 46.40 | 75.43 |
| Frontier settings | 51.13 | 75.36 |
| Frontier settings | 55.09 | 74.63 |
| Frontier settings | 57.46 | 65.62 |
| Frontier settings | 61.79 | 64.62 |
| Frontier settings | 65.98 | 62.71 |
| Frontier settings | 68.90 | 55.28 |
| Frontier settings | 72.49 | 53.17 |
| Frontier settings | 77.99 | 52.08 |
| Frontier settings | 88.42 | 49.71 |
| Frontier settings | 89.34 | 47.75 |
| Frontier settings | 93.19 | 45.96 |
| Frontier settings | 95.35 | 44.75 |
| Frontier settings | 98.13 | 41.80 |
| Frontier settings | 99.54 | 39.19 |
| Frontier settings | 100.00 | 37.35 |
E
Trust nothing until it is re-run
Every frontier and menu row is replayed on all days by an independent driver and must match to the lot.
- 747 of 747 reported rows matched3
- Per-lot plausibility scan and frontier-integrity checks catch what a match cannot
- Hold-out re-runs, same-snapshot re-runs and a legging model for spreads with no listed contract
F
Leave it running
A six-product cycle runs for hours on one office PC without anyone watching it.
- Starts by itself when the pull lands; every stage checkpointed; resumes after a crash or a forced restart
- Live progress page with per-worker heartbeats and a time estimate
- Exchange-aware: Dalian, Zhengzhou and Shanghai contract codes, spread ids and sessions
05How it works
One commodity, end to end: every listed spread, every cell, a verified menu
One commodity through the search
Synthetic data. An illustrative run of the optimizer’s procedure, step by step, on one generated commodity: every count, cut and curve comes from that run, not from a desk run, and all results are backtests. The last step is stated in words: the desk traded the optimizer’s picks; which configurations, when, and their results are confidential.
Text description of this figure
Three panels follow one generated commodity through the optimizer, step by step; every count comes from that synthetic run. Panel one, which pairs can be traded: of 11 contracts, 3 in or near delivery are dropped. The 3 most-traded contracts each serve as the trigger leg against each of the 7 other contracts, giving 21 pairings. Only 12 of them are listed by the exchange as a spread contract; the other 9 are hatched because they cannot be quoted. A 3-day screen at 4 quote edges and 4 lookbacks per pair keeps the union of the top half by total and the top half by profit per lot, 7 pairs, which finish the remaining 27 days, and 4 pairs are shortlisted. Panel two, the parameter grid: one block per shortlisted pair, labeled Spread A to Spread D, each 12 quote edges wide and 12 rows deep (3 withdraw distances times 4 inventory-skew levels). Twelve cells per block are hatched because the withdraw distance must be smaller than the quote edge, leaving 132 cells per pair and 528 configurations, each replayed at 3 or 4 lookbacks on the FakeSPD engine. The skew axis starts at a floor tied to the quote edge and never reaches zero, because a backtest carries inventory for free and live trading does not; trade size and quote levels are held fixed, and since skew is set per lot its axis already spans size. All four blocks are swept in parallel on the first 3 days (5,544 backtests), and a marker follows the leader by total as it changes hands. Because a market maker’s volume is limited, profit per lot is a goal of its own: the search keeps the top half by total profit together with the top half by profit per lot, 292 configurations rather than 264, and runs them to day 6 (3,027 backtests); the same cut leaves 234 for the remaining 24 days (18,744 backtests), and the early leader is overtaken. The search then refines at half steps around each pair’s leaders and extends the grid when a leader sits on its edge. A curve of the best result found so far rises against the number of backtests run, which ends at 63,435 for this one commodity. Panel three: a 22-row frontier becomes a ranked menu of 3 spreads (Spread A, Spread B and Spread C) with 5 settings each, running from most total profit to most profit per lot, and every row is re-run by a second, independent driver and required to match. Held-out days: every menu row is replayed unchanged on the 12 trading days before the search window, and all 15 stay profitable; the top row keeps 61% of its profit per lot, the widest-quote rows less. In use: the desk traded the optimizer’s picks; which configurations, when, and their results are confidential and are not part of this illustration.
06Under the hood
The optimization problem, the search and the evidence
Under the hoodObjective, search space, successive halving, constraints, pseudo-code, validation and results
For a quant or an ML engineer: this is hyperparameter and configuration selection on an expensive, noisy, non-differentiable black box, solved as a two-objective, multi-fidelity search. One function evaluation is a full tick replay of a trading day; the objective has two components; the feasible set is defined by the exchange, not by the model; and selecting among more than a thousand noisy estimates invites the winner’s curse. The sections below give the full problem statement, the search design, why the obvious alternatives were rejected, pseudo-code of the key rules and the out-of-sample evidence; every counted example is a synthetic run of the same procedure.8
Objective: two components, no fee term
For a product, let be an ordered pair of contracts (trigger leg, quoted leg) and the quoting parameters: quote edge (ticks from fair value), withdraw threshold , inventory-skew gain and the lookback of the fair-value moving average, counted in trigger-leg updates. is the backtested profit on day and the lots traded over the days of the window.
Fees are left out of the objective because market-making volume is largely fee-exempt, so there is no fee break-even term. A market maker’s volume is constrained by exchange self-trade rules and risk limits, so profit per lot is an objective in its own right. Shuo set both as first-class: the result is the Pareto set over (total, per lot), reported with each row’s share of the thinner leg’s market volume. Trade size is held fixed in the backtest because the skew acts per lot, so the skew grid already spans it.
Feasible set: the exchange and the data define it
Four constraints, each added for a reason found in the data:
- Listed spreads only. The desk quotes the exchange’s spread contract, so a pair with no listed spread cannot be quoted at all. Added the night one product’s first winner turned out to be unlisted. Listing must hold over the whole window.
- Withdraw inside the edge, by construction of the strategy.
- Skew floor , enforced in every stage: the screen never quotes below the floor, the grid uses 1 to 4 times the floor so every edge keeps four admissible skew levels, and refinement rejects any point below it. The fraction is not published.
- Volume floor of lots a day, purely statistical: profit per lot on a handful of lots is noise. Violators are reported, never ranked.
Hygiene before any screening: contracts in their delivery month, or entering it within a month after the window, are excluded (one-sided books); a quoted leg must be present on at least 90% of days; the trigger leg must be among the three most-traded contracts.
Search space, counted on a synthetic run
Both leg orders of a pair are tried because the trigger leg sets the decision clock: (A triggers, B quoted) and (B triggers, A quoted) are different simulations of the same listed spread. The grid is quote edges in half-tick steps × 3 withdraw thresholds × 4 skew levels, with withdraw below edge, each cell at that pair’s best three lookbacks from the screen plus a short one, on a fixed lookback ladder. The table counts one synthetic run of the procedure on one commodity over 30 trading days, the same run as the figure above.
| Step | What is evaluated | Count |
|---|---|---|
| Universe | Contracts: top 3 by volume on any day ∪ market-maker-designated | 11, of which 3 excluded for delivery |
| Pairings | Ordered (trigger, quoted): 3 trigger legs × 7 quoted legs | 21 |
| Tradable | Pairings whose spread the exchange lists | 12 |
| Screen | 4 edges × 4 lookbacks on the first 3 days; union of halves, survivors finish | 12 → 7 pairs; 4 shortlisted; 3,600 backtests |
| Grid, days 1–3 | 132 cells × 4 pairs, each at 3 or 4 lookbacks: 1,848 runs per day | 528 configurations · 5,544 backtests |
| Grid, days 4–6 | Union of top half by total and top half by per lot: 1,009 runs per day | 292 · 3,027 backtests |
| Grid, days 7–30 | Same cut again: 781 runs per day | 234 · 18,744 backtests |
| Refinement | Half-step cube and axis star around each pair’s leaders, boundary passes | 32,520 backtests; 63,435 for the commodity in total |
| Output | Pareto frontier; menu | 22 rows; 3 spreads × 5 settings |
| Verification | Every frontier and menu row re-run by a second code path | 32 of 32 matched |
Staging and early stopping
The method is a staged grid with successive halving over blocks of days, a multi-fidelity scheme: fidelity is the number of days a configuration has been replayed on. It is the early-stopping rule of modern hyperparameter tuning (the inner loop of Hyperband), with trading days in place of training epochs. It is legitimate here because profit is additive over days and each day is simulated independently, so a partial sum is an unbiased early read of the full-window total. Survivors must be good on more than one block.
The halving keeps the union of the top half by total and the top half by per-lot profit, which is why the synthetic run in the table goes 528 → 292 → 234 and not 528 → 264 → 132: a configuration that is excellent per lot but small in total is not thrown away by a total-profit ranking. No grid cell is ever skipped; a weak cell just stops consuming days. In that run the three blocks cost 27,315 replays against 55,440 for the same grid on all 30 days: 51% saved with every cell still evaluated.
The price of selecting among more than a thousand noisy estimates is the winner’s curse. It is countered in the validation stage: profit in four consecutive day blocks per row, Spearman rank stability across blocks, neighborhood averages, and a report that names the best region, not the best cell.
def union_of_halves(alive, days_seen, keep=0.5):
"""Keep the top half by total profit AND the top half by profit per lot."""
total, per_lot = {}, {}
for config, lookbacks in alive.items():
r = best_over(lookbacks, config, days_seen)
total[config] = r.total
if r.lots_per_day >= MIN_LOTS_PER_DAY: # per lot only where volume means something
per_lot[config] = r.per_lot
n = max(4, ceil(len(alive) * keep))
kept = top_n(total, n) | top_n(per_lot, n) # the union: more than half survives
return {c: alive[c] for c in kept}
# grid stage: every cell on the first block, then days only for survivors
days_seen = []
for i, block in enumerate(day_blocks):
run_backtests(alive, block) # configurations x lookbacks x days
days_seen += block
if i < len(day_blocks) - 1:
alive = union_of_halves(alive, days_seen)Pushing past the grid’s edge
A fixed grid lies when the optimum sits on its edge. In the first cycle the grid’s caps bound on several products, and pushing past the grid by hand improved one product’s answer substantially. Since then this is automatic: in refinement, a leader that sits on the largest or smallest value its pair has been evaluated on, for edge, lookback, withdraw or skew, gets one more outward step, for up to four passes, and the run writes a boundary report saying whether each winner is now interior.
For one recommended spread, a separate bracketing sweep of fixed-pair runs over edge × lookback located a peak that is interior on both axes and stable across the window’s day blocks; longer lookbacks turned blocks negative.
Extension is tested, not assumed. When every best total of one product sat on the top rung of the lookback ladder, a much longer lookback was tried on both the search window and the hold-out: it won in sample and lost on the hold-out, so the ladder top stayed where it was.
The inventory constraint: inventory is free in a backtest
In an unconstrained search a skew of zero wins almost everywhere. The reason is in the backtest, not the market: each session is closed flat at the mid at no cost, so carrying inventory is free and skew only costs fills. In live trading, positions persist.
Shuo set a floor on skew, a fixed fraction of the edge, and re-ran all six products overnight. The floor is enforced in every stage, as the pseudo-code shows: the grid’s skew levels become multiples of the floor, so every edge keeps four admissible levels, and refinement rejects any point below it. The six-product subtotal fell sharply, and the split shows where it went: spreads that earn from quoting kept most of their result, spreads that had only been carrying inventory lost most of it. On one product the top-ranked spread changed, and the new leader’s profit was spread across the window instead of concentrated on a few days.
The reading rule that came out of it: where the search chooses a skew above the floor, the edge comes from quoting; where every row sits on the floor, the search is trying to hold a position.
# grid stage: skew levels are multiples of a floor tied to the edge
for pair in shortlist:
for edge in EDGE_GRID:
for withdraw in WITHDRAW_GRID:
if withdraw >= edge:
continue # withdraw must sit inside the edge
for multiple in (1, 2, 3, 4): # four admissible skew levels at every edge
add_candidate(pair, edge, withdraw, skew=multiple * K * edge)
# refinement: any neighbor below the floor is rejected
def admissible(edge, withdraw, skew):
return 0 < withdraw < edge and skew >= K * edge| Spread | Result kept under the floor | Reading |
|---|---|---|
| Spread A | 82% | Quoting income |
| Spread B | 78% | Quoting income |
| Spread C | 74% | Quoting income |
| Spread D | 69% | Quoting income |
| Spread E | 64% | Quoting income |
| Spread F | 14% | Inventory carry |
| Spread G | 14% | Inventory carry |
| Spread H | 13% | Inventory carry |
| Spread I | 12% | Inventory carry |
Reading the frontier at a volume cap
When the desk supplies a volume cap in lots per day, or a maximum share of market volume, the frontier collapses to one number. Without a cap the report recommends the interior of the frontier: the tight-edge end is the one a queue-free fill model flatters most, and the wide-edge end is pinned to the volume floor.
Alternatives rejected, and why
| Alternative | Why not |
|---|---|
| Brute-force grid on all days | About 14 hours per product on one core. Staging evaluates the same cells and stops paying for the losers. |
| Bayesian optimization (Gaussian process) | The objective is a step function of the edge, because quotes round to the tick, and noisy over a few weeks of daily values; the runtime has no numerical libraries. A transparent grid is reproducible and its cost is known before it starts. |
| Gradient or local search from a default | Non-differentiable, and the surface has separate basins per pair and leg order; the answer for one product moved well past the original grid. |
| A single objective (total profit) | Volume is limited, so the tradable optimum depends on the cap. Total alone selects the highest-volume settings. |
| Pricing inventory inside the backtest instead of a skew floor | The better model, and the documented next step: a carry penalty or position cap, gap profit and loss at the session close, then a sensitivity test on the floor’s level. The floor was the constraint that could be enforced in every stage, on every product, immediately. |
| Optimal control for the pair choice | Choosing a pair and θ is static selection under noise, not a control problem. The control problem is inside the strategy: the linear skew is a hand-set proportional inventory feedback, and the Avellaneda–Stoikov optimal-quote solution is the principled replacement. Identified and proposed, not built. |
Failure modes engineered out
A search exploits whatever the model rewards. Each guardrail below exists because the optimizer found the loophole first, or was about to.
| What the search “found” | Root cause | Guardrail |
|---|---|---|
| A winner that could not be traded | No listed spread for that pair | Listed-only constraint before screening; near-month-first id normalization |
| An absurdly profitable pair | A leg in its delivery month: one-sided book, meaningless mid | Delivery-month exclusion, delivery-lead rule, per-lot plausibility scan |
| A frontier with rows missing | Truncation bug | Integrity checks: the per-lot winner must be on the frontier; row-count signature |
| Optima on the edge of the grid | Fixed grids bind | Boundary auto-extension, longer lookback ladder |
| Per-lot winners at the volume floor | The floor, not the data, stopped them | Marked “floor-bound, not tradable at scale” |
| Zero skew everywhere | Inventory is free in the backtest | Skew floor in every stage; skew-profile diagnostic |
| Another exchange’s delivery contracts about to slip through | Month codes with three digits instead of four | Exchange-aware contract parser |
| Every winner using the same leg order (one exchange’s run) | The quoted leg was read one snapshot stale inside each exchange batch | Same-snapshot re-run |
| A large profit on a pair with no listed spread | It would have to be legged; spread-terms quoting assumes instant re-pricing | Legging model with best-case and worst-case bounds; recommendation: do not trade as is |
Validation and results
Three layers, kept apart on purpose. Reproducibility: an independent fixed-pair driver re-runs every reported row and must match to the lot. Stability: profit in four consecutive day blocks, share of profit from the best three days, Spearman rank stability and neighborhood averages. Out of sample: a formal hold-out. Its recommendation rule was fixed in advance on in-sample data only (highest total after dropping the best day, with most days up), then every menu row was replayed unchanged on earlier trading days the search never saw.
The hold-out also shows where overfitting lives. Volume fell while per-lot profit largely held for the recommended setting; the wide-edge rows with the highest in-sample profit per lot decayed most, which is why the reports recommend the interior of the frontier and not its ends. The chart shows the pattern on synthetic data.
Recommended rows: per-lot profit kept on the hold-out
The higher a row’s in-sample profit per lot, the less of it survived: the top row kept most of its per-lot profit, the widest-quote rows clearly less.
Show the dataHide the data
| Series | In-sample profit per lot (index) | Per-lot profit kept (%) |
|---|---|---|
| Recommended rows | 141.7 | 49.5% |
| Recommended rows | 199.7 | 44.7% |
| Recommended rows | 288.7 | 48.7% |
| Recommended rows | 323.1 | 16.5% |
| Recommended rows | 95.5 | 65.1% |
| Recommended rows | 130.4 | 58.3% |
| Recommended rows | 218.7 | 36.9% |
| Recommended rows | 251.3 | 39.0% |
| Recommended rows | 296.0 | 38.3% |
| Recommended rows | 91.3 | 69.8% |
| Recommended rows | 163.5 | 63.5% |
| Recommended rows | 198.6 | 67.6% |
| Recommended rows | 231.1 | 59.1% |
| Recommended rows | 252.0 | 56.4% |
| Top row | 100.0 | 61.3% |
| Measure | Value |
|---|---|
| Adoption | The desk traded the optimizer’s picks1 |
| Scope searched | 16 commodities on 3 exchanges |
| Search evaluations, three six-product cycles | 600,000+ |
| Core-search benchmark, full window | 129,168 replays in 146.6 min on 16 worker processes |
| Core-search benchmark, short window | 55,303 replays in 75.8 min |
| Rows reproduced by the independent driver | 747 of 747 |
| Hold-out | Every recommended row profitable on days the search never saw |
| Where the hold-out decayed most | The widest-quote rows; the reports recommend the frontier’s interior |
| Lookback pushed past the ladder | Won in sample, lost on the hold-out: rejected |
| Inventory floor | Quoting-income spreads kept most of their result; inventory-carry spreads lost most of it |
| Quoting-income spreads, next cycle | All on both lists again, profitable on most days, not carried by a few big days |
| Side run on another exchange, request to verdict | One morning; the search itself ran 32 minutes |
Stack and throughput
Python 3.10, standard library only: multiprocessing over pairs, per-stage CSV checkpoints with resume, HTML and SVG reports. A 1,243-line optimizer and about twenty helper scripts for verification, hold-outs, boundary sweeps, skew profiles, data pulls and unattended runs. SQL for the one-click pulls against MariaDB.
To size it for daily use Shuo benchmarked the core search with 16 worker processes (55,303 replays in 75.8 minutes on a short window; 129,168 in 146.6 on a full one). An incremental mode that evaluates only the newest day is specified as the next step.
Built with
- Python
- Hyperparameter optimization
- Exhaustive grid search
- Successive halving
- Multi-objective optimization
- Pareto frontier
- Black-box optimization
- Backtesting
- Hold-out validation
- Parallel computing · multiprocessing
- Checkpoint and resume
- SQL · MariaDB
- Market microstructure
- Market making
07Releases
Shipped in versions, like a product.
- First versionStaged search built the same morning, reproducing a fixed-pair reference backtest to the lot. Two objectives, no fee term.
- Listed-only constraintOnly exchange-listed spreads are searched; delivery-month contracts excluded.
- Multi-spread menusTop 3 spreads × 5 settings per product, per-pair refinement, boundary auto-extension, live progress page.
- Inventory-skew floorA floor on inventory skew, a fixed fraction of the quote edge, enforced in every stage.
- Unattended cycleOne-click runner with resume, delivery-lead rule, skew-profile diagnostic.
- Second exchangeExchange-aware contract codes, spread ids and sessions; a side run searched and reported the morning it was requested.
- Hold-out runnerRecommendation rule fixed in sample; every menu row replayed unchanged on earlier days the search never saw.
- Legging and same-snapshot checksFor products with no listed spreads, a legging model with best- and worst-case bounds, and a same-snapshot re-run; on one exchange they overturned the search’s own winners.
- 1Each live configuration was a row of the optimizer’s output; the desk chose which rows to trade. Which configurations, when, and their results are confidential.
- 2Every ordered pairing whose trigger leg is among the three most-traded contracts and whose spread the exchange lists is screened, and every cell of the parameter grid is backtested on every shortlisted pair. Cells are stopped early across days, never skipped, and the grid is refined and extended around the leaders. It is a search of a grid, not a proof of a global optimum.
- 3Summed over the cycles whose verification logs record a count. A match shows the number is reproducible by independent code; plausibility, day-concentration, inventory and hold-out checks address whether it is tradable.
- 4Search evaluations summed over three six-product cycles, verification re-runs excluded. One evaluation is a tick replay of one pair on one day at one parameter set. A cycle takes roughly five to seven hours of wall time including verification.
- 5Best backtested total per spread with the skew floor, as a share of the same spread’s best without it, on the same window and products. The chart shows synthetic spreads, labeled A to I.
- 6One formal hold-out: the recommendation rule was fixed on the search window, then every menu row was replayed unchanged on earlier trading days the search never saw. No rolling walk-forward was run. The charts on this page show a synthetic version of this test.
- 7Counted by commodity across the main six-product cycles and the side runs on two other exchanges. Where the fill model cannot see a product’s spread-book trading, the report calls the result inconclusive instead of ranking it.
- 8All results on this page are backtests: a fill is counted when the legs’ implied spread touches the quote, with no queue, no fees and each session closed flat at the mid. A later validation against live fills showed this touch rule under-fills listed spreads and favors tight quotes, so the figures rank configurations against each other and are not forecasts of realized profit. Earlier runs were not re-checked for a same-snapshot timing bias found later in another exchange’s data. The quoting strategy being optimized is a colleague’s design; the optimizer is Shuo’s.