Part 2: Running a simple Rust market maker from your laptop in 5 minutes
Today: 2-sided quoting on SOL-PERP
Market making 101
The order book has bids (people wanting to buy) and asks (people wanting to sell). The gap between the best bid and best ask is the spread. Depth is how much size sits at each price. See attached image.
A market maker rests a bid below fair value and an ask above it, and earns the spread when both get filled. Fill too much on one side and you're holding inventory, so you skew both quotes to lean back toward flat. Get filled right before price moves through you and that's adverse selection, the thing that kills makers.
Fair value comes from Binance, where most price discovery happens: the Binance mid plus the average gap between Binance and Bullet. No trustworthy price, no quotes.
The design
The bot uses the actor model. Every input (a Binance tick, a Bullet book update, a fill, a timer) becomes an event on one queue. The market maker reads one event at a time and answers with intents: place this, cancel that. An executor carries them out and reports back as more events.
Why that fits a trading bot:
• One writer, no locks. Only the market maker touches its state, so there are no races between a fill and a requote.
• Quote on the newest info. If more events are waiting, read them first. Quoting on a price you know is stale is a gift.
• Testable. The market maker never touches the network, so its 48 tests run in milliseconds with made-up events.
• Dry run is real. Paper trading is just a different executor, so dry run runs the same code as live.
• Room to grow. Later parts move feeds and the executor onto their own threads without touching the strategy.
It's the same idea LMAX built a famously fast exchange on: a single thread owning the business logic, fed by a queue.
Why Rust
It's fast, close to C++. The compiler is strict, catching memory bugs (no manual memory mgmt with malloc) and data races before they ever reach production. The cargo crate ecosystem is extensive. And there's no garbage collector. A GC pauses your bot at random (see the orange spikes), and the worst time to pause is mid-move, with stale quotes resting. See the test below, same loop in Go vs Rust on my box: Go's worst tick was ~1ms, Rust's ~0.05ms (chart). That tail is where you get picked off.
To be clear, this strat rn has no edge. The defaults are deliberately wide and tiny, and it's slow: every order is synchronously waited on before the next event is read. It also measures no latency numbers yet.
Tomorrow we timestamp every hop, spoiler alert, our Rust trading logic won't be the bottleneck.