NewTurn any lesson into a live trading bot with one prompt, using AgenKitagenkit.xyz

Part 5 · Market makingLesson 1712 minQuant Bible §6.1–6.2

What a market maker does

Bid, ask, spread and edge, and the three inputs behind every quote: value, last trade and position.

You want to buy Tesla call options. Someone has to sell them to you, right now, at a sensible price. With hundreds of thousands of listed instruments, a natural seller won’t always be there. Market makers fill that gap: they stand ready to buy or sell at prices they quote, all day, and earn a small margin for the service and the risk.

Bid, ask and spread

A market maker quotes a two-sided market written bid @ ask, for example 99 @ 101:

  • the bid (99) is the price they will buy at: you can sell to them there;
  • the ask or offer (101) is the price they will sell at: you can buy from them there;
  • the spread or width is ask − bid (2 here). Exchanges often cap it, and a market maker must honour any trade at the prices they show.

Exchanges partner with market makers to keep products liquid (tradable without big price jumps), and in return market makers get benefits such as fee rebates and better information about order flow. The spread pays for the risk: right after buying from you, the market maker is long and loses if the price drops. They can hedge that risk with related instruments (shares, futures, other options), a principle that comes up constantly in interviews.

The three inputs to every quote

1. Theoretical value. What you think it’s worth. A market on one die roll is centred on 3.5, and you can quote it tightly because you know the distribution exactly. A market on “ping-pong balls that fit in the Empire State Building” has to be much wider. Interviewers want to see the width respond to your uncertainty.

2. Last price traded. Where the market has actually been dealing. If it differs from your value you have to weigh faith in your model against faith in the market. In interview games that repeat, every trade the interviewer makes is information.

3. Current position. Market makers like to be flat (no net exposure). If you are very long something worth $0.50, you might quote $0.43 @ $0.53 instead of $0.45 @ $0.55: you give up edge on the side that sells to make it more attractive for someone to take your inventory. Flat, quote symmetrically around value.

Figure 17.1The order book you quote into
A live, simulated limit order book. Green columns are bids, red are asks, and each row back in depth is an earlier moment. Your bid and ask become one more column at the front. Lesson 21 looks at it in detail.
Figure 17.2Quote builder
The grey curve is your belief about the true value. Wider belief → wider market. Then build a position: the whole quote shifts away from your inventory, giving up edge on the side that reduces risk.

Confidence intervals and realistic markets

Interviewers often ask for an interval: “give me a 90% confidence interval for the number of windows in this building.” As with a market, it should be wider when you know less. But both must be realistic. 0 @ 1 billion contains the truth and nobody will ever trade with you. In real markets the best bid and best offer across all participants form the market, and the tightest, fastest quotes get most of the business.

Width, information and skew

Suppose you must make a market on the number of windows in the building and the interviewer will trade on it. Say the truth (which you don’t know) is 400.

  • Your bid is what you’d pay for the count, your ask what you’d sell it for. If you “buy” at 300 and there are 350, you make 50 units; if there are 275, you lose 25.
  • If your first market is 350 @ 370 and the interviewer knows it’s 400, they buy at 370 and you lose 30. Had they sold at 350, you would have made 50.
  • If you knew the true value, you would quote as wide as the counterparty will still trade on. If you think they believe the answer is high (say 600), you might even show 550 @ 600: your bid is above your own estimate, but they are much more likely to buy from you at 600 than sell to you at 550.

In code

def quote(theo, sigma, position, skew_per_lot=0.6, base=0.5, k=0.6):
    """Bid and ask around a theoretical value, wider when uncertain, skewed against inventory."""
    half_width = base + k * sigma
    mid = theo - skew_per_lot * position
    return round(mid - half_width, 2), round(mid + half_width, 2)

print(quote(100, sigma=4, position=0))     # (97.1, 102.9): symmetric when flat
print(quote(100, sigma=4, position=+5))    # (94.1, 99.9): long, so lean lower to sell
print(quote(3.5, sigma=0.3, position=0))   # a die roll: tight market

Check yourself

You are flat and quoting 49 @ 51 on something you value at 50. You get filled on your bid three times in a row. What should your next market look like?

Progress is saved in this browser only.