Smart Queue Review

Software · Quant research

Smart Queue Review 提前排队

Shuo audited a new trading strategy before it went live, proved where its value really came from, reconstructed its first live session order by order, and designed the safeguard now running in production.

  • Conceived, designed and built by Shuo Huang, on his own initiative
  • Guard adopted in production
  • Specification built by the engine team
  • 7 reports · Aug–Oct 2026
  • Python · C++ code review
  • Strategy code by the desk’s engine team

01System architecture

Three kinds of evidence, one verdict the desk and the engine team could act on.

A backtest is only as good as its model of the exchange queue, and this strategy adds size exactly where queue models are weakest. So Shuo read the code, replayed history with one rule switched at a time, and then priced every question the simulator could not settle on the desk’s own fills and logged orders.

Engine team

Smart-queue strategy

New C++ quoting class. Tops up a price level as soon as part of the desk’s order trades.

Shuo’s review

Line-by-line code review

15 findings with file and line, 5 bundled behavior changes separated, fixes ranked by value.

Shuo’s deliverable

Change notes and specification

16-step per-snapshot logic, 4 new parameters, 12 acceptance cases.

Engine team

Engine builds

A depth-aware guard with a floor and a cap, now in production; the next build was built from the specification.

Market history

Ticks, signal, size schedules

Months of market history: every snapshot, the production price signal, the desk’s historical order sizes.

Shuo’s replay engine

Switchable A/B replay

17 arms, one rule on or off at a time, paired by day. Matches the model team’s reference simulator on 27 of 27 rows.

Shuo’s deliverable

Seven reports

Valuation, guard design, throttle rules, stacking, redesign verdict. Every number generated from data by script.

Trading desk

Go / no-go and parameters

Deploy, gate by depth, adopt the corrected redesign.

Production

Fills and engine logs

The desk’s historical passive fills with the book at each fill; every order of the first live session.

Shuo’s order lab

Fill-based pricing, rule harness

Prices thin-book rules on historical fills; scores 88 candidate rules on logged top-up orders.

Shuo’s findings

Guard design and rule verdicts

A floor and a cap on other traders’ depth; a traded-flow gate; a no-flip check applied after sizing the add.

Simplified: the three lanes ran in sequence between late August and mid-October 2026, and each later study reused the earlier instruments. The strategy, the engine and its builds are the engine team’s; the reference simulator and the price signal are the model team’s.

Who built what

The engine team wrote the smart-queue strategy and every engine build. Shuo opened the review on his own initiative and conceived, designed and built everything in the two middle columns: the code review, the replay engine and its 17 arms, the fill-based studies, the live-session reconstruction, the 88-rule test, the reports and the specification.

Why not just trust the backtest?

A snapshot backtest cannot see cancels ahead of the desk or other traders reacting to the desk’s size. On thin levels it pointed the opposite way from the desk’s own fills. From that point on, every thin-book question was priced on fills.

Why it had to be exact first

A replay that differs from the reference by a little cannot isolate a rule worth a little. Shuo’s replay reproduces the reference on 27 of 27 rows, down to the full fill list, before a single rule is switched.

02The story

Free speed on paper. Shuo priced it on the desk’s own fills and designed the guard now in production.

On an exchange, orders at the same price wait in line, first come, first served. The desk’s engine team wrote a new strategy that rejoins the line the moment part of the desk’s order trades, instead of waiting for the rest.1 It sounded like free speed, and nobody had measured what it was worth. So Shuo did: one trader, on his own initiative, with every instrument designed and built himself, and allowing for the answer to be negative.

He read the code line by line, replayed months of market history with the rule switched on and off, priced its safeguard on the desk’s own historical fills, and reconstructed the strategy’s first live session order by order to test the backtest against what actually happened. The safeguard he designed now runs in production,2 and the engine team built the redesigned strategy from his specification.3,4

  1. 01

    The problem

    The desk makes markets in live-hog futures: it rests buy and sell orders and earns the gap between them. Orders at one price trade in arrival order, so a place near the front of the line is valuable.

    The engine team’s new strategy, which the desk calls the smart queue, does something that sounds like free speed: the moment part of the desk’s order at a price trades, it adds more behind what is left, instead of waiting for the remainder to trade first. Think of rejoining the checkout line before you have finished paying.

    • Nobody had priced it. The code existed; its value, positive or negative, did not.
    • The risk hides in the mechanism. It adds size at the back of the line, which fills mainly when the whole price level is being run over, the worst moment to trade.
    • Money on the line, every second. A market maker has capital on the line, and a two-sided quoting duty to keep, whenever a strategy runs.5
  2. 02

    What Shuo built

    An independent model validation in four instruments, each conceived and built for this question.

    • A code review. Shuo read the engine team’s C++ line by line and reported 15 findings, each with file and line, before the strategy traded live. He also separated 5 behavior changes bundled with the headline feature, so that each could be priced on its own.
    • An A/B replay. A backtesting engine that reproduces the desk’s reference simulator exactly (27 of 27 rows),6 then switches one rule at a time on months of market history with the desk’s historical order sizes.7
    • Fill-based pricing. Where the simulator gave the wrong answer, in thin order books, he priced the safeguard on the desk’s own historical fills instead.8
    • A live-session reconstruction and a rule test. After the strategy’s first live session he rebuilt every order from the engine’s raw logs, reconciled the result exactly to the desk’s records, and scored 88 candidate rules on the logged top-up orders.9
  3. 03

    What changed

    • The value was not where the name said. The strategy showed a clear simulated gain, but most of it came from offering more on the side that reduces inventory. The earlier place in line was worth almost nothing, and the live session agreed: where the old rule would have posted anyway, the top-up reached the line only moments sooner.
    • A safeguard Shuo designed runs in production. He replaced a single multiple with a floor and a cap on external depth, the lots other traders are showing with the desk’s own removed. The engine team implemented it, and it runs in production.2
    • The gap between backtest and live, explained. The order-by-order reconstruction showed that the backtest had mispriced top-up fills in thin books. A five-arm replay of the same session’s ticks isolated the gap to fill quality and inventory, not the strategy’s arithmetic, so every later rule was priced on logged fills.
    • The redesign was tested with data, then built. He scored each proposed rule on the logged orders, showed that the no-flip check has to run after the add is sized, and wrote the full specification. The engine team built from it.3

27/27

validation rows where Shuo’s replay matches the desk’s reference simulator exactly6

17

rule arms in the A/B replay, one switched at a time, every comparison paired by day7

88

candidate rules scored on the logged top-up orders of the first live session9

15

review findings reported to the engine team, each with file and line, before the strategy traded live

16steps

in the specification he wrote, with 12 acceptance cases; the engine team built from it3

7

reports in seven weeks, every number in them generated from data by script

03Functions

Everything it does, in the order a user meets it.

A

Audit the code before it trades

A line-by-line review of the engine team’s C++ strategy, written up with file and line for every finding.

  • 15 findings, each reported to the engine team with file and line before the strategy traded live
  • 5 behavior changes bundled with the headline feature, separated so each could be priced on its own
  • Fixes ranked by value, so the engine team could act on the important ones first

B

Find where the money comes from

An ablation on the same market tape: one rule switched at a time, so the value of the earlier queue place is separated from the value of simply quoting more.

  • Replay verified 27 of 27 rows exact against the reference simulator before any rule is changed6
  • 17 arms, every comparison paired by trading day and tested on the daily difference; the headline result survived every robustness check7
  • Most of the gain is inventory-scaled size, almost none the earlier queue place; value rises steadily with book depth

Simulated gain by book depth

The deeper the order book, the more the strategy earned: the gain rises steadily from the thinnest quarter of days to the deepest.

Data: Simulated gain by book depth
Quarter of contract-days, by average book depthDaily gain, index (deepest quarter = 100)
Thinnest38
Second66
Third84
Deepest100
Synthetic data. Illustrative values, generated to show the effect: a paired A/B replay split into quarters of days by the session’s average depth at the best bid and offer, each bar the average daily gain over the baseline. The method is as built; the desk’s own figures are confidential.

C

Design the thin-book guard from fills, not from the simulator

The simulator said to switch the guard off; the desk’s own fills said the opposite, and showed what shape the rule should have.

  • Position-adding fills lose on average when the level is thin relative to the desk’s order, and earn when it is deep8
  • A single multiple cannot serve every order size, so the rule became a floor and a cap on other traders’ depth
  • Tested day by day on historical fills, with a split-sample check; implemented by the engine team and running in production2

Quoting time each rule switches off

A flat multiple switches off more and more quoting time as the order grows; held between a floor and a cap, it levels off at the larger sizes.

Data: Quoting time each rule switches off
Order-size band, smallest to largestFlat multipleFloor and cap
Smallest0%0%
Band 20%0%
Band 32%2%
Band 410%10%
Band 528%11%
Largest53%11%
Synthetic data. Illustrative values, generated to show the effect: the share of quoting time on the position-adding side that each rule would switch off, counted by order-size band. The method is as built; the desk’s own figures and the guard’s settings are confidential.

D

Reconstruct the first live session, order by order

Every order of the session rebuilt from the engine’s raw logs and classified from the engine’s own book print, written before each decision.

  • P&L identity reconciled exactly to the desk’s own records; engine snapshots checked one for one against the tick database
  • Every fill classified as a new level, a top-up or a cross, then compared class by class with what the backtest had assumed: it had mispriced top-up fills in thin books
  • A five-arm counterfactual replay of the session’s own ticks isolated the gap to fill quality and inventory, not the strategy’s arithmetic

E

Make sure the guard always has its bounds

A threshold that scales with the order size needs its cap most when the order grows, so Shuo made any missing bound visible, and one step to fix, in the tool that edits the configuration.

  • Without a cap the threshold rises in step with the order size and starts refusing ordinary, healthy levels
  • Held between a floor and a cap, the same book is quoted almost throughout: 6% of snapshots refused instead of 66% in this illustration
  • Built into Strategy One: its configuration template carries the guard’s bounds, and its parameter editor shows the value the engine silently uses for any bound a block leaves out, then inserts the value the trader types
Line chart, on synthetic data, of other traders’ lots at the best bid over 60 seconds. Two thresholds of k times the order size (dashed: no cap; dotted: held between floor and cap) sit well below the depth until the order size steps from 10 to 30 lots. Then the dashed one jumps above most of it; the dotted one stays below nearly all of it. Strips below: 66% of later snapshots refused without the cap, 6% with it. Enlarge
Synthetic data. Illustrative trace, generated to show the effect. When the order size steps from 10 to 30 lots, a threshold with no cap climbs above ordinary depth and refuses the bid on 66% of the snapshots that follow; held between a floor and a cap, it refuses 6%. The settings and depths are invented for the picture; the desk’s own are confidential.

F

Test the fixes on logged orders, then specify the rebuild

Candidate rules are judged on what they would have done to the logged orders of the live session, never on a hypothetical.

  • 88 candidate rules on the logged top-up orders: a traded-flow gate, which needs market data alone, kept far more fills than the rules that worked mainly by switching top-ups off9
  • A no-flip condition checked before adding still lets a swept stack carry the position through zero; checked after the add is sized, it cannot. The desk adopted the post-add form
  • A standalone specification: 16-step per-snapshot logic, 4 new parameters, 12 acceptance cases, built by the engine team in its next build3

Candidate rules on logged top-up orders

The traded-flow gate captures most of the best rule’s improvement while blocking about half as many fills; a queue-depth rule blocks more and improves less.

Data: Candidate rules on logged top-up orders
SeriesTop-up fills blocked (%)Improvement in kept fills (index, best rule = 100)Label
Other rules0%0No rule
Other rules64%26Queue-depth rule
Other rules72%100Wider-edge filter
Traded-flow gate38%64Traded-flow gate
Synthetic data. Illustrative values, generated to show the effect: the share of top-up fills each rule would have blocked, and the improvement in the average quality of the fills it keeps, indexed to the best rule (= 100). Three of the 88 rules tested, with no rule as the origin. The method is as built; the desk’s own figures and the rules’ settings are confidential.9

04How it works

Queue early, get swept, and the guard that steps aside in time

One price level, one line of orders

Synthetic data. Mechanism as built; every number in this figure is illustrative. The queues (a 10-lot order; 28, 12 and 40 lots from other traders), the bar chart and the gauge are drawn to show the effect. The guard’s settings are not shown, and the desk’s own figures are confidential.

Text description of this figure

Three panels. Panel one, queue early: under the old rule, one order per price, buyers take 7 of the desk’s 10 lots and the last 3 must trade before the engine lines up again; under the engine team’s smart-queue strategy, 10 more lots join the back of the line at once. Facts: Shuo’s paired A/B replay switched one rule at a time; his replica matched the reference simulator row for row before any rule changed; most of the simulated gain came from size, not queue place, and the head start in line was worth almost nothing. Panel two, the thin book: the same top-up at a level where other traders show only 12 lots, 1.2 times the desk’s order size. One buyer takes all 25 lots, the top-up fills last, the price steps up a tick and the desk’s position flips from plus 3 to minus 10. An illustrative bar chart shows indexed fill quality five seconds after a fill in seven buckets from the thinnest level to the deepest, relative to the desk’s order size: −37, −38, −26, −2, +31, +65, +100, so thin levels lose on average and deep ones earn. The study priced this on the desk’s historical fills, not on the simulator. Panel three, the guard: it counts only other traders’ lots, 22 displayed minus the desk’s own 10 leaves 12, which is below the floor, so the engine cancels the desk’s 10 lots at that price before a sweep; when other traders refill the level to 40 lots the quote returns. Facts: the guard reads other traders’ depth only; its threshold is a multiple of the order size held between a floor and a cap; it was adopted in production.

05Under the hood

For the technical reader: the model, the math and the code.

Under the hoodReplay validation, ablation design, the fill-based objective, live-session forensics, the why-not-X table and pseudo-code

The method, for a quant, an ML scientist or an engineer who wants to check it. In machine-learning terms this is a model-validation and sim-to-live study: a simulator verified exact, an ablation with paired tests, a region where the simulator is shown to have the wrong sign and is replaced by observed fills, and a live-session reconstruction that scores candidate fixes on logged decisions. All of it runs in standard-library Python on an ordinary desk PC. Everything here is Shuo’s own work except where the engine team or the model team is credited. Charts, figure data and screenshots on this page are synthetic, illustrative or public market data. Methods and outcomes are described as they happened; the desk’s own figures are confidential and do not appear here.

The mechanism under review

Per market snapshot (about four a second on the Dalian Commodity Exchange) a quoting engine recenters its quotes around a fair value and reposts. The new step: if the desk already rests at the touch on the side that reduces its position, add a top-up behind its own order at once, without waiting for the remainder to trade, and size that top-up with the desk’s inventory.

So the mechanism has two halves that the name hides: an earlier place in the queue, and a larger, inventory-scaled size on the position-reducing side. The second half, not the timing, turned out to carry the value, and later the risk.

Replay engine: exact first, then switchable

No new simulator. The baseline is a line-exact port of the model team’s reference backtest, built and verified in Shuo’s live-versus-backtest study. He re-expressed it with an on/off arm for every rule in the new strategy, 17 arms in all, plus sensitivity runs.

  • Validation. Run with the reference’s own queue rule, the engine reproduces the reference on 27 of 27 rows: P&L, lots, withdrawals, failed cancels, crosses and the complete fill list. The study’s baseline differs from it only by the queue-order fix below.
  • Inputs as traded. The desk’s historical intraday order-size schedules and quoting settings, and the production price signal.
  • Sample. Every contract-day on which ticks, signal and a size schedule all exist, across several live-hog contracts.
  • Scale. About 2.7 GB of ticks read per day through a byte-offset index, nothing cached; sweeps fan out over (contract, day) with multiprocessing; pure standard-library Python.

The modeling fix that mattered: same-price queue order

A queue model written for one order per price can let two of the desk’s own orders at that price share a queue position. That is harmless for a strategy that almost never rests two orders at one price, and fatal for one whose whole point is stacking: the top-up would inherit the front order’s place for free.

Shuo found it because verification failed on 10 of 27 rows once strict order was imposed, kept a replica arm with the shared-position rule for the exactness check, and enforced first-in-first-out everywhere else. The baseline itself is unchanged to within rounding.

qi≥qi−1+ℓi−1
For the desk’s orders at one price, sorted by arrival: the lots queued ahead of order i are at least the lots ahead of the previous order plus that order’s own remaining lots ℓ.
Pseudo-code
# Two of our own orders at one price cannot share a place in the queue.
for each (side, price) level that holds two or more of our orders:
    sort the level's orders by arrival
    for each order after the first:
        minimum_ahead = previous.queue_ahead + previous.lots_left
        order.queue_ahead = max(order.queue_ahead, minimum_ahead)
Pseudo-code. The same-price first-in-first-out constraint, applied after every queue update. Simplified.

Statistics: paired by day, decomposed, stress-tested

Every comparison runs two arms on the same day’s tape and tests the daily difference, reported with its t-statistic, the share of positive days and the worst day. The mechanism is then split into its two halves: refilling to the order size (the literal queue-early step) and scaling the target with inventory.

A queue-realism parameter α makes other traders who arrive within the same snapshot queue ahead of the desk with weight α. It is the direct way to ask how much of a simulated edge survives a less generous queue.

  • Depth gradient. By quartile of the day’s average touch depth, the gain rises steadily from the thinnest quarter of days to the deepest, and the thinnest quarter is not statistically significant. The thick-book thesis Shuo started with holds, and it says where to switch the feature on.
  • Robustness. The conclusion survived every robustness check: split by calendar month, with five price levels instead of three, and on the most-sampled contract alone.
  • Top-up fills are discounted lots. Their 5-second mark-out is well below a regular quote’s, so P&L per lot falls, significantly, even as the total rises.
  • Against the obvious alternative. Compared with simply raising the order size to buy a similar amount of extra volume, the top-up earned more per marginal lot, because it adds size only on the position-reducing side, only at the touch, only after a fill.10
  • Side effects priced, not ignored. Larger average and peak inventory, many more cancels, and a larger share of the touch, each measured and reported next to the gain.
  • Recommendation. Enable it where books are deep, gated by depth.
t=d¯sd/n,dk=Πkon−Πkoff
Paired test over n contract-days: d is the same-day difference in simulated P&L between the arm with the rule and the arm without.
The ablation in words; the simulated amounts and test statistics are confidential. The two halves sum to the whole, and the queue-early half vanishes under conservative queueing.
Comparison (paired by contract-day)What the replay showed
Mechanism vs. reference baselineA clear, statistically significant gain
Refill to the order size only (the literal queue-early step)A small part of the gain; not significant on mark-out
Target scaled with inventoryMost of the gain
Mechanism under more conservative queueing (α rising to 1)Shrinks steadily as α rises, and stays positive
Refill only, under conservative queueingIndistinguishable from zero

Where the simulator has the wrong sign: pricing the guard on fills

The thin-book guard refuses to post, or cancels, on the position-adding side when the touch is too thin. Sweeping it in the replay says to turn it off. That verdict is wrong: the guard only acts in thin books, exactly where a snapshot queue model over-credits the desk. The simulator’s per-lot mark-out barely moves across the sweep while observed fills differ enormously across the same range. Rule adopted from then on: anything that touches thin-book behavior is priced on fills.

  • Data. Months of the desk’s own passive fills across several contracts, each with side, size, position before, the prevailing order size, touch sizes, and 1-, 5- and 30-second mark-outs.
  • Target. The 5-second mark-out of a fill: the mid price five seconds later against the fill price, signed by side, in money per lot.
  • Objective. The saving of a threshold m is minus the summed mark-out of the position-adding fills it would have blocked, weighted by lots. The optimum is where the marginal bucket’s per-lot mark-out crosses zero, a first-order condition Shuo verified on a fine grid: the pooled optimum sits on a flat top, and the result holds on a split sample.
  • The shape. Fill quality is negative in the thinnest levels, crosses zero in the middle of the range and rises steadily after it; the position-reducing side has the same shape, so it is a property of thin books. The figure above draws that curve with illustrative values.
  • A small sample would have misled. A first short-sample pass pointed to a clearly higher multiple and looked statistically significant. Extended to the full sample, the study showed that was noise.
S(m)=−∑i∈adding,Di<msiviμi5s,μiΔ=σiM(mti+Δ−Pi)
Saving of a threshold multiple m: the position-adding fills i whose level depth D was under m times the prevailing order size s would not have happened; v is lots and μ the mark-out per lot at horizon Δ (σ: +1 buy, −1 sell; M: contract multiplier; m with a time subscript: mid price; P: fill price).

The guard’s shape: a multiple, a floor, a cap, and other traders’ depth only

  • Why a multiple at all. Depth ÷ order size explains fill quality several times better than absolute depth or order size alone, measured as the between-bucket share of variance.
  • Why one multiple is not enough. The best multiple falls as the order grows, because the threshold grows linearly with size and the book does not. A flat multiple therefore switches off a large share of quoting time at the larger sizes; held between a floor and a cap, it does not. The chart in the guard section above illustrates the comparison.11
  • Why external depth. The desk’s own resting lots are a sizable share of the touch at fill moments. Counting them means the larger the desk quotes, the more easily it passes its own safety test, and a strategy that stacks size at the touch would progressively disarm its own guard. A colleague raised the question; Shuo reconstructed the desk’s resting lots at every fill (live orders at that price, less their fills strictly before the instant) and measured it. External depth also discriminates better.
  • Why only the position-adding side. A quote that reduces inventory is worth keeping even in a thin book, and a market maker has to keep quoting both sides.5
  • Quoting time. What each rule switches off is counted on the tick tape, not estimated.
  • A free improvement. Blocking only the touch price instead of the whole side gives the same simulated result and keeps more two-sided quoting time.
  • Review of the implementation. He checked the engine team’s implementation against the design by reading the change.
T=min(max(ks,F),C),Dext=Dshown−Down,block ifDext<T
The guard as designed: a multiple k of the order size s, held between a floor F and a cap C, compared with the depth other traders show. k, F and C are desk settings and are not published.

Live forensics: every order, reconciled

The strategy’s first live session was rebuilt from the engine’s raw logs in one streaming pass: every market snapshot, insert, order return, trade, cancel, position print, configuration and status change, with order references keyed by engine process because they restart with each one.

  • Classification without guesswork. The engine prints the desk’s resting book before each decision. An insert at a price already in that print is a top-up; otherwise it is a new level; immediate-or-cancel orders are crosses; inserts while stopped are flattening.
  • Reconciliation. Marked P&L is fill edge plus inventory carry. It matches the engine’s own running total run by run, and the session’s total matches the desk’s settlement-based figure exactly.
  • Result by order class. The backtest had predicted the share of top-up fills well and their quality poorly: it had mispriced top-up fills in thin books.
  • A colleague’s question, answered on the orders. Where the old strategy would have posted anyway, the top-up arrived only moments earlier: worth about nothing, as the replay’s decomposition had predicted.
  • The counterfactual. Five arms × two crossing settings replayed on the session’s own ticks and the engine’s own signal values. A queue model does not reproduce the live fill quality of the top-ups, and live inventory ran well above the replay’s. So any throttle has to be priced on logged fills.
  • The market regime, controlled for. He benchmarked the session against historical sessions of similar trendiness under the desk’s main strategy: the regime alone does not explain the gap.
  • A correction Shuo kept. His first report, written on part of the session, pointed to a different cause. The full-session classification overturned that, and the final report says so.
Π=∑iσiviM(mti−Pi)+∑txtM(mt+1−mt)
Fill edge plus inventory carry. σ: +1 buy, −1 sell; v: lots; P: fill price; m: mid price; x: position from cumulative fills; M: contract multiplier (16 metric tons per lot for live hog). The mark-out at horizon Δ is the first term with the mid taken Δ later.

Testing rules on logged orders, not on the simulator

For each logged top-up order Shuo rebuilt the state any candidate rule would have seen at that instant: level size, the desk’s lots there, the queue behind the desk’s newest order, the volume traded at that exact price over the last few seconds, the recent maximum level size, time since the last fill, the engine’s quote center and signal. A rule is then scored as a subset of the logged fills, blocked against kept, judged per run and never pooled, and no per-lot figure is reported on fewer than 50 lots.

The traded-flow gate needs each snapshot’s volume split into lots done at the bid and at the ask. The exchange publishes only cumulative volume and turnover, so the split is solved from the average trade price. When he specified the C++ port, he required std::lrint: it rounds halves to even as Python does, and lround differed on 10,311 of 200,000 synthetic snapshots, every one an exact tie.

vask=T−Vpbidpask−pbid,vbid=V−vask
One snapshot’s traded volume V and turnover T (in price units, per lot) split between the two prices that bracket the average trade price T ÷ V: the lots done at the ask, rounded to a whole number, and the remainder at the bid.
Three of the 88 candidate rules, and the baseline. First-order scoring on logged fills: the position path is not re-simulated. Results and settings are confidential; the chart in the last feature above illustrates the comparison.
Rule, applied to the logged top-upsHow much it blocksVerdict
No ruleNothingThe baseline every rule is scored against
Queue-depth rule: enough lots queued behind the desk’s last orderMost top-upsWorks mainly as an off switch; also needs a queue-position estimate
Traded-flow gate: skip when the level has just traded heavilyFar fewerThe only selector whose blocked fills were consistently worse than the fills it kept; needs market data alone
Wider-edge filterThe most of the threePrecise, but a cliff

The no-flip rule: check after adding

Top-ups queue behind the original order, so when the target scales with inventory, a full sweep of the stack can carry the position through zero and out the other side by a whole order. Shuo raised it from the trading seat: if that level is run over, the adverse move is paid on a doubled position.

A no-flip condition is the natural fix, and where it is checked decides whether it works. Checked before adding, it passes whenever the lots already resting cannot flip the position, and the new order then stacks on top of them. On the logged orders that was the case that mattered most. Checked after the add is sized, it blocks that case. The desk adopted the post-add form.

He also traced, in the logs, every distinct cause of oversized stacks; the specification closes those in the strategy’s own sizing and trimming logic and documents the remaining one with an operating rule.

e+s+p≤0instead ofe+p≤0
Buy side while short (p < 0), with e the desk’s lots already at that price and s the new order: top up only if the desk’s lots at that price, including the new order, cannot carry the position through zero.

From findings to a build

The engine team asked for a full strategy description, not a list of edits. Shuo wrote one that can be implemented from scratch.

  • Contents. Terms; every parameter; inputs; a 16-step per-snapshot processing order; every rule stated as a testable condition; order-state and restart handling; 12 acceptance cases; an evidence appendix.
  • Observability by design. One log line per top-up decision with every input and the reason, so the next live session can be scored from the log alone.
  • Checked by reading. Proposed C++ changes were verified without compiling: types, const-correctness, format strings, and each before / after block compared line by line with the source it patches.
  • Read back in the build. He verified the engine team’s build against the specification by reading its source.3
  • Tooling kept in step. Strategy One validates and edits the new parameters; CHRONOS switches a contract between the two strategies safely and keeps a separate sizing model for each.

Why not something simpler?

The questions a market-making quant asks first, with the answer the data gave to each.

Each row is expanded, with its method, in the sections above.
The obvious alternativeWhat the data said
Just raise the order sizeAdds size on both sides and at every level. The top-up adds it only on the position-reducing side, at the touch, after a fill, and earned more per marginal lot in the replay
Credit the earlier queue placeWorth about nothing: a small part of the simulated gain, not significant on mark-out, zero under conservative queueing; live, a head start of moments
Tune the guard in the backtestWrong sign. The guard acts only in thin books, where a snapshot queue model over-credits fills; observed fills reverse the verdict
One flat multiple, or a flat lot countDepth ÷ order size explains fill quality far better than absolute depth, but the best multiple falls as size grows. A flat multiple silences a large share of quoting time at large sizes; a floor and a cap do not
Count the whole displayed levelThe desk is a sizable share of the touch at fill moments, so a larger quote passes its own safety test more easily. External depth also discriminates better
Pull the quote on any thin sideA market maker has to keep resting size on both sides, so the guard blocks only the position-adding side
Require enough lots queued behind the deskWorks mainly as an off switch and needs a queue-position estimate. The traded-flow gate uses market data alone and keeps far more of the fills
Check the no-flip rule before addingStill passes when the resting lots alone cannot flip the position, the case that mattered most on the logged orders. Checked after adding, it blocks that case.
Cap the stack at twice the order sizeDoes not touch the case that hurts: a position of one order size, a stack of two, swept through zero to one order size on the other side

Failure modes engineered out

  • Over-credited stacking: same-price FIFO in the replay.
  • Wrong-sign thin-book results: fill-based pricing replaces the simulator wherever depth is the question.
  • A guard that disarms itself: external depth, with the desk’s own lots removed.
  • A guard that starves large orders: the cap. One that fails small orders: the floor.
  • A guard configured without its bounds: Strategy One’s template carries them, and its editor shows any bound a block leaves out.
  • A flow gate that drifts between languages: the C++ port pinned to the Python reference’s rounding, tested on 200,000 synthetic snapshots.
  • Small-sample stories: paired tests, per-run verdicts, a 50-lot minimum for any per-lot figure, and Shuo’s own standing rule for the redesign review: a failure case counts only if it happened in the data.
  • Hand-typed numbers: every report is generated from JSON by script.
  • The next live session going unscored: one log line per top-up decision, written into the specification and present in the build.12

Built with

  • Python (standard library only)
  • C++ code review
  • Backtesting
  • Ablation / paired A/B testing
  • Statistical inference (paired t-tests)
  • Model validation: simulation vs. live
  • Market microstructure
  • Order-book queue modeling
  • Mark-out analysis
  • Counterfactual replay
  • Streaming log parser
  • Data pipelines (2.7 GB of ticks per day)
  • Multiprocessing
  • SQL
  • Requirements specification
  • Decision logging / observability

06Releases

Shipped in versions, like a product.

  1. v1.0 · Code review and economic value15 findings and 5 bundled changes documented; the A/B valuation on the exact replica.
  2. v1.1 · Thin-book guard from fillsThe guard priced on the desk’s historical passive fills; the single multiple replaced by a floor and a cap.
  3. v1.2 · External depthThe desk’s own resting lots reconstructed and removed from the depth the guard reads.
  4. v1.3 · First live sessionWhole-session order forensics, a five-arm replay of the session’s own ticks, and 88 candidate rules scored on the logged top-ups.
  5. v1.4 · Top up to flat onlyThe position-doubling stack explained; why the guard must always carry its cap.
  6. v1.5 · Redesign verifiedThe redesign scored rule by rule on logged orders; the no-flip check moved to after adding.
  7. v1.6 · Requirements specification16-step per-snapshot logic, 4 new parameters, 12 acceptance cases; built by the engine team in its next build.
  1. 1The smart-queue strategy and every engine build are the work of the desk’s engine team; the reference simulator and the price signal are the model team’s. The review, the replay engine, the fill-based studies, the live-session reconstruction, the rule tests and the specification are Shuo’s.
  2. 2The engine team implemented the floor-and-cap guard on external depth, and it runs in production. The multiple, floor and cap are the desk’s settings and are not published. No realized profit effect is claimed for the change.
  3. 3Checked by reading the source of the engine team’s build against the specification. No live results of that build are claimed.
  4. 4Charts, figure data and screenshots on this page are synthetic, illustrative or public market data. Methods and outcomes are described as they happened; the desk’s own figures are confidential and do not appear here.
  5. 5A designated market maker must keep a minimum size on both sides, within a maximum spread, for a minimum share of each month’s trading time.
  6. 627 validation rows, each matching the reference simulator (Shuo’s line-exact port of the model team’s backtester) on P&L, lots, withdrawals, failed cancels, crosses and the complete fill list. The check runs his engine with the reference’s own queue rule; the study’s baseline then enforces first-in-first-out between the desk’s own orders at one price.
  7. 7Simulated on a snapshot replay across several live-hog contracts, 17 rule arms, each comparison paired by trading day. Snapshot simulations over-credit fills at swept price levels, which is why the thin-book questions on this page were priced on fills instead.
  8. 8Fill quality is the 5-second mark-out per lot of position-adding passive fills. First-order estimate: the position path is not re-simulated. Fill counts and the sample window are confidential.
  9. 988 candidate rules scored on the logged top-up orders of the strategy’s first live session, judged run by run; first-order (the position path is not re-simulated). Results and settings are confidential.
  10. 10Simulated on the same sample: a larger order size against the top-up mechanism. The simulator understates what plain size buys, so the two levers are best read as complementary. Under conservative queueing the top-up’s marginal lot is worth less.
  11. 11The share of quoting time on the position-adding side that each rule would switch off, counted on tick data by order-size band.
  12. 12Scope of the evidence: no realized profit improvement is claimed for the guard, the flow gate or the redesign; simulated values carry the queue-model bias this page describes, and the fill-based studies are first-order (the position path is not re-simulated).
Previous
Previous

FakeSPD Backtester

Next
Next

Live vs Backtest