SPD Parameter Optimizer

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.

  • Conceived and built by Shuo Huang
  • The desk traded its picks
  • 600,000+ tick-replay backtests
  • 16 commodities · 3 exchanges
  • 747/747 rows re-verified

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

  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
  2. 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
  3. 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.

600,000+

full-day tick replays across three six-product search cycles, run unattended on one office PC4

16

commodities searched on three exchanges7

747/747

reported rows reproduced to the lot by an independent re-run3

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
Data: Best backtested result per spread, before and after the floor
SpreadWithout the floorWith the floorChange
Spread A100%82%−18%
Spread B100%78%−22%
Spread C100%74%−26%
Spread D100%69%−31%
Spread E100%64%−36%
Spread F100%14%−86%
Spread G100%14%−86%
Spread H100%13%−87%
Spread I100%12%−88%
Synthetic data. Illustrative data, generated to show the effect: each spread’s best backtested result with the floor as a share of its best without it, on the same window. Here the quoting spreads kept 64 to 82% and the carry spreads 12 to 14%. The method is as built; the desk’s own figures are confidential.5

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
Data: Recommended rows: in sample and on the hold-out
SeriesDaily profit in sample (index)Daily profit on the hold-out (index)
Recommended rows76.916.9
Recommended rows64.610.2
Recommended rows47.88.1
Recommended rows37.42.0
Recommended rows85.112.7
Recommended rows71.510.1
Recommended rows53.76.8
Recommended rows40.613.1
Recommended rows34.49.9
Recommended rows61.016.1
Recommended rows49.112.6
Recommended rows40.68.8
Recommended rows38.74.1
Recommended rows30.22.8
Top row100.030.6
Synthetic data. Illustrative data, generated to show the effect: 15 menu rows chosen on a 30-day window, then replayed unchanged on the 12 trading days before it. Both axes are average daily profit, indexed so that the top row’s in-sample value is 100; hold-out values are lower mainly because volume was. Rank correlation of the two: 0.73. The method is as built; the desk’s own figures are confidential.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

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 s be an ordered pair of contracts (trigger leg, quoted leg) and θ the quoting parameters: quote edge e (ticks from fair value), withdraw threshold w, inventory-skew gain δ and the lookback L of the fair-value moving average, counted in trigger-leg updates. πd is the backtested profit on day d and N the lots traded over the D 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.

maxs∈S,θ∈Θ(Π(s,θ),Π(s,θ)N(s,θ))Π(s,θ)=∑d=1Dπd(s,θ),θ=(e,w,δ,L)
Joint maximization of total profit Π and profit per lot Π / N over listed pairs s and parameters θ. Days are replayed independently, so Π is additive over days.

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 δ≥ke, 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 k is not published.
  • Volume floor of nmin 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.

s∈Slisted,w<e,δ≥k·e,N(s,θ)D≥nmin
The constraints of the current version. S-listed is the set of pairs the exchange lists as a spread contract on every day of the window; the floor fraction k and the volume floor n-min are not published.

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.

Synthetic data. Illustrative counts from one generated run of the procedure. A backtest is one (pair, parameter set, lookback, day) replay; in every block, configurations × lookbacks × days = backtests.
StepWhat is evaluatedCount
UniverseContracts: top 3 by volume on any day ∪ market-maker-designated11, of which 3 excluded for delivery
PairingsOrdered (trigger, quoted): 3 trigger legs × 7 quoted legs21
TradablePairings whose spread the exchange lists12
Screen4 edges × 4 lookbacks on the first 3 days; union of halves, survivors finish12 → 7 pairs; 4 shortlisted; 3,600 backtests
Grid, days 1–3132 cells × 4 pairs, each at 3 or 4 lookbacks: 1,848 runs per day528 configurations · 5,544 backtests
Grid, days 4–6Union of top half by total and top half by per lot: 1,009 runs per day292 · 3,027 backtests
Grid, days 7–30Same cut again: 781 runs per day234 · 18,744 backtests
RefinementHalf-step cube and axis star around each pair’s leaders, boundary passes32,520 backtests; 63,435 for the commodity in total
OutputPareto frontier; menu22 rows; 3 spreads × 5 settings
VerificationEvery frontier and menu row re-run by a second code path32 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.

Pseudo-code
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)
Pseudo-code. The union-of-halves cut and the staged loop that uses it, simplified.

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.

Pseudo-code
# 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
Pseudo-code. The skew floor in the grid and in refinement, simplified. K is the floor as a fraction of the quote edge.
Synthetic data. Illustrative split, generated to show the effect: each spread’s best backtested total with the floor as a share of its best without it. The desk’s own figures are confidential. Pricing inventory inside the backtest is the documented next step.
SpreadResult kept under the floorReading
Spread A82%Quoting income
Spread B78%Quoting income
Spread C74%Quoting income
Spread D69%Quoting income
Spread E64%Quoting income
Spread F14%Inventory carry
Spread G14%Inventory carry
Spread H13%Inventory carry
Spread I12%Inventory carry

Reading the frontier at a volume cap

When the desk supplies a volume cap c 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.

Jcap=ΠN·min(ND,c)·D
Volume-capped scalarization: per-lot profit times the lots the desk is allowed to trade, over the window.

Alternatives rejected, and why

AlternativeWhy not
Brute-force grid on all daysAbout 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 defaultNon-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 floorThe 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 choiceChoosing 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.

The last two were found by Shuo on his own optimizer’s winners and overturned them. A verification match proves a number is reproducible; these checks are what guard its validity.
What the search “found”Root causeGuardrail
A winner that could not be tradedNo listed spread for that pairListed-only constraint before screening; near-month-first id normalization
An absurdly profitable pairA leg in its delivery month: one-sided book, meaningless midDelivery-month exclusion, delivery-lead rule, per-lot plausibility scan
A frontier with rows missingTruncation bugIntegrity checks: the per-lot winner must be on the frontier; row-count signature
Optima on the edge of the gridFixed grids bindBoundary auto-extension, longer lookback ladder
Per-lot winners at the volume floorThe floor, not the data, stopped themMarked “floor-bound, not tradable at scale”
Zero skew everywhereInventory is free in the backtestSkew floor in every stage; skew-profile diagnostic
Another exchange’s delivery contracts about to slip throughMonth codes with three digits instead of fourExchange-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 batchSame-snapshot re-run
A large profit on a pair with no listed spreadIt would have to be legged; spread-terms quoting assumes instant re-pricingLegging 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
Data: Recommended rows: per-lot profit kept on the hold-out
SeriesIn-sample profit per lot (index)Per-lot profit kept (%)
Recommended rows141.749.5%
Recommended rows199.744.7%
Recommended rows288.748.7%
Recommended rows323.116.5%
Recommended rows95.565.1%
Recommended rows130.458.3%
Recommended rows218.736.9%
Recommended rows251.339.0%
Recommended rows296.038.3%
Recommended rows91.369.8%
Recommended rows163.563.5%
Recommended rows198.667.6%
Recommended rows231.159.1%
Recommended rows252.056.4%
Top row100.061.3%
Synthetic data. Illustrative data, generated to show the effect: 15 menu rows, in sample on a 30-day window and replayed unchanged on the 12 trading days before it. Across: each row’s in-sample profit per lot, indexed so that the top row is 100. Up: the share of it kept on the hold-out. Correlation of the two: −0.74. The method is as built; the desk’s own figures are confidential.6
Measurements of the optimizer itself, and the study’s verdicts in words. The desk’s backtest figures, parameter values and positions are confidential; the charts on this page use synthetic data.
MeasureValue
AdoptionThe desk traded the optimizer’s picks1
Scope searched16 commodities on 3 exchanges
Search evaluations, three six-product cycles600,000+
Core-search benchmark, full window129,168 replays in 146.6 min on 16 worker processes
Core-search benchmark, short window55,303 replays in 75.8 min
Rows reproduced by the independent driver747 of 747
Hold-outEvery recommended row profitable on days the search never saw
Where the hold-out decayed mostThe widest-quote rows; the reports recommend the frontier’s interior
Lookback pushed past the ladderWon in sample, lost on the hold-out: rejected
Inventory floorQuoting-income spreads kept most of their result; inventory-carry spreads lost most of it
Quoting-income spreads, next cycleAll on both lists again, profitable on most days, not carried by a few big days
Side run on another exchange, request to verdictOne 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.

  1. First versionStaged search built the same morning, reproducing a fixed-pair reference backtest to the lot. Two objectives, no fee term.
  2. Listed-only constraintOnly exchange-listed spreads are searched; delivery-month contracts excluded.
  3. Multi-spread menusTop 3 spreads × 5 settings per product, per-pair refinement, boundary auto-extension, live progress page.
  4. Inventory-skew floorA floor on inventory skew, a fixed fraction of the quote edge, enforced in every stage.
  5. Unattended cycleOne-click runner with resume, delivery-lead rule, skew-profile diagnostic.
  6. Second exchangeExchange-aware contract codes, spread ids and sessions; a side run searched and reported the morning it was requested.
  7. Hold-out runnerRecommendation rule fixed in sample; every menu row replayed unchanged on earlier days the search never saw.
  8. 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.
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
Previous
Previous

Live vs Backtest

Next
Next

QWIN Task Guide