Faking a market: the bots that make an empty order book come alive
The matching engine is built and fast. There is one problem: a market with no traders is an empty list. Nothing rests in the book, nothing matches, there is nothing to watch.
Hiring real traders is expensive and they ask for lunch breaks. So you write fake ones. The interesting part is that the fakes have to be believable. Pure random noise looks nothing like a market. What you want is a price that wanders the way real prices do, with orders arriving in a realistic mix. It turns out three simple bots, each following one rule, get you most of the way there.
Bot one: the price wanderer
Real prices do not teleport. They wander in small steps, and they tend to drift back toward some sense of fair value rather than running off to infinity. Those two ideas have names. A random walk is the wandering: each new price is the last price plus a small random nudge. Mean reversion is the pull home: the further the price drifts from its fair value, the harder it gets tugged back.
The first bot moves a hidden fair price with exactly those two forces, then places orders around it. It does more than trade. It mostly posts patient limit orders that rest in the book, fires the occasional market order that trades right away, and cancels one now and then. The split is about seventy percent limit, twenty percent market, ten percent cancel, which is close to how real order flow looks. That mix is what fills the book with depth instead of churning trades.
Bot two: the market maker
A market maker is a trader who always offers to both buy and sell at the same time, a little below fair value and a little above. It hopes to buy low from impatient sellers and sell high to impatient buyers, pocketing the gap, the spread, over and over.
The risk is obvious once you say it out loud. If sellers keep hitting the market maker's buy quote, it keeps accumulating, and now it is holding a big pile of something whose price might fall. The amount it is holding is its inventory, and a one-sided pile is exactly what it wants to avoid.
The fix is a trick called inventory skew. When the bot is holding too much, it shifts both of its quotes down: it makes its sell more attractive to get rid of the pile, and its buy less attractive so it stops adding to it. Lean the wrong way and lower the price you ask; the market gently helps you back to flat. In the chart below, that is the shaded band hugging the price line, the maker's two quotes tracking fair value and leaning as its inventory shifts:
Bot three: the momentum chaser
The last bot does the least thinking. It watches the recent price and, when the price makes a sharp move in one direction, it jumps in the same direction with a market order, betting the move continues. Trend-followers like this are common, and they are part of why real moves sometimes feed on themselves.
"Sharp" needs a number. Traders measure small moves in basis points, where one basis point is one hundredth of one percent, so a hundred basis points is a full one percent. This bot fires when the price moves more than fifteen basis points over its recent window, then sits on its hands for a short cooldown so it does not machine-gun orders on a single wiggle. That is the dot on the chart, the moment a breakout pulls it in.
Why three rules look like a market
None of these bots is clever on its own. One wanders, one quotes a spread and manages its pile, one chases breakouts. Run them together and they start reacting to each other: the maker quotes around the wanderer's price, the momentum bot pounces when the wanderer jumps, and the book fills, thins, and shifts in a way that looks alarmingly like the real thing. That is the quiet lesson of simulations. Believable complexity usually comes from a few plain rules interacting, not from one bot that is secretly a genius.
Source: order-book-simulator, the simulator bots (order generator, market maker, momentum trader). The price walk uses geometric Brownian motion with mean reversion.
Further reading: