Inspiration
Friends. A few of us, one weekend, and a live exchange full of bots we didn't understand yet. We wanted to find a real edge by measuring the market rather than guessing at one.
What it does
Black Friday is a trading bot for Optiver's Optibook exchange. It trades a lead-lag effect we found in the market: three slow stocks (CRWV, NBIS, SNDK) each follow a fast one (MU, AVGO, NVDA), but the slow market-maker bot only closes about half the remaining gap per second. When a leader jumps, our bot works out where the follower should be (β × the leader's move), buys or sells the mispriced follower up to the ±100 position limit with a single order, and closes as the follower catches up, usually within 4–10 seconds.
Around that core:
- An adaptive layer learns each pair's β live, keeps checking that every pair still holds, and pauses a pair whose recent trades lost money.
- A three-stage runner: shadow sends zero orders and only profiles the market, canary trades with ±5 lots, live trades full size.
- Optional market making on the two stocks with no partner (AMD, VRT), which switches itself off when its own fills stop paying.
How we built it
- Watch first. We recorded the full order feed without logging in, so we never disturbed our team's trading connection. From the recordings we identified the two market-maker bots by order size (3000/2000/1000 vs 1000/750/500 lots) and by when they re-quote (at .000 vs .500 each second), and found the three pairs.
- Replay before going live. The real strategy code runs against a fake client that rebuilds the order book from a recording and fills our orders after a chosen delay, with the same position limits and price rounding as the live client.
- Paper trading. Live prices, simulated fills, no login.
- A custom client on top of optibook. It wakes on every order-book update instead of a timer and sends orders without waiting for the exchange's reply, tracking in-flight volume against the position limit. It also keeps itself under the exchange's 25 requests/s limit.
- An offline stress test with scripted counterparties (informed traders, noise traders, copycats, herds, end-of-round panic sellers), so the profiler and the quoting could be tested before risking money.
- Python 3.13 with uv. The bot runs in the Optibook workspace, close to the exchange.
Challenges we ran into
- Latency. From a laptop the round trip to the exchange was 16–870 ms, while other teams clear the stale follower prices within 20–50 ms. In replay, a 5 ms reaction made about twice as much as a laptop connection, so the bot runs in the workspace.
- The time went to waiting, not computing. Our Python decision loop takes about 0.04 ms. The real delays were blocking order calls, a fixed settle pause and a polling timer. Removing them made the bot fast; rewriting it in another language wouldn't have.
- One login per team. A new login kicks the old one, and two copies of our auto-reconnecting bot kicked each other every half second, so neither could trade. The client now steps aside when another session takes over.
- A one-character rounding bug.
-int(-n)isn't a ceiling, so every sell went out one tick too low. We only caught it because the replay showed volumes that made no sense. - Exits cost more than entries. Crossing the slow bot's wide spread on the way out costs more than the edge, so exits wait for better-priced orders from other teams.
Accomplishments that we're proud of
- We found the edge purely from data: the three pairs, their betas, the half-gap-per-second catch-up and both bots' timing within each second.
- In replay over a 40-minute recording, an earlier version of the strategy made about 3,000 per hour with a 5 ms reaction and about 1,600 per hour from a laptop, with no rejected orders and no open position at the end. In paper trading on the live market it made 6 round trips in 14 minutes, all profitable, +324 in total.
- A client whose own decision loop runs in about 0.04 ms.
- Dropping our own ideas when the numbers said so: market making, trading on jumps directly, the social media feed and aggressive exits were all tested and rejected.
What we learned
- Measure the market before building anything. Most ideas that sound good don't make money.
- With a ±100 position cap, profit comes from catching every move and freeing the limit quickly, not from trading bigger.
- Look at the individual events before trusting an average. Our "+0.75 continuation after jumps" turned out to be two back-to-back jumps.
- When results look strange, check your own tooling first.
- Operations matter as much as strategy: one login per team, and a laptop that goes to sleep drops the connection.
What's next for Black Friday
- Record a market open. We assumed the open is the busiest part of a round, but haven't measured it yet.
- Replay the current strategy on more recordings. The published numbers come from its predecessor.
- Let the adaptive layer trade new pairs automatically. Right now it only reports candidate pairs.
- Keep market making only where our own fills prove it pays.
A few things to check before submitting:
- Inspiration: I added a sentence after "Friends". Cut it if you'd rather keep the one word.
- Live results: the repo has none, so the write-up has no live PnL. If you have a final number, put it in "Accomplishments".
- "An earlier version": the replay figures were measured with PairFollower, so the text says "an earlier version of the strategy" on purpose.
Built With
- python
- vscode