Software · Desk tool
Self-Trade Check 自成交检查
A verified first count in 38 minutes and in production within 48 hours: it finds every self-trade on the desk, measures it on the exchange’s basis, traces each one to the spread order and the quote behind it, and reports after every trading session with nobody running anything.
01System architecture
Three exports in, one verified answer in the desk’s chat after every session.
The tool runs on standard-user desk machines with nothing installed: Python’s standard library, no pandas and no database. So the whole pipeline reads the files the trading terminal already exports, checks itself at every step, and is built to stop loudly instead of posting a plausible wrong number.
Uploaded after each session
Fill exports
The terminal’s trade-detail file: night, morning, afternoon, full day.
Inside Spread Calculator
Pairing engine
One exchange trade ID seen as both the desk’s buy and the desk’s sell is one self-trade. Every pair must mirror exactly, or the run stops.
Monthly, from the exchange
Scanned notice
The month’s designated market-making contracts, issued as page images.
Fail-loud
Notice decoder
Must reproduce last month 10 of 10 products, character for character, before it may read the new month.
One shared text file
Designated-contract list
One section per month. A missing month turns every report red.
The exchange’s yardstick
Deduction basis
Self-trade-formed opening lots, on designated contracts only, per contract and per product.
After the close
Order file
A large file every day. Streamed, never loaded; only the orders behind self-trades are kept.
Rule-based, golden-validated
Mechanism classifier
Joins both sides of each pair to their orders: M1, M2, or an anomaly flagged for a person. Never force-fitted.
Self-verifying
Report builder
Nine-sheet workbooks, a month-to-date ledger, three images per session. Each image is pixel-checked.
No chat API exists
Chat sender
Shuo’s WeCom Scheduler: verifies the chat’s title before every send and never re-sends on doubt.
The market-making team
Desk group chat
Sees each session’s self-trades minutes after the file lands.
Simplified: the watcher, the duplicate and regression guards and the retry queues are left out. Counting needs only the fill export; the order file is used only to explain why each self-trade happened.
Why opening lots, not a count of self-trades?
Because what matters is positions. Under the exchange’s market-maker scheme, holdings that self-trades created do not count toward the open interest a market maker is evaluated on.1 A self-trade that only closes positions creates no holding, so the pipeline’s yardstick is the lots that self-trades open, on the month’s designated contracts.
Why a month-to-date ledger?
The basis accumulates over the month, while the terminal’s exports are daily. The only way to know the month’s running total in time is to capture every day as it happens, per contract and per product, which is what the ledger does.
Late is better than wrong
The order file arrives later than the fill file and takes a while to copy. The classifier waits until every order reference resolves and the file is closed and stable, retrying every 20 seconds. A late image is acceptable. A wrong one in a surveillance feed is not.
02The story
Every self-trade found, traced to its orders and reported, in production within 48 hours.
A market maker quotes to buy and to sell at the same time, in single delivery months and in calendar spreads. The exchange turns each resting spread order into legs that no screen displays, and such a leg can land on the firm’s own quote. That is a self-trade: an unintended match between a spread order’s exchange-derived leg and the desk’s own quotes. Positions built that way do not count toward the open interest a market maker is evaluated on,1 and the trading terminal’s export does not mark them. Shuo built, from scratch and alone, the system that finds every one, measures it the way the exchange does, traces it to the two orders behind it, and puts the answer in the desk’s group chat after every trading session, with nobody running anything: a verified first count 38 minutes after he started, and in production within 48 hours.
01
The problem
A market maker is a firm the exchange appoints to quote buy and sell prices all day, and it is evaluated in part on the positions it holds in each month’s designated contracts, the delivery months the exchange names for it. A self-trade, the account’s own buy matching its own sell, creates volume and positions with no real counterparty, so positions formed that way do not count toward that open interest.1
For a desk that quotes calendar spreads and single months side by side, self-trades are a structural by-product of the exchange’s own matching: it turns every resting spread order into legs that no screen displays, and a leg can land on the desk’s own quote. Standard tooling does not show them. The terminal’s export does not mark which fills are self-trades, and the two fills of a pair look like any other two fills. Think of a shop with two tills that occasionally sell to each other: the day’s turnover looks normal, and nothing on either till says which sales were the shop’s own.
02
What he built
The project began as a desk assignment: count the self-trades in a month of trading. Shuo delivered a verified count of a whole month of the desk’s trade records 38 minutes after he started, checked against the export’s own totals.2 He designed that first count to become a program, and within 48 hours it was one, running unattended inside his Spread Calculator:
- It finds every self-trade in each session’s export and proves each pair with both order references.
- It measures them the exchange’s way: opening lots on that month’s designated contracts, per contract and per product. The monthly contract list is decoded from the exchange’s scanned notices.
- It reports by itself after the night, morning and afternoon sessions and for the full day, as three images posted to the desk’s group chat through his WeCom Scheduler.
- It explains every one. Shuo then set out to find why self-trades occur at all. He traced every pair of a multi-day sample by hand to its originating orders and showed that each one came from the exchange turning the desk’s own resting spread orders (one order that buys one delivery month and sells another) into orders no screen displays.3 That attribution now runs automatically after every close.
The first count was the assignment, and coworkers specified what each report should list. Everything else was Shuo’s own initiative: turning a one-off count into a program, the per-session automation and delivery, the root-cause investigation and its daily automation, and the impact metric.
03
What changed
The desk went from no view of its self-trades to a measured one within minutes of each session, on the exchange’s own basis, with the cause attached after every close.
- Traders get feedback at once. Every session’s report shows the effect of a change to the spread orders or the quotes the same day, so the desk tunes on evidence.
- Nobody runs it. A full-day report has gone out after every trading day since launch.4
- The cause has a name. Two mechanisms, their timing to the second, and four concrete engineering counters handed to the desk.
- It became infrastructure. The desk’s next question, which calendar spreads are worth quoting, became the SP liquidity study. The same pairing rule later went into Position Atlas, where it matches the Shanghai exchanges’ own effective open-interest figures on 2,410 of 2,410 contract-days.5
38min
from start to a verified count of a whole month of trade records2
48h
from the first question to an unattended production system
2
mechanisms explain every self-trade traced by hand, with none left unexplained3
4
reports every trading day: night, morning, afternoon and full day, with no one running anything4
13
contract tests pin the classifier, which had to reproduce the hand-traced study before release
03Illustration
Most collisions happen while both orders rest
The delay between the desk’s outright order and the M1 self-trade it ends in, on a generated sample run through the classifier. A check at order entry sees only the first bar.
Delay from the outright order to the M1 self-trade
Only 21% of the sample’s M1 self-trades fire in the second the order arrives; the other 79% happen while both orders rest, so a check at order entry would miss them.
Show the dataHide the data
| Delay after the outright order | Share of the sample's M1 self-trades (%) |
|---|---|
| Same second | 21% |
| 1–10 s | 27% |
| 11–60 s | 32% |
| Over 1 min | 20% |
04Functions
Everything it does, in the order a user meets it.
A
Find every self-trade
One exchange trade ID appearing as both the account’s buy and the account’s sell is one self-trade; nothing is inferred and nothing is estimated.
- Each pair is asserted to mirror exactly in contract, quantity, price and time, or the run stops
- Every pair is listed with both order references as evidence; exchange position offsets are listed separately and excluded
- Every workbook is verified cell by cell against a fresh parse of the raw files before it is released
B
Measure it the exchange’s way
Counts become the number the exchange actually deducts: self-trade-formed opening lots on the month’s designated market-making contracts.
- Each pair is typed both-open, mixed or both-close from its open and close flags
- Two figures side by side: the position created, and the conservative upper bound
- Per contract first, per product second, with a month-to-date ledger behind them
C
A report after every session
Night, morning, afternoon and full day: three images each, in the desk’s group chat minutes after the export lands.
- Each session’s images contain that session’s self-trades only, whatever shape the uploaded file has
- The full day equals the sum of its sessions on every metric, by construction and verified in production
- The sender confirms the chat’s title before sending and never re-sends when unsure
D
The cause, every day
After the close, every self-trade is joined to the two orders behind it and labeled by mechanism, with the delay between the order and the collision.
- M1: the desk’s own ordinary order meets the hidden leg of its own resting spread order; split into instant and drift-triggered
- M2: two of the desk’s spread orders cross on the month they share
- Anything that fits neither is flagged for a person, never forced into a category
Self-trades by cause, a generated sample labeled by the classifier
Every pair in the sample gets a named cause: 62% from M1, 38% from M2, none unexplained.
| Cause | Share of the sample's pairs (%) |
|---|---|
| M1: hidden spread leg | 62% |
| M2: shared month | 38% |
| Unexplained | 0% |
E
A contract list that cannot go stale quietly
The exchange publishes each month’s designated contracts as scanned pages; the decoder refuses to trust its own reading until it has reproduced the previous month exactly.
- Known misreads (l read as 1, lh as Ih, b as 6) are corrected only through an explicit table; anything unexplained aborts
- A month without a list turns the images, the workbook and the page red and names the days to recompute
- A daily reminder card goes to Shuo alone until the list is fixed
F
Which self-trades cost the most
A metric Shuo designed weights each day’s self-trades by how long they weigh on the month’s average position, so early ones count in full and late ones barely at all.
- Ranks products by weighted impact instead of raw counts; the two rankings differ
- Split by product on designated contracts only, a colleague’s refinement
- Produced on request, with monthly comparison images
05How it works
The exchange turns the desk’s own spread order into an order nobody can see.
How a self-trade happens, and how each one is labeled
Synthetic data. Illustrative orders, prices, sizes and shares, generated to show the effect; months A, B and C stand for three delivery months of one commodity. The mechanism and the labeling rules are as built; the desk’s own orders and figures are confidential.
Text description of this figure
Three panels and a strip. Panel one shows an order the desk rests at the exchange: buy a calendar spread, months A and B, 8 lots at a price gap of minus 42, which means buy month A and sell month B. The exchange derives from it a sell order in month B priced at month A’s price plus 42, here 8,170 plus 42, which is 8,212. The desk’s ordinary bids and offers in month B are managed separately from the spread order, so the quoting side cannot see the spread’s derived leg. Panel two is the month B order book; the derived sell is drawn with a dashed outline because no screen displays it. In the first case the desk’s own quoting engine, which cannot see that order, bids 8,212 for 2 lots and the two match: buyer and seller are both the desk, one trade ID, a self-trade. In the second case the desk’s bid is already resting at 8,212 while the hidden sell is at 8,218; 6 seconds later month A falls from 8,176 to 8,170, the hidden sell slides to 8,212 and matches the resting bid although nobody sent an order. In the third case two spread orders in the same direction, A and B, and B and C, share the middle month; the exchange derives a hidden sell and a hidden buy in month B and matches them at 8,200 for 3 lots. Panel three is the tool’s label, with each mechanism’s share of a generated sample of 250 pairs: M1 instant, 13 percent; M1 drift, 49 percent; M2 shared leg, 38 percent; anomaly, 0 percent. A bar chart gives the trigger delay of the sample’s M1 pairs: 21 percent in the same second, 27 percent within 1 to 10 seconds, 32 percent within 11 to 60 seconds, 19 percent within 1 to 10 minutes and 1 percent after more than 10 minutes; median 14 seconds. A pair that fits neither mechanism, such as two ordinary orders from one account, is flagged for a person and never forced into a category. The strip explains why a market maker measures every one: positions formed by self-trades do not count toward the open interest a market maker is evaluated on; they come from how the exchange matches spread orders, so most happen while both orders rest; and a derived order is on no screen, so the reliable control is to measure and trace every pair after each session. All orders, prices and shares in the figure are synthetic.
06Under the hood
For the technical reader: the model, the math and the code.
Under the hoodPairing rule, deduction basis, implied matching, classifier code, golden validation and failure modes for the technical reader
This is a surveillance and attribution system: exact arithmetic over the exchange’s own identifiers, with a verification gate at every stage. No statistical model is used, on purpose, and its most transferable lesson is a data-science one: an inferred label turned out to be off by more than an order of magnitude against ground truth, so inference was replaced by the label.
A machine-learning reader will recognize the practices: ground-truth labels over heuristics, a rule-based classifier with an explicit abstain class, golden-set validation before release, a regression gate in front of an OCR pipeline, and data-quality checks that halt instead of degrading. Stack: Python 3.10 standard library plus openpyxl inside a Flask service, on standard-user Windows, with no pandas and no database; the large daily order file is streamed, never loaded.
Definition: a self-trade is a duplicated trade ID
Within one settlement day (which includes the previous evening’s night session) and one exchange, let be the set of the account’s fill rows carrying exchange trade ID . Both sides of a match that belong to the same account print the same ID twice, so the detector is a group-by, and the properties one might be tempted to match on (contract, quantity, price, time) are demoted to assertions. A group of three or more rows, two rows on the same side, or two rows that do not mirror raises instead of being counted; a file that mixes accounts is refused. The design rule: a surveillance tool should stop before it emits a plausible wrong number.
def pair_fills(fills):
"""One exchange trade id on two of the account's fills,
a buy and a sell, is one self-trade pair. Anything that is
not a clean mirror stops the run."""
pairs = []
for trade_id, rows in group_by(fills, key="trade_id"):
if len(rows) == 1:
continue # an ordinary fill
require(len(rows) == 2) # never three or more
a, b = rows
require({a.side, b.side} == {BUY, SELL})
require(same(a, b, on=["contract", "quantity", "price", "time"]))
pairs.append(Pair(buy=buy_of(a, b), sell=sell_of(a, b)))
return sorted(pairs, key=night_session_first_then_time)The classification lesson: real fields beat clever inference
The first month’s export had no field saying whether a fill came from a spread order or an ordinary one, so the first answer to “did spread orders self-trade with each other?” was an inference: a footprint heuristic over prices, sizes and timing, with thresholds. It looked reasonable and it was badly wrong. A second export format carries the exchange’s fill-type field (ordinary versus combination-derived), and under that definitive label the heuristic had missed most spread-versus-spread self-trades, off by more than an order of magnitude.7
The estimate was withdrawn the same evening and Shuo set the rule that has held since: identical trade ID only, classification from the fill-type field only, no thresholds. Where the field does not exist, the report says “cannot be determined”; it never says zero. The two formats were then reconciled against each other on the days both cover: 88 of 88 day-by-product cells identical.
- Rejected: footprint inference. Plausible, unfalsifiable from the same file, and off by an order of magnitude.
- Rejected: fuzzy matching on price, size and time. Unnecessary once the trade ID is the key, and it would manufacture pairs.
- Chosen: the exchange’s own identifiers and type field, with every other attribute used as a consistency check.
The exchange’s deduction basis
Under the exchange’s market-maker scheme, what is set aside is the positions that self-trades open, on designated contracts only.1 Each pair of quantity is typed from the open and close flags of its two sides, with the number of opening sides. Two figures are reported side by side so that the tool assumes nothing about the exchange’s arithmetic: the position the pair creates on each side, and the literal sum of opened lots, which is the conservative upper bound. The filter is the month’s designated-contract list; each pair uses the list of its own settlement month, and a product missing from the list is counted in full, so the fallback can only overstate.
A cross-check from the sister tool: on the Shanghai exchanges, Position Atlas shows the deduction is exactly per both-open pair, on 2,410 of 2,410 contract-days.5 Dalian has no comparable daily figure to test against, which is why both figures are kept.
def opening_lots(pair):
"""Returns (type, both-open lots, opening-side lots)."""
n_open = count(side.opens_position for side in (pair.buy, pair.sell))
q = pair.quantity
if n_open == 2:
return "both-open", q, 2 * q
if n_open == 1:
return "mixed", 0, q
return "both-close", 0, 0Root cause: derived (implied) matching
A listed calendar spread order, buy A&B at spread , means buy the near month A and sell the far month B at . It rests in a combination queue that the matching system links to the outright queues: when outright prices satisfy the spread, the exchange derives the spread’s legs as implied orders and matches them against ordinary orders by time priority. The implied leg’s price moves with the other leg, and it is not displayed in the outright order book.8
A worked example with illustrative prices: a resting buy of the A&B spread at −42 with month A trading at 8,170 puts an invisible sell in month B at 8,212. The desk’s quotes in month B are managed separately from its spread orders, so the quoting side cannot see the spread’s implied leg. A bid at 8,212, into what looks like an empty level, matches it. One trade ID, both sides the desk.
- M1, own resting spread × own outright. The larger group in the hand-traced study. The outright order is almost always the later arrival, but only a minority of collisions fire in the second it arrives. The rest are drift-triggered: both orders were resting, the other leg’s price moved, and the implied price slid onto the desk’s own quote with neither side acting.
- M2, shared middle leg. Two same-direction spreads on adjacent month pairs hold opposite implied orders in the month they share, and the exchange matches them against each other. Every spread-versus-spread pair in the study fit this pattern.
No pair was left unexplained, and the leg-direction convention (buy A&B = buy A + sell B) held on every spread side.3 The consequence for any fix follows directly from the timing: a check at order entry would miss most of M1, so avoidance has to track the implied price continuously. Shuo’s report proposed four counters for the desk to weigh: a table of the desk’s own implied-leg prices for the quoting side, spreads that share no month (a configuration-only cure for M2), a pre-trade self-match check, and weighing the cost of the residual before investing in any of them.
The table runs the same rule set on a generated sample of 250 pairs, so its shares are illustrative.
| Finding | Value | Basis |
|---|---|---|
| Pairs labeled | 250 of 250 | each label equals the mechanism that generated the pair |
| M1: own spread’s implied leg × own outright | 62% | 13% instant, 49% drift-triggered |
| M2: adjacent spreads, shared middle leg | 38% | all spread × spread pairs |
| Unexplained | 0 | no third pattern |
| M1 trigger delay | 21% same second · 27% 1–10 s · 32% 11–60 s · 20% over 1 min | median 14 s; 79% of M1 drift-triggered |
| Negative controls | 4 of 4 abstain | outright × outright, wrong leg direction, missing order, impossible delay |
| Leg-direction convention | every spread side | buy A&B = buy A + sell B |
The classifier and its golden validation
The daily attribution is a deterministic rule set, deliberately not a learned model: the mechanisms are structural, the evidence is deterministic, and a surveillance feed has to be explainable pair by pair.
- Inputs. The pairs, and the day’s order file streamed once and filtered to the order references behind those pairs.
- M1 if exactly one side’s order is a spread order whose derived direction on the traded contract matches the convention. Delay is trade time minus the outright order’s time, wrapped across midnight, with a legitimate maximum of one trading day’s span (the previous night’s open to the next day’s close); beyond that the pair is an anomaly.
- M2 if both sides are spread orders whose derived legs on the shared contract are a buy and a sell.
- Anomaly otherwise: a missing order reference, a direction mismatch, outright × outright, an impossible delay. Flagged for a person, never force-fitted. The class has fired in production, which is its purpose: an unexpected pattern reaches a person instead of being absorbed into M1.
Golden validation. Before release the automation was run on the days of the manual investigation and had to reproduce it to the number: the M1 and M2 counts on each day, zero anomalies, every delay bucket and the longest delay. Thirteen contract tests pin the classifier.
Cross-source agreement in production. The classifier labels from order records; the composition report labels from the exchange’s fill-type field. On days cross-checked in production, the M1 count equals the spread-versus-outright count and the M2 count equals the spread-versus-spread count, with zero anomalies: two independent sources, one answer.
The completeness rule. An early version could read a half-copied order file and label every pair an anomaly. The fix is a precondition, not a patch: every order reference must resolve and the file must be closed and stable, otherwise the run defers and retries every 20 seconds from a restart-safe queue.
def classify(pair, orders):
"""Returns (label, trigger delay in seconds)."""
buy = orders.get(pair.buy_order)
sell = orders.get(pair.sell_order)
if buy is None or sell is None:
return ANOMALY, None # an order reference did not resolve
if buy.is_spread and sell.is_spread:
# two spreads: their derived legs in the traded month must be a buy and a sell
if derived_side(buy, pair.contract) == BUY and derived_side(sell, pair.contract) == SELL:
return M2, None
return ANOMALY, None
if buy.is_spread or sell.is_spread:
spread, outright = (buy, sell) if buy.is_spread else (sell, buy)
expected = BUY if buy.is_spread else SELL
if derived_side(spread, pair.contract) != expected:
return ANOMALY, None # leg direction fails the convention
delay = seconds_between(outright.time, pair.time) # wraps past midnight
if delay > ONE_TRADING_DAY:
return ANOMALY, None # an impossible delay
return M1, delay
return ANOMALY, None # outright x outrightA deduction-impact metric: when a self-trade happens matters
A market maker’s open interest is assessed as a daily average over the month. If lots formed by self-trades on trading day are struck out from that day on, they are missing on of the month’s days. A self-trade on the first day costs its full size; one on the last day costs of it. Shuo designed the metric and corrected its first draft himself: must be the full month’s trading days even while the month is still running, because this is persistence, not a re-weighting of elapsed days.
It changes the answer. Ranking products by weighted impact and by raw count gives different orders, because one product’s self-trades can cluster late in the month under low weights.9
Sessions that partition the day
Each fill gets one session key from its timestamp: night (from 20:00), morning one (through 10:28, including the opening auction), morning two (before 13:00), afternoon. The keys partition the settlement day and both sides of a pair share one timestamp, so every pair belongs to exactly one session and the full day is the exact sum of its sessions. That identity was verified in production across all 16 metrics and every contract and field.
The deliverable is the latest session present in the uploaded file, sliced to its own trades, so a cumulative file and a session-only file produce the same images. The trading day is read from inside the file, never from its name or the clock, so a night export uploaded at 23:00, at 03:00 or on a Saturday is dated correctly; that was Shuo’s design. Ledger guards keep it honest: a later session blocks an earlier one’s re-delivery, a cumulative count may never regress, and a partial file never overwrites a full day.
Reading a scanned notice without trusting the OCR
The designated-contract list arrives monthly as scanned pages with an invisible OCR text layer. The decoder is built around a regression gate: it first decodes a month whose answer is already known and must reproduce it for all 10 products, character for character, or exit. Only then does it read the new month, page by page, correcting OCR confusions solely through an explicit table and aborting on anything the table does not explain. It writes every page as an image for a check by eye, and appending the result to the list stays a deliberate manual step. The program never edits the list.
| Printed | OCR read | What happened |
|---|---|---|
| l | 1 | every month; handled by the table |
| lh | Ih | three months running; handled by the table |
| b | 6 | first month; handled by the table |
| i (as a prefix) | 1 | the earlier rule would have silently dropped three contracts; the decoder was rebuilt around the explicit table |
| lh | Th | a new misread; the decoder aborted as designed |
Design choices a reviewer will question
- Why key on the trade ID alone, not ID plus contract? Both give identical pairs on the data tested. The simpler key is used and the stronger statement is enforced as an assertion.
- Why are exchange position offsets excluded? They also print one trade ID on a buy row and a sell row, but they are an end-of-day position offset, not an intraday match. They are listed on their own sheet and never counted.
- Why a report after every session instead of once a day? The basis accumulates per contract over the month. A session-level report shows a heavy session while there is still trading time left to adjust.
- Why can’t the quoting engine simply avoid its own spread orders? It cannot see them. The spread orders and the quotes are managed separately, the implied leg is not displayed, and its price moves with the other month, so most collisions happen with no new order to check.
- Why no pandas and no database? The desk machines run a bundled Python runtime with neither. A large daily order file is read in one streaming pass that keeps only the orders behind that day’s pairs.
Failure modes engineered out
| Failure | How it would have looked | Guard |
|---|---|---|
| Parse drift | a slightly wrong count | row and lot totals checked against the export’s own trailer, to the row |
| Workbook formula or cell error | a wrong cell nobody recomputes | the saved file is re-opened and every cell and sum re-derived from the raw files (506 cells on the first month); a tampered workbook must fail its test |
| Product codes folded together | one product absorbing another’s contracts | caught before release by a cell-count mismatch; codes are parsed, not prefix-matched |
| Half-copied order file | every pair labeled an anomaly | completeness rule: all references resolve, file closed and stable, else defer |
| Renderer error page saved as an image | an error screenshot posted as a report | isolated browser profile per render, retries with rising timeouts, and a pixel check for the table header |
| Missing month in the contract list | figures too high, silently | red strip on images and workbook, page banner, recompute list, daily reminder card |
| Wrong chat, or a double post | a surveillance image in the wrong room | chat title verified before each send; an unconfirmed send is reported, never retried; rehearsals go to Shuo’s own chat only |
| Duplicate or regressing uploads | an earlier session overwriting a later one | stage-aware ledger guards; atomic rename so the sender never sees a half-written image |
Verification record
| Check | Result |
|---|---|
| Export trailer versus parsed rows and lots, first month | identical |
| Independent recount of one day in a second language (PowerShell) | identical |
| Two export formats on the days both cover | 88 of 88 day × product cells |
| Integrated app versus the standalone command-line tool | cell-identical |
| Full day versus the sum of its four sessions | every metric, contract and field |
| Automated attribution versus the manual investigation | identical on every day of the study |
| Rebuilt monthly ledger versus an independent recomputation | every day of the month |
| Three-way recompute: fresh code, original tool, live ledger | identical, twice |
| Designated list versus the exchange-fed reference table | all 10 products |
| Posted images re-scanned after the renderer fix | 60 of 60 genuine |
Built with
- Python 3.10 (standard library)
- openpyxl
- Flask service
- Streaming CSV parsing (large files, GB18030)
- Trade surveillance and compliance reporting
- Root-cause analysis
- Rule-based classifier with an abstain class
- Data-quality gates (checksums, mirror assertions)
- Market microstructure: implied matching
- Headless Edge rendering with pixel verification
- Win32 chat automation
- OCR-layer PDF decoding
- Golden-set validation and regression tests
- PowerShell
- Windows, no admin rights
07Releases
Shipped in versions, like a product.
- First countA whole month of trade records counted and verified 38 minutes after he started; the footprint estimate withdrawn the same evening in favor of the exchange’s fill-type field.
- Spread Calculator 1.11Self-Trade Check becomes the second main page of Spread Calculator: daily workbooks, month-to-date ledger, both order references as evidence.
- 1.13 to 1.16The exchange’s deduction basis: opening lots on designated contracts, the list taken from the exchange’s notices. First fully unattended day.
- 1.17 to 1.22Reports for four sessions plus the full day, three images each, posted to the desk’s chat automatically; each session guaranteed to contain only its own trades.
- Root-cause investigationEvery self-trade of a hand-traced sample attributed to two mechanisms of derived matching; timing study; counters proposed.
- 1.23Mechanism attribution automated and golden-validated against the manual study; attribution and trigger-delay images after every close. Weighted deduction-impact metric.
- 1.24 to 1.28Stage-aware duplicate guard, the completeness rule for the order file, render retries, merged morning report, isolated render profile with a pixel check.
- 1.29A month missing from the designated-contract list is loud everywhere: red strip, banner, recompute list.
- 1.30Daily reminder card to the maintainer while the list needs work.
- 1The treatment of positions formed by self-trades follows the exchange’s market-maker scheme. The tool reports two figures side by side, the position created and a conservative upper bound, so that it assumes nothing about the exchange’s own arithmetic.
- 2A full month of the desk’s trade records, validated against the export’s own row and lot totals; the first report was delivered 38 minutes after he started. Counts are confidential.
- 3Every self-trade pair of a multi-day sample, each joined by hand on both sides to its originating order; the daily automation reproduces that manual analysis. Counts are confidential. That the exchange’s derived orders are not displayed in the outright order book is an inference supported by several public sources, not a rule text.
- 4A full-day image set exists for every trading day since the first unattended day. Night and morning reports depend on colleagues uploading those session files.
- 5Position Atlas, Shanghai Futures Exchange and Shanghai International Energy Exchange contracts, compared with the exchanges’ own effective open-interest figures. For the Dalian exchange the basis is presumed, not confirmed.
- 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.
- 7Comparison of the withdrawn footprint estimate with the count under the exchange’s fill-type field on the days where that field exists. Counts are confidential.
- 8Derived matching per the exchange’s trading rules on spread orders and its public explanations; that implied legs are not shown in the outright order book is an inference supported by several public sources, not a rule text.
- 9The metric assumes the deducted position persists to month end and that the deduction runs from the day of the self-trade; neither has been checked against an actual exchange deduction. Values are confidential.