15 topics · 2 tracks · one tick-to-trade path

Low-Latency
Trading Systems

From a market-data packet to an order in microseconds — fifteen topics, one system. This is a graduate C++ course in which the deliverable is a trading bot that reacts to a live order book faster than the bot sitting next to it, and the grade is a percentile: p50, p99 and p99.9 of tick-to-trade. Every topic below is one stage of that path, or one C++ tool you need to make that stage cheap.

Start with Week 1 See the two-track map Spend the latency budget Get set up
15
Topics, one system
2
Tracks · same content
p99.9
The grade · never the mean
64 B
The cache line, all term
The learning path

Fifteen topics, two tracks, identical content

The material is taught in two formats. A 15-week track gives each topic its own session; a condensed 9-session track groups them into nine longer meetings, following the order the language is taught in: pointers, then classes, then polymorphism, then templates. Nothing is dropped. Flip the switch and watch the fifteen cards regroup.

15 topics · 13 sessions
Reading the 9-session track. Session 5 (Oct 26) is the midterm and carries no new material. Two pages are split across sessions. Week 3 serves Session 2 (classes, RAII, the Rule of Five, after pointers in week 2) and Session 3 (smart pointers). Week 4 serves Session 3 (runtime polymorphism, its second half) and Session 6 (allocators and pools, its first half). Otherwise the groups run in order: 5+6 are templates and compile-time design; 4+7+8 are the pool, the order book built on it and the O(1) structures around it; 9+10 are the memory model and the lock-free ring; 11+12+13 are the wire, the I/O and the machine; 14+15 are the tail and the tournament, with a short part on pre-trade risk.
Calibration

What a nanosecond is, and why you can feel one

Before any of this is useful you need a physical sense of the units. Pick one and see what fits inside it — the numbers are the reason this course exists.

What fits inside it

    Light in vacuum
    —
    Light in fibre
    —
    Cycles at 3 GHz
    —
    L1 hits
    —
    The one path

    Tick to trade — spend the budget, stage by stage

    This is the whole course in one diagram. A packet lands on the NIC; some number of nanoseconds later an order leaves it. Every stage below is owned by a topic on the map, and every stage is a slider. Move them, switch the kernel off, and watch the total cross the budget line — because the budget is not the mean, it is the tail, and the tail is what you are graded on.

    The waterfall

    Tick to trade
    —

    Controls

    p50
    —
    p99
    —
    p99.9
    —
    Over budget
    —

    This stage

    NIC → host

    Why p99.9, never the mean. A bot with a 4 µs median and a 900 µs p99.9 loses exactly the races that pay: the volatile ticks when every participant fires at once. A single heap allocation, one page fault, one cache miss on a cold branch — none of them move the median and all of them live in the tail. Week 14 is entirely about that sentence.
    Before week 1

    Start here — four things, in this order

    Toolchain check

    Toolchain: RED · 0 of 5

    Ticks are kept only in this browser tab and nothing is sent anywhere. No GPU and no cloud account is needed for any topic in this course; a laptop and a release build are the whole lab.

    If something is red

    -std=c++20 is rejected

    The course uses designated initialisers, constexpr containers, concepts in a couple of places, and std::span. A 2019-vintage compiler will not do.

    Fix: GCC 11+ or Clang 13+. On macOS, Apple Clang from a current Xcode is fine; clang++ -std=c++20 -E -x c++ - < /dev/null is a one-line smoke test.

    Your benchmark reports 0 ns per operation

    You measured nothing. At -O2 the optimiser deletes work whose result is never read, and your timing loop is exactly that.

    Fix: sink every result through a doNotOptimize helper, and never benchmark a debug build. Week 2 does this properly.

    perf is not available

    perf is Linux-only, and even there it needs perf_event_paranoid relaxed. On macOS the equivalents are xctrace, sample and Instruments.

    Fix: do the sampling work on Linux (a container or a small VM is enough), or use the platform profiler — but keep the steady_clock harness as the number of record, because it is the one that matches the grader.

    The threaded version is slower than the single-threaded one

    Almost always false sharing: two hot variables landing on one 64-byte cache line, so two cores invalidate each other on every write.

    Fix: alignas(64) on each hot counter. Week 2 reproduces the regression and Week 9 explains the coherency traffic underneath it.

    What you will have built by the end

    • An order book in flat arrays with O(1) top-of-book and price-time priority.
    • A pool allocator and a lock-free SPSC ring, both with published ns/op numbers.
    • A hand-written binary parser for a market-data feed, with gap detection.
    • A bot whose tick-to-trade p99.9 you can defend from a flame graph.
    Where to go next

    Begin, get the code, or see the sibling arenas

    Begin
    Week 1 · HFT Landscape
    The order book, price-time priority, queue position, and the latency budget that makes them matter.
    Code
    Get the code · 15-week track starter
    Header stubs, the autograder, and the C++ arena client. Use it as a template, then cmake -B build.
    Code
    Get the code · 9-session track starter
    The same stubs and the same grader, packaged for the condensed nine-session schedule.
    Prequel
    Computer Architecture Arena
    Nine interactive dashboards on the machine underneath — from the Turing machine to tick-to-trade.
    Finance intro
    Financial Markets Arena
    What a market is, who trades in it, and what a spread pays for — the vocabulary Week 1 assumes.