Live-Hog FAK Daily Report

Software · Desk tool

Live-Hog FAK Daily Report 生猪FAK日报

Every trading day it replays every live order through the desk’s own backtest and through an improved one, by itself, and shows order by order where the simulator is optimistic.

  • Conceived, designed and built by Shuo Huang, on his own initiative
  • In production from 25 Aug 2026
  • Every live order · 2 matching engines · 8 outcomes
  • 346 report pages, built automatically
  • 3 products · 9 contracts
  • Code-signed one-file app for colleagues

01System architecture

One click pulls the day, and the report builds itself.

The pull is read-only and dates itself; the results land in a dated run folder; a resident watcher checks them and builds every report that is missing. No date or contract is typed, and nothing is installed.

Trading engine

Engine log

Every order, acknowledgment, cancel and fill, stamped to the millisecond. The engine and its log are IT’s.

Log archive

Daily log archives

One day’s engine log per archive.

Read-only

Desk database

Market data and the desk’s own records.

One click

One-click pull

Step 1 fetches missing log archives. Step 2 runs a SQL extract that finds the trading day and the contracts by itself.

Dated run folder

Day package

One folder per trading day, each file verified before it is renamed into place.

Always running

Watcher

Copies only finished files, refuses half-day pulls, lists what is missing, never rebuilds a finished report.

Analysis

Replay step chain

Ten steps in a fixed order. Every live order runs through two matching engines: the desk’s current one and an improved one.

A colleague’s PC

One-file app

Code-signed single file. Drop in the two inputs, get the same pages, offline.

Output

Report pages

Two pages per contract per day, plus a combined page when several contracts trade. Self-contained HTML and SVG.

Simplified: the same click also pulls the egg and coking-coal data, in parallel.

Why a package and a watcher?

Pulling the data and analyzing it are separate steps, done within the access the desk already has. The package is the hand-off between them, so every guard on the analysis side assumes a file may be half-written, a day old, or somebody else’s.

Why does the pull date itself?

No machine clock and no typed date is trusted, and the dominant contract rolls every couple of months. So the SQL takes the newest trading day found in the data and that day’s highest-volume contract. A contract roll needs no edit; the new dominant contract is picked up by itself.

Why two matching engines?

Both pages replay the same orders, in the same windows, valued the same way. Only the matching rule differs. Subtract one page from the other and what is left is the effect of the matching rule alone.

Whose work is whose

The trading engine and its logs belong to IT. The backtest matching rule being audited is the model team’s. Colleagues contributed the eight-outcome diagram, a revised volume allocation (identical to a rule Shuo had designed independently), the self-liquidity point and the signal-to-profit specification. The bit-exact replica, the replay, the improved matcher’s queue correction and self-liquidity guard, the report, the pull, the watcher and the app are Shuo’s.

02The story

Every live order replayed through the backtest, every day: a standing audit of the simulator.

A trading desk judges its strategy with a simulator. This report is the daily reality check: it takes every order the desk’s engine sent to the exchange that day, replays each through a bit-exact replica of that simulator, and shows order by order where the two disagree. Shuo conceived it, built it from scratch on his own initiative, and made it run itself, every trading day.1

  1. 01

    The problem

    The desk makes markets in live-hog futures with a high-frequency engine, and judges that engine’s strategy with a backtest: a simulator that decides which of its orders would have traded. If the simulator is generous, every decision built on it is too.

    One order type makes the gap easy to see. A fill-and-kill order (FAK) is a now-or-never order: it trades immediately against whatever is on the other side, and anything left over is canceled on the spot. A snapshot simulator sees the market four times a second and assumes the price it saw is still there. At the exchange, a faster trader may have got there first.

    Shuo had already shown, in a research study, that live results trailed the backtest, and where the two part ways. Answering the same question for one more day meant:

    • a SQL query dated by hand
    • an engine log fetched by hand
    • eight scripts run by hand in a fixed order, where one skipped step produced a clean-looking table of zeros
  2. 02

    What he built

    A report that makes itself. One click pulls the day’s data and logs, read-only; the SQL works out the trading day and the contracts on its own. A program that is always running notices the day’s package, checks that the files are whole and cover the full day, and builds every report that is missing.

    Each report is a referee’s review of the day. Every live order is replayed twice: once through a bit-exact replica of the desk’s simulator, once through an improved one. Each order lands in one of eight outcomes: two order types, crossing or resting, times four fates (traded in both worlds, in neither, only in the simulator, only at the exchange). Each disagreement is valued. The page also tracks how often crossing orders miss, how long resting orders wait in line, and how order latency moves with results minute by minute.

    Then he packaged the live-hog edition as a code-signed one-file Windows app, so a colleague can drop in the same two files and get the same pages.

  3. 03

    What changed

    The desk went from a one-off study to a daily instrument: 346 report pages, built automatically, for live hog, egg and coking coal.1

    The daily series settled what single days could not. The audit found a consistent optimistic bias in the backtest and quantified it every day; an improved matching rule cut it substantially.2 On crossing orders the bias ran one way: the simulator booked fills the exchange never gave.

    The same order records answered a desk question about order types. A fill-and-kill order and a limit order sent at the same instant differ only in the unmatched remainder; that identification argument let Shuo compare the two on live records without guessing queue position, and he recommended the option the data favored.3

    It also kept everyone honest, its author included. After Shuo’s own latency analysis, the desk gave its live-hog engine a server of its own. The report then checked, day after day, whether orders had become faster. It showed no speed-up, so no gain is claimed for the move.4 And when an engine restart reused order identifiers, Shuo re-keyed every order by engine run and accepted the fix only after the restart days reconciled with the database.

346

report pages built automatically, for 9 contracts in 3 products1

8

outcomes every live order is sorted into: what the exchange did against what the simulator says

2

matching engines replay the same orders every day: a bit-exact replica of the desk’s, and an improved one

55s

from the day’s package arriving to both finished reports, first live run5

5/5

pages byte-identical between the pipeline and the one-file app handed to colleagues

466.6M

engine-log lines distilled to one contract per day for a colleague’s analysis, in 350 seconds

03Evidence

What the daily audit shows: a generous simulator, and how much a better rule removes

Every trading day the report replays every live order through the desk’s current matching rule and through the improved one, then nets what each books against what the same orders earned at the exchange. The chart shows the shape of that output on synthetic data.6

Daily over-credit, current rule against improved rule

In this illustrative series the current rule over-credits on all 30 days, and the improved rule removes a median 62% of it.

Show the dataHide the data
Data: Daily over-credit, current rule against improved rule
Trading dayCurrent ruleImproved rule
113474
25412
3194104
4101−3
59151
67924
76631
87232
912817
1015053
1110930
125626
13189109
1413857
1544−4
166220
1718189
187941
199727
2011069
2113855
222910
233010
247243
258629
269016
274330
288525
2913342
3016180
Synthetic data. Illustrative values, generated to show the effect. The method is as built; the desk’s own figures are confidential. Over-credit is what a matching rule books for the day’s live orders, valued by 5-second mark-outs, minus what those orders earned at the exchange. Both lines are indexed so that the current rule’s 30-day average = 100; below zero the improved rule under-credits (2 days here).

04Functions

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

A

Pull the day with one click

One file to click and one password to type. Nothing is ever edited: not the date, not the contract.

  • Fetches any missing engine-log archives first, each one verified by size before it is renamed into place
  • The SQL resolves the newest trading day and the dominant contract from the data, then adds every contract the engine traded
  • Says so loudly when the database has not loaded today yet, instead of quietly pulling yesterday

B

Hand over the day and walk away

A watcher that is always running turns the day’s package into finished pages, about a minute per contract.

  • Copies a file only after its writer has closed it, and refuses a pull whose market data stop before the close
  • Surveys the last seven days and builds whatever is missing, oldest first; a status view lists each day as done, to build, missing pull or missing log
  • Restarts itself when its own code changes, and never rebuilds a finished report on its own

C

See each order’s two fates

Every live order is classified by what happened to it at the exchange and what the simulator says happened: eight outcomes, counted and valued.

  • Order type is read from the engine’s own log, never guessed from the outcome
  • Two pages per contract: the desk’s current matching rule, and an improved one, on identical orders
  • Each of the three trading sessions gets its own matrix, and the sessions add back to the day exactly
English redraw of the report's fate matrix on a synthetic day: eight rows lettered A to H, each with a count of orders, lots filled live and lots filled in the replay. Totals: 748 orders, 1,451 lots live, 1,383 lots in the replay. Enlarge
Synthetic data. Redrawn in English from a generated report day. The heart of every page: one row per outcome, A to H. Read across a row to compare what the exchange filled with what the replay filled.6
  1. Marker 1: Three columns: number of orders, lots filled in live trading, lots filled in the replay.
  2. Marker 2: Row B, phantom crosses: 15 crossing orders missed at the exchange, yet the replay filled 54 lots of them.
  3. Marker 3: Row D is empty: a cross that filled live but missed in the replay. On crossing orders the snapshot rule errs in one direction.
  4. Marker 4: Row F, phantom fills: 36 resting orders were canceled unfilled, yet the replay filled 182 lots of them first.
  5. Marker 5: Row H, the ghost queue: the exchange filled 400 lots (28% of the day’s live lots) that the replay never reached, because a snapshot cannot show where an order stands in line.

D

Catch the simulator filling too early

For orders that traded in both worlds, the page measures who filled first, and shows what a better matching rule changes.

  • In the session bars below, violet is the replay filling first: the optimistic direction
  • The improved matcher lowers that early share, session by session and day by day
  • A histogram of the timing gap, with the 250 ms snapshot grid called out so alignment noise is not mistaken for a finding

Orders the replay filled first

On every one of the 30 illustrative days the improved rule lowers the share of orders the replay fills before the exchange did: median 21.6% against 56.1%.

Data: Orders the replay filled first
Trading dayCurrent ruleImproved rule
148.8%11.4%
256.9%23.7%
349.6%15.3%
448.5%14.3%
561.6%27.6%
655.5%22.5%
758.8%28.0%
862.7%30.5%
955.4%21.7%
1060.0%22.1%
1156.6%15.9%
1245.0%14.3%
1357.5%19.4%
1460.2%24.8%
1554.8%16.4%
1657.7%19.9%
1755.6%24.4%
1856.7%25.8%
1952.9%16.0%
2060.7%26.7%
2161.9%27.7%
2249.5%18.3%
2366.2%31.2%
2450.7%21.2%
2557.4%18.4%
2660.4%22.0%
2748.8%17.7%
2855.0%21.9%
2952.1%21.5%
3045.0%17.4%
Synthetic data. Illustrative values, generated to show the effect. The method is as built; the desk’s own figures are confidential. Orders filled in both worlds whose first fill came earlier in the replay than at the exchange, as a share of all orders filled in both.
English redraw on a synthetic day: three stacked bars per matching rule, one per trading session, split into replay first, same snapshot and replay later. Replay-first shares are 66, 67, 65 percent under the current rule and 14, 13, 7 percent under the improved rule. Enlarge
Synthetic data. The same day’s orders under each rule: the violet, replay-first share falls from 66 / 67 / 65% to 14 / 13 / 7% across the three sessions.
  1. Marker 1: Key: violet is the replay filling first, gray is the same 250 ms snapshot, amber is the replay filling later.
  2. Marker 2: Violet, 66% (early morning, current rule): the replay filled these orders before the exchange did. This is where optimism enters.
  3. Marker 3: Violet, 14%: the same orders under the improved rule.
English redraw on a synthetic day: histogram of the replay's first fill time minus the live first fill time, in ten bins from more than ten seconds early to more than 2.5 seconds late. Violet bars on the left, one gray bar, amber bars on the right. Enlarge
Synthetic data. How early, how late

E

Track execution quality, a month at a glance

Beyond the audit, each page doubles as a daily execution monitor for the desk: missed crosses, latency minute by minute, and how long orders wait to fill.

  • Miss rate of crossing orders per day, with its trend
  • Order acknowledgment and market-data delay per minute, set against that minute’s result, with rank correlations and a noise band
  • Order-to-first-fill waiting time as a trailing-month fan chart
English redraw on synthetic data: four headline cards above a fan chart of order waiting times in seconds over 22 trading days, with shaded percentile bands, a median line and a ringed dot for today. Enlarge
Synthetic data. How long a resting order waits for its first fill, day by day for a month.
  1. Marker 1: Today’s median wait for queued orders, 26.0 seconds, with the month’s median (22.1 seconds) beside it.
  2. Marker 2: Fill share: 40% of resting orders placed today were filled (253 of 640).
  3. Marker 3: Outer, darker band: the 10th to 90th percentile of waiting time on each day.
  4. Marker 4: Inner, lighter band: the middle half of orders (25th to 75th percentile); amber dots are daily means.
  5. Marker 5: White line: the daily median; the ringed dot at the right edge is today.

F

Check that the price forecast turns into money

One section of the page follows each price-forecast signal into the position change that came after it and the price move that came next.

  • For every signal: how the desk’s position changed in the next second, and what the market then did over 1, 5 and 30 seconds
  • Split into trades made with the signal and trades made against it, each with its own mark-out
  • Built to a colleague’s specification; the forecasting model is the desk’s, the measurement and its leak-proof price reference are Shuo’s

G

Hand it to a colleague as one signed file

The one-file app produces the same pages on a colleague’s PC, with nothing to install.

  • Drop the day’s log archive and data pull into the window; wrong inputs are refused with the reason
  • Code-signed, single instance, self-healing on every start; closing the window stops the run
  • Accepted only after 5 of 5 pages matched the pipeline’s byte for byte

05All screens

Four views of the program.

06Under the hood

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

Under the hoodModels, math and code for the technical reader

For the quant, the ML scientist and the engineer. This is model validation in production: a simulator (the desk’s backtest matching engine) is scored every day against ground truth (what the exchange did with the same orders). Below: what is replayed, how the two matching engines differ, how a disagreement is valued, the statistics behind each panel, pseudo-code of the key steps, and the failure modes this pipeline was hardened against. On the report itself, every number and every sentence that reads one is computed from the pipeline’s own outputs; none is typed by hand.

Unit of analysis and data

The unit is one live order with its full lifecycle: insert time, price, size, side, order type, acknowledgments, cancel request, every partial fill. It is parsed from the engine’s millisecond log, because a trade ledger holds only aggregates.

Market data are the exchange’s five-level snapshots at 250 ms. One extract per day returns a fixed sequence of result sections, read by position. The fate analysis uses the backtest’s own session windows; the latency panel uses whole sessions, because opening minutes are where latency trouble would show.

Two matching engines on identical inputs

Current rule. A bit-exact replica of the desk’s snapshot-based backtest matcher, so that what the page audits is the simulator the desk uses and not an approximation of it.

Improved rule. Three stacked changes: a colleague’s revised volume allocation (proven identical to Shuo’s own grid allocation on every quarter-second slice compared), Shuo’s queue-join correction, and a guard that stops the desk’s crossing order from filling against the desk’s own resting order at the same price.

The guard is measured, not assumed. At the exchange a crossing order does not take the desk’s own resting quote; an unguarded replay happily fills it. Shuo verified the point on the live record before building the guard.

The replay is driven by the live order stream: each order dies in the replay at its live cancel or fill time, and an unfilled fill-and-kill order lives for one slice. Same orders, same windows, same horizons, so the two pages subtract cleanly.

Q←Q+α·max(0,DW−Q),α=0.5
Queue-join correction. Q is the queue the model believes is ahead of the desk’s order; D_W is the size other participants show at the desk’s price in the first snapshot that certainly contains the desk’s order. If more is displayed than the model thought was ahead, somebody joined in the same 250 ms window; α = 0.5 assumes half of them arrived before the desk (arrival-time symmetry). α = 0 means no correction; α = 1 is the worst case.
Pseudo-code
# 1. self-liquidity guard: checked when a trade prints at the order's price
if order.is_crossing and own_quote_rests_opposite(order.price):
    skip_fill(order)            # that liquidity is our own

# 2. queue-join correction: once per order, at the first snapshot W
#    that certainly contains the order
others = displayed_size(W, order.price) - own_size(W, order.price)
if others > order.queue_ahead:
    order.queue_ahead += alpha * (others - order.queue_ahead)   # alpha = 0.5
Pseudo-code. The two improvements, simplified: the self-liquidity guard, then the queue-join correction.

Eight outcomes from a three-bit key

Each order gets a key of three bits: is it a crossing (fill-and-kill) order, did it fill live, did it fill in the replay. The taxonomy is a colleague’s diagram; implementing it exposed a bug in the earlier heuristic, which had inferred the order type from the outcome and so made class D impossible by construction. Reading the true type from the log fixed it and produced a finding: under the current rule, class D does not occur. The simulator’s error on crosses is one-directional.

Why order by order and not day totals: the classes offset. B and F inflate the backtest, H deflates it, and a daily total nets them into one number that hides all three mechanisms. For class H the page also records the model’s state at the moment the exchange filled the order: how many lots the replay still believed were queued ahead.

Pseudo-code
key = (is_crossing_order, filled_live, filled_in_replay)

OUTCOME = {
    (1, 0, 0): "A", (1, 0, 1): "B", (1, 1, 1): "C", (1, 1, 0): "D",
    (0, 0, 0): "E", (0, 0, 1): "F", (0, 1, 1): "G", (0, 1, 0): "H",
}
Pseudo-code. The eight outcomes as a three-bit lookup, simplified.
B and F inflate the backtest; H deflates it. The page values each block and nets them.
ClassOrderLiveReplayWhat it means
ACrossMissedMissedAgreement
BCrossMissedFilledPhantom fill: the simulator books a cross the exchange never gave
CCrossFilledFilledAgreement; timing may differ
DCrossFilledMissedNot observed under the current rule
ERestingCanceledNever filledAgreement
FRestingCanceledFilled firstReplay fills before the live cancel: queue too optimistic
GRestingFilledFilledTiming may differ
HRestingFilledNever filledThe ghost queue: queue position is invisible to snapshots

Valuing a disagreement

Every partial fill is valued by its mark-out: where the book’s mid-price stands a fixed time after the fill, relative to the fill price. The day’s over-credit is the replay’s total minus reality’s, at 30, 5 and 2 seconds; the headline uses 5 seconds, the desk’s standard view.

Mark-outs rather than hold-to-close, because the replay is open-loop: a fate difference creates a phantom position that the fixed live order stream never rebalances, so carrying it to the close would measure drift, not matching. Timing compares first fill with first fill.

vh=s·q·M·(m(t+h)−p),Δh=∑replay fillsvh−∑live fillsvh
s is +1 for a buy and −1 for a sell, q the lots filled, M the contract multiplier, p the fill price, m(t+h) the book mid h seconds after the fill, h ∈ {2, 5, 30} s. A positive Δ means the simulator credits the desk with value reality did not deliver.

What the daily series measure

Each daily measurement is a full replay of that day’s live order stream on one contract. The audit found a consistent optimistic bias in the backtest, and the gap is structural, not a good-day artifact: the bias appeared on good and bad days alike.

What each series measures and what it showed, in words. The desk’s own figures are confidential; the charts on this page illustrate the outputs with synthetic data.
SeriesHow it is computedWhat it showed
Over-credit under the current ruleReplay value minus live value of the same orders, mark-outs at 2, 5 and 30 sA consistent optimistic bias
Over-credit removed by the improved ruleThe same orders through both rules, paired day by dayCut substantially; on a few days the improved rule under-credits
Replay-fills-first shareOrders filled in both worlds, first fill against first fillLower under the improved rule
Class D, live cross filled but replay missedCount per day, order type read from the logNot observed under the current rule: the error on crosses runs one way
Miss rate of crossing ordersShare canceled with nothing filled, per day, with its trendTracked daily
Acknowledgment and market-data delay against the minute’s resultSpearman rank correlation with a noise band and partial controlsNamed only when it clears the band and survives the controls

The latency panel, and an honest check on a server move

Two delays are measured per minute. The acknowledgment round trip (order sent to exchange acknowledgment received) is timed on one clock. The market-data delay compares the local log time with the exchange’s stamp, so it crosses two clocks and is read only for its variation within a day.

Each is rank-correlated (Spearman) with that minute’s marked-to-market result: raw, within session, partial on the size of the price move, on quiet minutes only, and on minutes with no crossing order. The page names a co-movement only when the coefficient clears a band of ±2/n, checks it against the desk’s own order rate and market volume so that fast markets are not mistaken for slow orders, and says in the text that the band is optimistic because neighboring minutes are not independent. A pattern is reported as something worth checking in the order channel, never as a cause.

The same series kept the desk honest about its own infrastructure. After Shuo’s latency analysis, the desk gave its live-hog engine a server of its own. The report then checked, day after day, whether the order path had become faster. It showed no speed-up, so no gain is claimed for the move.4

Does the price-forecast signal convert into profit and loss?

A colleague specified the question (the forecasting model and its training are the desk’s, not Shuo’s); Shuo defined the statistic once, in one module, so that the daily report and any study compute the same number, and backfilled it over past days’ logs.

An event is a decision tick with a non-zero forecast. Windows are non-overlapping, so every fill is counted at most once; position is the account’s, rebuilt from fills, never a strategy’s own counter, which a restart resets. Each event is split by whether the position moved with the forecast’s sign or against it, and each bucket also carries the ordinary fill-price mark-out, because a mark-to-mid statistic leaves out the spread the fills themselves earned or paid.

The leak that had to be closed. Any reference price that already embeds the forecast puts the signal into its own baseline on exactly the event ticks. The reference is therefore the plain book mid of the last market-data update before the decision: the book the strategy saw, with no look-ahead.

Verification: a synthetic self-test, a brute-force recomputation on a separate code path for two full days (every total equal), and reproduction of an earlier study’s event counts.

ΔP=P(T0+1 s)−P(T0),PnLh=ΔP·M·(S(T0+h)−S(T0)),per lot=∑PnLh∑|ΔP|
T₀ is a decision tick with a non-zero forecast, P the account’s net position, S the book mid, M the contract multiplier, h ∈ {1, 5, 30} s. A horizon that runs past a session close is frozen at the close, so every horizon shares the same events and the same ΔP.

Companion study: fill-and-kill or limit, settled by identification

Which order type should a crossing order use? A snapshot replay would have to guess where a resting remainder stands in the queue, so the study uses an identification argument instead.

Identification. A fill-and-kill order and a limit order sent at the same instant receive the same immediate match. They differ only in the unmatched remainder: one is canceled, the other rests at the crossing price. On days when crosses are limit orders, therefore, the fill-and-kill outcome is the immediate part, and the later fills are limit minus fill-and-kill, observed directly instead of simulated. Crosses are identified by the engine’s own marker, never by order type, and only like periods are compared.

The naive alternative, tested and rejected. Replaying fill-and-kill days as if the remainder had rested first in the queue matched the volume of later fills but overstated their value, because other participants who missed the same price rest ahead of the desk. Shuo recommended the option the data favored.3

A SQL extract that needs no date and no contract

The extract resolves its own parameters from the data, so no clock and no typed date matters and contract rolls follow automatically. Section order is a hard contract: the parsers key on position, so nothing that returns a result set may precede the first section, and new sections are only ever appended.

Two engineering details. Contracts the engine traded are found by scanning the newest log archives with a regular expression in 4 MB chunks (402 MB of log in 1.8 seconds) and passed to SQL as literals. And one section’s bare regular-expression filter forced a full index walk, 380 seconds of an eight-minute pull; an index-friendly prefix turned it into a range scan with identical rows, and on every pull since, that section has finished in about 0.2 seconds.

Pseudo-code
day      <- newest trading day present in the tick data
main     <- the product's highest-volume contract on that day
contracts<- main + every contract found in the newest engine logs
window   <- a few trading days ending on day

return the result sections in a fixed order, for contracts over window
Pseudo-code. How the extract finds its own parameters, simplified.

Failure modes engineered out

Most guards below exist because the failure they prevent is silent: the pipeline would have produced a plausible page with wrong numbers.

The sharpest case: an engine restart reused order identifiers, so two different orders shared one key and one of them dropped out of the day. The headline barely moved, because orders dropped out of numerator and denominator alike. Shuo re-keyed orders by engine run, and the tracker sees every log line before any parser filters it. The acceptance test was the database: the restart days had to reconcile on lots, fills, cash flow to four decimals and net position before the fix shipped.

Pseudo-code
run = 0
for line in engine_log:                 # every line, before any filter
    if marks_engine_start(line):
        run += 1
    elif places_order(line):
        oid = order_id(line)
        key = oid if run == first_trading_run else (oid, run)
        track(key, line)

# shared output folders: match the WHOLE file name, never a prefix
Pseudo-code. Per-run order keys, simplified. A day’s first run keeps the plain identifier, so every single-run day rebuilds byte for byte.
Failure modes of the pipeline itself, each with the guard that closed it; the first two were designed out from the first version.
FailureHow it showed upGuard
Pull taken before the closeA believable half-day reportTicks must reach the end of the last session, or the day is refused with the reason
File still being copiedTruncated inputWrite-handle check, then size and timestamp stability; pending state survives a restart
Another study’s files in the shared output folderForeign files were parsed as trading days and the build failedWhole-file-name matching
A different product’s pull beside the day’s ownIngested as the live-hog dayOnly the one expected file name is ingested
Engine restart reuses order identifiersOrders silently dropped from a day’s reportPer-run order keys; database reconciliation as the acceptance test
Watcher still running old code after an editYesterday’s finished report rebuilt instead of today’sSupervisor loop restarts it on a code change; version and process banner; finished reports are never rebuilt automatically
Database not yet loaded for todayThe previous day’s data came back instead of today’sPre-flight check of the newest trading day, loud stale-day warning
Order type assumed instead of readA cross of another type was mis-sortedCrosses identified by the engine’s own marker; every order type reported
Hard-coded sentences in the reportProse drifted from the dataEvery reading on the page is computed

Testing and the release gate

The automation computes nothing itself: every number still comes from the validated research scripts, and the pipeline supplies ordering, guard rails and file movement. That makes the release gate simple and strict: after every structural change, finished days must rebuild byte for byte (SHA-256). The first automated run, on a day already built by hand, matched both hand-run reports byte for byte; so did every later refactor on the days it was checked against.

  • A stand-in database client replays a captured pull byte for byte, so the whole pull is testable with no database: suites of 24 of 24 and 43 of 43 checks
  • Log-derived results are checked against the database to four decimals, which is what makes a same-day figure usable before settlement posts7
  • The colleague app ships the step scripts byte-identical to the pipeline’s, with a manifest of hashes; acceptance was 5 of 5 pages identical
  • When a panel was added, existing days were re-run and compared key by key, and only the new keys could change
  • Session breakdowns must add back to the day; the identity is asserted in code

Alternatives rejected, and why

  • Comparing daily totals. That is what existed before. Totals net the classes that inflate the backtest against the one that deflates it, and cannot say why the two worlds differ; the unit here is the single order.
  • Hold-to-close valuation. Rejected for mark-outs: in an open-loop replay it measures drift on phantom positions.
  • Inferring the order type from the outcome. It under-counted one class and made another impossible; the type is now read from the log.
  • Refusing restart days. The first fix refused any day with reused order identifiers. Orders are keyed per run instead, so every day builds.
  • Replaying fill-and-kill days as if the orders had rested first in the queue. That replay matched later-fill volume but overstated its value, because others who missed the same price rest ahead of the desk. It was dropped for the identification argument above.
  • Rebuilding a finished report when inputs change. Convenient, and a way to overwrite a good report. Finished pages are immutable unless rebuilt on purpose.
  • numpy and pandas. The desk’s PCs are standard-user machines with nothing installed, so everything runs on the Python standard library with a bundled runtime, and the pages are hand-written HTML and SVG with no dependencies.
  • Auto-update for the colleague app. Rejected: the app is rebuilt and handed over with each report change, so every copy matches the pipeline byte for byte.

Side job: 466.6 million log lines distilled for a colleague

A colleague wanted to run his own analysis on the engine logs, which mix several contracts and products. Shuo cut the whole archive down to each day’s dominant live-hog contract and handed over one file.

  • Scale: 466.6 million lines in; 22.3 GB of filtered text written in 350 seconds by 8 parallel workers
  • The hard part: only a minority of log lines name a contract, so a line filter is wrong by construction. The filter is block-aware: it follows the engine’s message loop and attributes each block to its contract, checked on 214,902 blocks
  • Dominant contract per day from the market’s volume, never from the desk’s own order count
  • Two self-checks per day before packing: every dominant-contract order of the original survives, and no output line carries another contract’s token. Passed on every day file
  • Handover notes warn the reader on which days orders must be keyed by engine run, the same restart trap described above

The colleague app

A C# WinForms launcher with an embedded payload: the step scripts and replay modules copied byte-identical, a Python runtime, and the per-day history as seed, with a SHA-256 manifest. It unpacks to the user’s local application folder, verifies and repairs itself on every start, runs its child processes in a job object so closing the window stops everything, allows a single instance, and is Authenticode code-signed to meet the desk’s signing policy. About 10 MB. Before running it refuses a wrong product’s pull, a log from the wrong source, a pull older than the log, and a pull taken before the close, each with the reason.

Built with

  • Python (standard library only)
  • SQL · MariaDB
  • PowerShell
  • C# WinForms
  • Authenticode code signing
  • WinSCP scripted transfer
  • Backtest validation
  • Model validation against live outcomes
  • ML signal monitoring in production
  • Automated data pipeline (ETL)
  • Data-quality guards and reconciliation
  • Order-book replay
  • Market microstructure
  • Mark-out analysis
  • Spearman rank correlation
  • Data pipelines
  • Byte-identical regression testing (SHA-256)
  • Test doubles (stand-in database client)
  • Parallel log processing
  • HTML + SVG reporting

07Releases

Shipped in versions, like a product.

  1. 1.0One-click self-dating pull and the watcher, first checked byte for byte against a day already built by hand. First live run the same afternoon. A second page per day under the improved matching rule followed that evening (1.1).
  2. 1.2Skipped days backfill by themselves; a status view lists what is missing and why.
  3. 1.3Supervisor loop restarts the watcher when its code changes; finished reports are never rebuilt automatically.
  4. 1.4Whole-file-name matching in shared folders; reused order identifiers after an engine restart are detected.
  5. Log fetchEngine-log archives are fetched inside the same click; no more copying by hand.
  6. 1.5Orders keyed per engine run, accepted once the restart days reconciled with the database. The affected report was rebuilt.
  7. 1.6Every page broken down by the three trading sessions.
  8. 1.7Order-to-first-fill waiting time as trailing-month fan charts.
  9. 1.8Signal-to-profit conversion section, to a colleague’s specification.
  10. 1.9Crossing orders of either type, fill-and-kill or limit, are identified by the engine’s own marker and reported.
  11. 2.0Every live-hog contract the engine trades, a combined multi-contract page, and the per-minute latency section.
  12. 2.2Egg and coking coal: parallel pulls with one password, daily pages for both.
  13. App 1.0.0The code-signed single-file edition for colleagues.
  1. 1346 single-day pages between Aug 25 and Nov 10, 2026, the latest page in the archive at the time of writing: nine contracts across live hog, egg and coking coal.
  2. 2Over-credit is the value a backtest matching rule assigns to the day’s live orders minus the value those same orders realized, at a fixed mark-out horizon. The matching rule audited is the model team’s; the improved rule combines a colleague’s volume allocation with Shuo’s queue-join correction and self-liquidity guard. The amounts are confidential.
  3. 3Companion study on the engine’s order records. Which order type the desk uses is the desk’s decision and is not published; the study measured the options and made a recommendation. Its figures are confidential.
  4. 4No speed or profit gain is attributed to the move; the desk’s latency figures are confidential.
  5. 5First live run, Aug 25, 2026: both reports were finished 55 seconds after the watcher received the day’s package. Earlier that day the watcher had rebuilt both reports of a day already built by hand, byte-identical (SHA-256) to the hand-run versions. Later builds took 29 to 82 seconds per contract.
  6. 6Charts, 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.
  7. 7The identity holds on days whose trades all went through the engine; a day with fills placed outside the engine prints a difference by design, and the page says why.
Previous
Previous

The One

Next
Next

Spread Calculator