DCE Level-2 Receiver

Software · Market-data infrastructure

DCE Level‑2 Receiver 大商所L2接收

None of the data routes open to his tools carried the Dalian exchange’s live order book, so one trader found the feed and built the receiver. On Windows trading servers with no compiler, it decoded every packet on its first live run, then proved the trading engine’s own log already carried every snapshot: 16,575 of 16,575.

  • Conceived and built by Shuo Huang, on his own initiative
  • From IT’s Linux C++ demo to live feed in 17 hours
  • Live since Sep 2026
  • 0 undecoded packets across ≈2,200 instruments
  • 16,575 / 16,575 snapshots verified
  • No compiler, nothing installed: one signed portable runtime
  • 266 lines of Python, 0 third-party packages

01System architecture

One multicast stream in, one verified order book out.

The trading servers are standard-user Windows machines with no compiler. So the receiver is pure Python on an official signed portable runtime, with nothing installed, built to prove itself on the first packet.

Exchange

Dalian Commodity Exchange

Publishes the best five bids and asks of every contract, four times a second.

Network

Level-2 multicast feed

Exchange data delivered as UDP multicast: one broadcast, any number of subscribed listeners, like a radio station.

Windows trading server

DCE Level-2 Receiver

Joins the stream, sorts packets by byte length, decodes, records. An unknown length raises a flag instead of vanishing.

Same server

CHRONOS

Shuo’s machine-learning system. Sizes live-hog quotes from the state of the book.

Same server

Trading engine

The desk’s engine receives the same market data independently and logs every snapshot of the contracts it trades.

The proof

Equivalence check

Joins both records on the exchange timestamp: 16,575 of 16,575 identical, the engine’s copy under a millisecond behind.

Simplified data flow. The feed carries several message families; the five-level snapshot is the one drawn here.

Why Python, on an exchange feed?

IT’s reference receiver is Linux C++. The trading servers are standard-user Windows machines with no compiler, and an official signed portable Python runtime runs on them with nothing installed. The whole feed peaks near 1,900 packets a second, and the receiver is not on the order path. Live data settled it: decoding every packet of the feed, the receiver missed none of the 16,575 live-hog snapshots the engine logged.1

How does it know a packet’s type?

The two snapshot layouts carry no type field at all. Each of the five layouts has its own fixed length, so the length is the type. A length that matches none is counted and hex-dumped, never silently dropped.

Why keep both sources?

The engine logs the book continuously only for the contracts it trades. The multicast path stays selectable for any other contract, with a compare mode that shows the arrival-time difference live.

02The story

No live route, one feed, and proof the engine already had it.

CHRONOS, the machine-learning system Shuo built to size the desk’s live-hog quotes, needed to see the live order book: the best five buy and sell prices with the quantity waiting at each. None of the data routes available to his tools carried it live. On his own initiative he went to IT, took their Linux demo, and built a Windows receiver that runs on the trading servers with nothing installed. Seventeen hours after the demo reached him, it read every packet of the live feed correctly on its first live run; six days later it supplied the proof that let the trading server carry one copy of the market data instead of two.

  1. 01

    The problem

    Shuo makes markets in Dalian futures, live hog among them: continuously posting prices at which others can buy and sell. Deciding how much to post takes knowing how much is already waiting in the market. That is the five-level order book, the best five buy and sell prices with the quantity resting at each, refreshed by the exchange four times a second. The industry calls it Level 2; Level 1 is only the single best price on each side. None of the data routes available to his tools delivered live Level 2 for Dalian contracts: the monitor he had built earlier recorded Level 1 only, and the desk database is filled after the close, not live.

    The servers that do receive the feed are standard-user Windows machines with no compiler, where nothing gets installed.

  2. 02

    What Shuo built

    The option on the table was to wait. Shuo went to IT instead. They confirmed that the desk receives the full five-level feed as a multicast stream, a broadcast that a subscribed machine tunes in to, like a radio station, and gave him a small Linux C++ demo of how to listen to it. He built the Windows version in pure Python, with nothing to install, on an official signed portable runtime.

    The feed is raw binary. Think of sorting unlabeled envelopes by size: each kind of message has its own fixed length, and the length is the one clue every message carries. The receiver sorts every packet that way, unpacks the right one into a clean order book, records it, and raises a flag on any envelope of a size it has never seen. With no compiler to confirm the layouts and no access to the live feed beforehand, he gave it a self-test that fabricates packets and runs the whole receiver against them, so the first live run would be a confirmation, not an experiment.2

  3. 03

    What changed

    The next morning, 17 hours after IT’s demo reached Shuo,3 the receiver ran on a trading server. The first packet arrived in 0.2 seconds and every packet decoded: up to 1,900 a second, across about 2,200 instruments, with zero unknown.4 Within the hour CHRONOS issued its first live size recommendations from that feed.

    Six days later he asked a sharper question. On a high-frequency trading server even the smallest added delay matters, and the trading engine already receives this data: does its own log contain every snapshot? The receiver’s recording answered it. 16,575 of 16,575 snapshots were identical, the engine’s copy written a fraction of a millisecond later.1 CHRONOS switched to the engine’s log, and the trading server went from carrying two copies of the market data to one. The decoder lives on inside CHRONOS, where it later powered a one-click report of the account’s share of each contract.

0

packets it could not decode, across every logged live run5

16,575of 16,575

order-book snapshots identical in the receiver’s record and the trading engine’s log1

17h

from IT’s reference code to the first live packet on a trading server3

1,900/s

peak packet rate on the first live morning, every packet decoded4

≈2,200

exchange instruments decoded live: futures, spreads and options4

<1ms

median lag of the trading engine’s log behind the direct feed: close enough to drop the second copy6

03Evidence

Not one snapshot missing on either side

In September 2026 the receiver’s recording and the trading engine’s own log, taken on the same trading day, were joined snapshot by snapshot on the exchange’s timestamp. Had the log dropped anything, or the receiver missed a packet, the counts would differ and some snapshots would match nothing.

Order-book snapshots compared, one trading day

Every snapshot the receiver recorded was in the engine’s log too, with identical best prices and volume: 16,575 of 16,575 for lh2611 and 9,132 of 9,132 for lh2703.

Show the dataHide the data
Data: Order-book snapshots compared, one trading day
Live-hog contractReceiver’s recordEngine’s logMatched, identical
lh2611 (Nov 2026)16,57516,57516,575
lh2703 (Mar 2027)9,1329,1329,132
A validation count of the receiver itself: one trading server, one day’s comparison window. Matched means the same exchange timestamp to the millisecond on both sides; identical means equal best bid, best ask and cumulative volume. No minute held unequal counts, and no snapshot appeared on one side only.1

04Functions

Everything it does, from the first packet to the proof.

A

Join

Subscribes to the exchange feed the way Windows requires, not the way the Linux original does it.

  • Windows rejects the demo’s bind-to-group call; the receiver tries the Windows forms first, keeps the demo’s form as a last resort and prints which one bound
  • Same socket options and arguments as IT’s demo, so IT can support it
  • Network card optional: on the default card it prints the machine’s own addresses, so the right one can be pinned if nothing arrives

B

Decode

Identifies each binary packet by its byte length and turns it into named fields.

  • Five fixed-length layouts, rebuilt from the C header’s packing rules without a compiler7
  • The header stores the ten price levels interleaved, not as five bids and then five asks; the decoder names each by meaning, so no consumer ever reads the wrong level
  • Every layout’s size and field count are asserted the moment the program loads, so a format of the wrong size stops it before it can misread a price

Bytes per packet, for five message types

No two message types share a length, so the length alone tells the receiver which of the five it is holding.

Data: Bytes per packet, for five message types
Message typeBytes per packet
Level-2 snapshot316
Volume by price148
Ten best orders140
Level-1 snapshot76
Order statistics60
Synthetic data. Illustrative record layouts, written for this page to show the method. The technique is as built; the feed’s own message formats are not published. In the receiver, each size is derived from the C header’s packing rules and asserted the moment the program loads.7
Synthetic five-level order-book snapshot for live hog, drawn twice. Left: ten price-and-size slots in the record’s interleaved order, starting bid 1, ask 1, ask 2, bid 2. Right: the decoded ladder, five asks from 14,215 to 14,235 above five bids from 14,210 down to 14,190, each with a bar for the lots resting, and a summary strip with mid price 14,212.5 and spread 5. Enlarge
Synthetic data. A generated five-level snapshot on the live-hog tick grid, at a fictitious price level, packed into an illustrative record and decoded back. Left, the ten price-and-size slots as they sit in the packet; right, the book once every level is named by meaning: the five best offers above the five best bids, each with its price and resting lots. Read the slots in their natural order and the ladder comes out scrambled; the decoder never lets a consumer do that.8
  1. Marker 1: Exchange timestamp: every snapshot carries the exchange’s own time to the millisecond, the key the equivalence test later joins on.
  2. Marker 2: As packed: the ten slots in the record’s interleaved order. Position says nothing reliable about which level a slot holds.
  3. Marker 3: Five ask levels, fifth best down to the best offer: the prices at which sellers are waiting.
  4. Marker 4: Lots resting at each price; the bar length is the depth.
  5. Marker 5: Book summary CHRONOS derives: mid price, spread, best-level imbalance and total five-level depth on each side.
  6. Marker 6: Five bid levels, best bid down to the fifth: the prices at which buyers are waiting.

C

Never drop silently

A packet of an unexpected length is the first sign that the live feed differs from the documentation, so it is counted and shown.

  • Unknown lengths are tallied by size and the first 32 bytes are hex-dumped once
  • Live counters by packet type every five seconds
  • Result on every logged live run: zero unknown5

D

Record

Every decoded snapshot can be written to a daily file per packet type.

  • Header written once per day; arrival time stamped to the millisecond
  • Filter to one packet type, or run quiet with counters only
  • This recording is what later proved the engine’s log complete1

E

Feed a live machine-learning model

Every decoded snapshot updates CHRONOS’s picture of the book, and at the start of each minute that picture supplies six of the nine inputs of the model that sizes the desk’s quotes.

  • The six: spread, total five-level depth, best-level imbalance, 30-second volume, 30-second volatility and 30-second price change
  • First live size recommendations within the hour of the first packet4
  • One machine receives and computes; traders’ PCs run a read-only reader, so no trader machine carries the feed

F

Prove it before the market opens

A self-test that needs no feed: it fabricates one packet of every type, plus a junk packet, and sends them through the real receiver on loopback.

  • Checks all five sizes, that every packet decodes as its own layout, and that known values survive the round trip, down to the fifth price level on each side
  • Confirms the junk packet is flagged and five files are written
  • Passed on the development PC and again from the deployed copy

G

One double-click

Starts receiving without a single typed command.

  • A launcher finds the runtime, reads one settings file and starts receiving
  • Stops cleanly and prints final totals
  • Runs on the signed portable Python beside it: nothing to install

H

Validate the simpler source

Shuo’s idea: read the order book from the trading engine’s own log and stop receiving it twice. The recording made that a measurement instead of a hope.

  • Snapshots joined one to one on the exchange timestamp: 16,575 of 16,575, none missing on either side, equal counts in every minute1
  • Identical best bid, best ask and volume; the engine’s line under a millisecond behind the packet6
  • CHRONOS made the engine log its default feed and kept multicast as a switchable option with a live compare mode

I

Measure the account’s footprint

A one-click report that divides the account’s positions, fills and resting orders, taken from the engine log, by the market’s open interest, volume and visible depth from the feed.

  • Share of open interest, of traded volume and of the visible book, per contract
  • Works in the night session too
  • States its own limits in the report: exchange data is an anonymous market-wide aggregate, so the account side comes from the trading engine’s own records

05Under the hood

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

Under the hoodPacking arithmetic, length dispatch, decoder pseudo-code, throughput budget, test design and the equivalence test

The engineering problem is narrow and unforgiving: decode a binary exchange feed on a machine with no compiler, working from a C header and a Linux demo, with no chance to test against live data before the first live run on a remote server. A single wrong padding byte would shift every later field and misread every price without raising an error. The design answer is a program that checks itself at load time and reports on the first packet whether its assumptions hold. The feed’s own message formats are not reproduced here: the layouts below are illustrative records, and the technique is shown on them exactly as it was applied.

Why port instead of compile

IT’s reference is a Linux-only UDP receiver: socket, 2 MB receive buffer, reuse-address, bind, join the group, blocking receive, dispatch by packet length. Three options were on the table.

  • Compile the C++ for Windows. Rejected: no toolchain on the development PC or the servers, POSIX socket headers to replace, and a new binary to qualify for the trading servers.
  • Wait for another data route. Rejected: none of the available routes delivered live Dalian Level 2.
  • Re-implement in standard-library Python (socket, struct, csv) on an official signed portable runtime. Chosen. 266 lines for the receiver, 101 for the self-test, no third-party package.

The port mirrors the demo call for call (same positional arguments, socket options and print format) so IT can reason about it. One call could not be mirrored: Linux binds the socket to the group address, which Windows rejects with WSAEADDRNOTAVAIL. On Windows the socket binds to the port on any or a chosen interface and then joins the group with IP_ADD_MEMBERSHIP on that interface. The receiver tries the forms in order and prints the one that bound.

Is Python fast enough for an exchange feed? Every instrument on the feed together peaked near 1,900 packets a second in the logged runs, and each packet costs one dictionary lookup, one struct.unpack and one dictionary of named fields. At a few hundred bytes a packet that is well under a megabyte a second, so the demo’s 2 MiB socket buffer would hold several seconds of peak traffic if the thread ever stalled. Live data settled the question: decoding every packet of the feed, the receiver missed none of the 16,575 live-hog snapshots the engine logged.1 And it is not on the order path: its consumer sets quote size once per sizing window, minutes apart.

Tstall=Br×L
The stall budget: how long a receive buffer of B bytes holds the feed if the decoding thread stops, at r packets a second of L bytes each. With the 2 MiB buffer, the peak rate of about 1,900 packets a second and packets of a few hundred bytes, T is several seconds. Payload only; per-datagram bookkeeping inside the kernel buffer is ignored.

Five layouts from packing rules

Without a compiler there is no sizeof to consult, so each size is derived by hand from the header’s #pragma pack directives and then asserted against struct.calcsize at import. The two snapshot records are pack(1): fields abut with no padding. The three order-flow records are pack(4): a one-byte type field is followed by three padding bytes, and the record is padded at the tail to a multiple of four. That is where a hand derivation goes wrong. In the illustrative ten-best-orders record below, the fields add up to 134 bytes, 137 once the type field is padded, and the true 140 only with the tail padding as well. Miss either rule and the size is off by three bytes, the record matches no packet, and every packet of that type lands in the unknown-length count.

1⏟type+3⏟pad+4⏟length+24⏟contract+8⏟best bid+40⏟10 sizes+8⏟best ask+40⏟10 sizes+9⏟time+3⏟tail pad=140
An illustrative ten-best-orders record under pack(4): three padding bytes after the type field and three at the tail bring 134 bytes of data to 140. Field widths are written for this page.
Synthetic data. Byte lengths and padding belong to the illustrative records; the feed’s own formats are not published. The message families are those of the exchange’s public Level-2 service. In the receiver, the five-level snapshot layout is the one confirmed on live data; the other four round-trip in the self-test.
PacketContentBytes (illustrative)PackingPadding bytesReceiver proven on
Level-1 snapshotLast price, volume, open interest, best bid and ask; 4 per second76pack(1)0Self-test
Level-2 snapshotDay statistics plus five bids and five asks with sizes; 4 per second316pack(1)0Live feed, 0 unknown
Ten best ordersThe ten orders queued first at the best bid and at the best ask140pack(4)3 + 3Self-test
Order statisticsTotal resting buy and sell quantity, weighted-average prices60pack(4)3Self-test
Volume by priceTraded volume at five prices, split buy-open, buy-close, sell-open, sell-close148pack(4)3Self-test

The decoder

Take an illustrative five-level record of 316 bytes: a 36-byte key (contract, exchange time, millisecond), 10 doubles of day statistics, 40 bytes of last price, volume, turnover, open interest and a sequence number, then ten price-and-size pairs of 16 bytes each: 36 + 80 + 40 + 160 = 316.

The trap is in the last 160 bytes. A C header is free to store the levels in any order, and the one Shuo worked from did not store them as bid 1 to 5 then ask 1 to 5: it interleaves them. The illustrative record does the same, as b1 a1 a2 b2 b3 a3 a4 b4 b5 a5. A decoder that assumes either natural order produces a plausible-looking but scrambled book. The field list follows the header’s order one for one and names every value, so consumers address bid3 by name and never by position; the self-test checks that the fifth level on each side survives a round trip.

Why dispatch on length and not on a type byte? The two snapshot records have none: they begin at the contract code. Length is the only discriminator common to all five layouts, and it is how IT’s reference dispatches. Dispatch is a dictionary keyed by packet length, built from struct.calcsize so the table cannot disagree with the formats. A length with no entry returns an explicit unknown; the receive loop tallies it by size and hex-dumps its first 32 bytes once.

Where the 316 bytes of an illustrative five-level record go

About half of the record, 160 of 316 bytes, is the book itself: ten price-and-size pairs, stored in an interleaved order.

Data: Where the 316 bytes of an illustrative five-level record go
Part of the recordBytes, of 316
Five-level book (10 pairs)160
Day statistics (10 values)80
Last price and totals40
Key: contract and time36
Synthetic data. Illustrative record layouts, written for this page to show the method. The technique is as built; the feed’s own message formats are not published. Little-endian, pack(1): no padding anywhere in this record.
Pseudo-code
# one name per field, in the record's own order
DEPTH_FIELDS = KEY + DAY_STATISTICS + TOTALS + [
    # the record interleaves the levels: name them in THAT order (each price is followed by its size)
    "bid1", "ask1", "ask2", "bid2", "bid3", "ask3", "ask4", "bid4", "bid5", "ask5",
]

LAYOUTS = [BEST, DEPTH, TEN_ORDERS, STATISTICS, BY_PRICE]      # each: name, binary format, field names
BY_LENGTH = {byte_size(l.format): l for l in LAYOUTS}          # sizes computed from the formats, never typed

# checked once, when the program loads
for l in LAYOUTS:
    assert byte_size(l.format) == HAND_DERIVED_SIZE[l.name]    # from the header's packing rules
    assert len(l.fields) == field_count(l.format)
assert len(BY_LENGTH) == len(LAYOUTS)                          # lengths are pairwise distinct


def decode(packet):
    layout = BY_LENGTH.get(len(packet))
    if layout is None:
        return UNKNOWN            # the caller tallies it by length and hex-dumps its first bytes once
    values = unpack(layout.format, packet)
    return layout.name, {name: clean(value) for name, value in zip(layout.fields, values)}
Pseudo-code. The length-keyed dispatch table with its load-time assertions, and the decoder, on the illustrative records. The level order shown is the illustrative one.

What a snapshot carries, and what the model takes from it

Confirmed on live data:

  • Contract and exchange time to the millisecond, on the exchange’s 250 ms cadence.
  • Open, high, low; close and settlement, which hold the maximum-double sentinel until the exchange publishes them, so a consumer must treat them as missing during the session.
  • Limit-up and limit-down prices.
  • A feed-wide sequence counter, usable as a gap detector.
  • Last price, cumulative volume (single-sided, restarting at the night-session open), turnover and open interest.
  • Five bid and five ask prices with sizes. The sizes are the whole market’s, a firm’s own resting orders included.

CHRONOS turns this into six of the nine inputs of its self-retraining machine-learning model, taken at the start of each minute: spread, log of total five-level depth, best-level imbalance, 30-second volume, 30-second volatility and 30-second mid change. The model was chosen in a walk-forward tournament of about 20 models, including gradient-boosted decision trees, ridge and ensembles; the top models tied on out-of-sample money, so the simplest of them shipped, and it re-fits itself every trading day. The model is on the CHRONOS page.

The equivalence test

Six days after going live Shuo proposed that the sizing system stop receiving its own copy of the feed: the trading engine on the same server already receives this data, so if its log holds every snapshot, the sizing system can read the book from the log and the server carries one data set. That is a claim to measure, not to assume, and only an independent record of the same feed can measure it: the receiver’s recording.

The test uses the engine’s full-depth log record, the one that carries its contract, exchange time and millisecond, because only a record keyed like the feed can stand in for it.

Both records came from the same server on the same day, so one clock stamps both, and the engine receives its data independently of the receiver, so the two copies are separate observations of the same feed. Each engine log line and each recorded packet is keyed by the exchange’s own timestamp, duplicates are counted and dropped, and the two key sets are compared inside their overlap window. The test reports the count on each side, keys present on one side only, field equality on best bid, best ask and cumulative volume, per-minute counts, and the distribution of the arrival gap. UDP has no retransmission, so this doubles as a loss check: a packet lost on either path would surface as a one-sided key. There were none. It is an independent check on the decoder too: best bid, best ask and volume, unpacked from raw bytes, equalled the engine’s own values every time.

|E|=|M|=|E∩M|=16,575,E△M=∅Δk=tkengine line−tkmulticast arrival,k=(exchange time,millisecond)∈E∩M
E and M are the sets of snapshot keys in the engine log and in the multicast recording within the overlap window. First line, completeness: equal counts and an empty symmetric difference. Second line, the arrival gap for snapshot k: when the engine wrote its log line minus when the multicast packet reached the receiver, both on the same machine’s clock.
Pseudo-code
# engine_log, recording: exchange timestamp -> (local time seen, best bid, best ask, volume)
both      = keys(engine_log) & keys(recording)
window    = span(both)                                         # compare only where the two records overlap
only_log  = [k for k in keys(engine_log) - keys(recording) if k in window]
only_feed = [k for k in keys(recording) - keys(engine_log) if k in window]
identical = count(k for k in both if engine_log[k].fields == recording[k].fields)
gap_ms    = sorted(engine_log[k].seen - recording[k].seen for k in both)

report(len(both), only_log, only_feed, identical, per_minute_counts(both), median(gap_ms))
Pseudo-code. The equivalence test, simplified: join on the exchange timestamp, list one-sided keys inside the overlap, compare the fields, and measure the arrival gap. A positive gap means the engine’s line is the later one.
A validation of the receiver itself: one trading day in September 2026, one trading server; lh2611 and lh2703 are the November 2026 and March 2027 live-hog contracts. The gap is lh2611’s. Scope: two contracts, one day, three compared fields. The tool re-runs on any day’s files.
Measurelh2611 (Nov 2026)lh2703 (Mar 2027)
Snapshots in the engine log16,5759,132
Snapshots in the multicast record16,5759,132
Matched one to one16,5759,132
Missing on either side00
Identical best bid, best ask, volume16,575 of 16,5759,132 of 9,132
Minutes with unequal counts00
Arrival gap, medianunder 1 ms—

The decision, and its limits

Reading from the log costs the sub-millisecond gap plus a 50 ms poll of the log file. CHRONOS sets quote size once per sizing window, minutes apart, so that delay is immaterial. What matters is that the sizing system and the engine see the same book, and that a latency-sensitive trading server does one less job. The engine log became the default source, engineered so the model cannot tell which source is active:

  • Same record, same file. Log lines are converted into the decoder’s own Level-2 record, same keys in the same order, so downstream code sees the same record and the recorded files carry byte-identical headers whichever source is active. An automated test asserts the header equality.
  • Restart-safe. After a restart the reader re-reads the day’s log but delivers only live snapshots to the model; stale ones are counted, not replayed. The recording is deduplicated on contract, exchange time and millisecond.
  • Still comparable. A compare mode runs both sources, pairs the same exchange snapshot from each and shows the arrival difference live.

The limit is coverage: the engine logs the book continuously only for the contracts it trades. For anything else the multicast path is the source, and it remains a setting.

Testing without the feed

The live feed was reachable only from a remote trading server, so the 101-line self-test had to stand in for it. It runs the production receive loop, not a copy of it, and exits non-zero on the first failed assertion. It passed on the development PC and again from the deployed copy before the first live run.

The self-test’s five assertions. Fabricated values only; no market data is needed or used.
TestWhat it asserts
Size per layoutOne fabricated packet per layout has precisely the byte length the C++ sizeof must give for that layout
Decode round tripEach packet decodes as its own layout; checked values come back unchanged, including contract, time and millisecond, levels 1 and 5 of the interleaved block, the sequence counter and volume, and the last field of each order-flow record
Negative decodeA 100-byte buffer of zeros returns an explicit unknown instead of a record
Loopback integrationThe real receive loop, started without a group join, gets six datagrams: one per layout plus a 77-byte junk packet. Every counter must read 1 and the unknown tally must be exactly {77: 1}
Recorder, end to endFive daily files exist; the Level-2 file’s header starts with arrival time, contract, time, millisecond, and the fifth ask size in the row is the value that was sent

Failure modes engineered out

What could go wrongWhat prevents it
A wrong padding assumption shifts every field and misreads prices silentlySizes derived from the packing rules and asserted against struct.calcsize at import; a layout of the wrong size never matches a live packet, so it surfaces in the unknown-length count instead of misreading. The live five-level record has no padding at all, and its decoded best bid, best ask and volume equalled the engine’s own on every matched snapshot
Two layouts with the same length would be indistinguishableImport-time assertion that the five sizes are pairwise distinct
The live build differs from the documented headerUnknown lengths counted by size and hex-dumped; zero on every logged live run
A packet lost in transit, which UDP never reportsDetected, not assumed: pairing each snapshot with the engine’s independently received copy on the exchange timestamp found zero one-sided keys (two contracts, one trading day); the check re-runs on any day’s files
Price levels read in the wrong orderField list follows the header’s interleaved order; round trip of the fifth level in the self-test
The Linux bind call fails on WindowsOrdered bind fallbacks; the one that worked is printed
Joined on the wrong network card: silence that looks like a quiet marketOptional timeout warning, and the machine’s interfaces printed as a hint
Contract names in a non-UTF-8 code pageFixed-width byte fields cut at the first NUL and decoded GBK-tolerantly
No way to test on the real feed firstLoopback self-test through the real receive loop, run again from the deployed copy
A restart replays the morning’s book into the modelThe log source delivers only live snapshots; stale ones are counted and skipped
A restart writes the same snapshot twiceRecording deduplicated on contract, exchange time and millisecond

Live results

The receiver’s own counters, September 2026: packets and instruments of the exchange’s market-wide feed, as logged by the sizing console and its diagnostic tools, all running the receiver’s socket and decoder. No figure here is the desk’s trading.
RunResult
Self-test, development PC and deployed copyPassed: five layouts, loopback receive, junk-packet flag, five files
First live run, trading serverFirst packet in 0.2 s; ≈1,000 to 1,600 packets/s; every exchange instrument on the feed; 0 unknown
Second run, same morning1,300 to 1,900 packets/s; ≈2,200 instruments; 0 unknown; first live size recommendations
Engine log against multicast16,575 of 16,575 and 9,132 of 9,132 identical; engine’s copy under 1 ms behind
Night session, 60 s windows64,002 and 66,821 packets; 2,401 and 2,314 contracts; all Level-2; 0 unknown

Built with

  • Python (standard library only)
  • Market-data feed handler
  • UDP multicast · IGMP
  • Windows sockets
  • Binary protocol decoding
  • C struct layout · #pragma pack
  • C++ to Python port
  • Level-2 market data
  • Order-book data · market microstructure
  • Real-time data pipeline
  • Live feature feed for an ML model
  • Data validation · timestamp join
  • Latency measurement
  • Loopback integration tests
  • Self-testing deployment
  • Windows Server · standard-user deployment

06Releases

Shipped in versions, like a product.

  1. v0.1Receiver, self-test, launcher and guide written from IT’s Linux C++ demo; self-test passed locally and from the deployed copy.
  2. First live runOn a trading server, 17 hours after IT’s demo: first packet in 0.2 s, every packet decoded, about 2,200 instruments. CHRONOS’s live feed from that morning.
  3. Engine-log validation16,575 of 16,575 snapshots identical. CHRONOS makes the engine log its default source; multicast stays selectable.
  4. Share reportThe decoder powers a one-click report of the account’s share of open interest, volume and visible depth, including the night session.
  1. 1lh2611 (the November 2026 live-hog contract), one trading day in September 2026, one trading server: snapshots matched on the exchange timestamp and compared on best bid, best ask and cumulative volume. lh2703 (March 2027) matched 9,132 of 9,132. Two contracts, one day.
  2. 2IT supplied the multicast feed and the Linux C++ reference receiver on September 2, 2026; the Windows receiver, its self-test and launcher were written, tested and packaged for the trading servers the same afternoon. The receiving logic follows IT’s demo; the Windows socket handling, the five Python layouts derived from the header’s packing rules, the level naming, the recorder, the unknown-length detector, the self-test and the launcher are new.
  3. 3About 17 hours from receiving IT’s reference code on the afternoon of September 2, 2026 to the first live packet on a trading server the next morning.
  4. 4Two runs on the first live morning: about 1,000 to 1,600 packets per second on the first, 1,300 to 1,900 and about 2,200 instruments on the second, which also produced the first live size recommendations, within the hour of the first packet. Later one-minute windows counted 2,314 and 2,401 contracts. These are counts of the exchange’s market-wide feed, made through the sizing console, which calls the receiver’s own socket, decoder and recorder.
  5. 5Unknown-length counts on the logged live runs of September 2026, day and night sessions, taken by the sizing console and its diagnostic tools, all of which run this receiver’s own socket and decoder. Every live packet was the Level-2 snapshot.
  6. 6Median of engine log-line time minus multicast arrival time, both on the same machine’s clock.
  7. 7Byte lengths, field widths, padding arithmetic and the level order shown on this page belong to illustrative records written for it; the feed’s own message formats are not published. On live data the receiver confirmed its five-level snapshot layout; the other four layouts are checked by the self-test.
  8. 8Charts, 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.
Previous
Previous

The Guardian

Next
Next

Options MM Analysis