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.
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
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
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.
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
| Trading day | Current rule | Improved rule |
|---|---|---|
| 1 | 134 | 74 |
| 2 | 54 | 12 |
| 3 | 194 | 104 |
| 4 | 101 | −3 |
| 5 | 91 | 51 |
| 6 | 79 | 24 |
| 7 | 66 | 31 |
| 8 | 72 | 32 |
| 9 | 128 | 17 |
| 10 | 150 | 53 |
| 11 | 109 | 30 |
| 12 | 56 | 26 |
| 13 | 189 | 109 |
| 14 | 138 | 57 |
| 15 | 44 | −4 |
| 16 | 62 | 20 |
| 17 | 181 | 89 |
| 18 | 79 | 41 |
| 19 | 97 | 27 |
| 20 | 110 | 69 |
| 21 | 138 | 55 |
| 22 | 29 | 10 |
| 23 | 30 | 10 |
| 24 | 72 | 43 |
| 25 | 86 | 29 |
| 26 | 90 | 16 |
| 27 | 43 | 30 |
| 28 | 85 | 25 |
| 29 | 133 | 42 |
| 30 | 161 | 80 |
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
Enlarge
- Marker 1: Three columns: number of orders, lots filled in live trading, lots filled in the replay.
- Marker 2: Row B, phantom crosses: 15 crossing orders missed at the exchange, yet the replay filled 54 lots of them.
- 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.
- Marker 4: Row F, phantom fills: 36 resting orders were canceled unfilled, yet the replay filled 182 lots of them first.
- 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%.
| Trading day | Current rule | Improved rule |
|---|---|---|
| 1 | 48.8% | 11.4% |
| 2 | 56.9% | 23.7% |
| 3 | 49.6% | 15.3% |
| 4 | 48.5% | 14.3% |
| 5 | 61.6% | 27.6% |
| 6 | 55.5% | 22.5% |
| 7 | 58.8% | 28.0% |
| 8 | 62.7% | 30.5% |
| 9 | 55.4% | 21.7% |
| 10 | 60.0% | 22.1% |
| 11 | 56.6% | 15.9% |
| 12 | 45.0% | 14.3% |
| 13 | 57.5% | 19.4% |
| 14 | 60.2% | 24.8% |
| 15 | 54.8% | 16.4% |
| 16 | 57.7% | 19.9% |
| 17 | 55.6% | 24.4% |
| 18 | 56.7% | 25.8% |
| 19 | 52.9% | 16.0% |
| 20 | 60.7% | 26.7% |
| 21 | 61.9% | 27.7% |
| 22 | 49.5% | 18.3% |
| 23 | 66.2% | 31.2% |
| 24 | 50.7% | 21.2% |
| 25 | 57.4% | 18.4% |
| 26 | 60.4% | 22.0% |
| 27 | 48.8% | 17.7% |
| 28 | 55.0% | 21.9% |
| 29 | 52.1% | 21.5% |
| 30 | 45.0% | 17.4% |
Enlarge
- Marker 1: Key: violet is the replay filling first, gray is the same 250 ms snapshot, amber is the replay filling later.
- Marker 2: Violet, 66% (early morning, current rule): the replay filled these orders before the exchange did. This is where optimism enters.
- Marker 3: Violet, 14%: the same orders under the improved rule.
Enlarge
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
Enlarge
- Marker 1: Today’s median wait for queued orders, 26.0 seconds, with the month’s median (22.1 seconds) beside it.
- Marker 2: Fill share: 40% of resting orders placed today were filled (253 of 640).
- Marker 3: Outer, darker band: the 10th to 90th percentile of waiting time on each day.
- Marker 4: Inner, lighter band: the middle half of orders (25th to 75th percentile); amber dots are daily means.
- 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.
# 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.5Eight 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.
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",
}| Class | Order | Live | Replay | What it means |
|---|---|---|---|---|
| A | Cross | Missed | Missed | Agreement |
| B | Cross | Missed | Filled | Phantom fill: the simulator books a cross the exchange never gave |
| C | Cross | Filled | Filled | Agreement; timing may differ |
| D | Cross | Filled | Missed | Not observed under the current rule |
| E | Resting | Canceled | Never filled | Agreement |
| F | Resting | Canceled | Filled first | Replay fills before the live cancel: queue too optimistic |
| G | Resting | Filled | Filled | Timing may differ |
| H | Resting | Filled | Never filled | The 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.
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.
| Series | How it is computed | What it showed |
|---|---|---|
| Over-credit under the current rule | Replay value minus live value of the same orders, mark-outs at 2, 5 and 30 s | A consistent optimistic bias |
| Over-credit removed by the improved rule | The same orders through both rules, paired day by day | Cut substantially; on a few days the improved rule under-credits |
| Replay-fills-first share | Orders filled in both worlds, first fill against first fill | Lower under the improved rule |
| Class D, live cross filled but replay missed | Count per day, order type read from the log | Not observed under the current rule: the error on crosses runs one way |
| Miss rate of crossing orders | Share canceled with nothing filled, per day, with its trend | Tracked daily |
| Acknowledgment and market-data delay against the minute’s result | Spearman rank correlation with a noise band and partial controls | Named 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 , 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.
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.
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 windowFailure 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.
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| Failure | How it showed up | Guard |
|---|---|---|
| Pull taken before the close | A believable half-day report | Ticks must reach the end of the last session, or the day is refused with the reason |
| File still being copied | Truncated input | Write-handle check, then size and timestamp stability; pending state survives a restart |
| Another study’s files in the shared output folder | Foreign files were parsed as trading days and the build failed | Whole-file-name matching |
| A different product’s pull beside the day’s own | Ingested as the live-hog day | Only the one expected file name is ingested |
| Engine restart reuses order identifiers | Orders silently dropped from a day’s report | Per-run order keys; database reconciliation as the acceptance test |
| Watcher still running old code after an edit | Yesterday’s finished report rebuilt instead of today’s | Supervisor loop restarts it on a code change; version and process banner; finished reports are never rebuilt automatically |
| Database not yet loaded for today | The previous day’s data came back instead of today’s | Pre-flight check of the newest trading day, loud stale-day warning |
| Order type assumed instead of read | A cross of another type was mis-sorted | Crosses identified by the engine’s own marker; every order type reported |
| Hard-coded sentences in the report | Prose drifted from the data | Every 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.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).
- 1.2Skipped days backfill by themselves; a status view lists what is missing and why.
- 1.3Supervisor loop restarts the watcher when its code changes; finished reports are never rebuilt automatically.
- 1.4Whole-file-name matching in shared folders; reused order identifiers after an engine restart are detected.
- Log fetchEngine-log archives are fetched inside the same click; no more copying by hand.
- 1.5Orders keyed per engine run, accepted once the restart days reconciled with the database. The affected report was rebuilt.
- 1.6Every page broken down by the three trading sessions.
- 1.7Order-to-first-fill waiting time as trailing-month fan charts.
- 1.8Signal-to-profit conversion section, to a colleague’s specification.
- 1.9Crossing orders of either type, fill-and-kill or limit, are identified by the engine’s own marker and reported.
- 2.0Every live-hog contract the engine trades, a combined multi-contract page, and the per-minute latency section.
- 2.2Egg and coking coal: parallel pulls with one password, daily pages for both.
- App 1.0.0The code-signed single-file edition for colleagues.
- 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.
- 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.
- 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.
- 4No speed or profit gain is attributed to the move; the desk’s latency figures are confidential.
- 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.
- 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.
- 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.