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

Part 5 · Market makingLesson 1910 minQuant Bible §6.2–6.3

Play: make a market on five dice

Quote a market while dice are revealed, against a trader who knows more than you do.

Reading about market making only gets you so far. This lesson is a game in the style firms use: a market on a sum of dice, revealed one at a time, against a counterparty who knows a little more than you.

The rules

  • Five dice are rolled and hidden. You are making a market on their sum.
  • Before each die is revealed, show a two-sided market, bid @ ask, between 1 and 6 wide.
  • The trader has peeked at the next die. They buy one lot at your ask if it is at least 1 below their estimate, sell one lot at your bid if it is at least 1 above it, and otherwise pass. Now and then they trade at random.
  • After the fifth die, everything settles at the true sum.

Your theoretical value

Each hidden die has mean 3.5 and variance 35/1235/12. With ss the sum of the revealed dice and hh dice still hidden:

fair value=s+3.5 h,σ=3512 h.\text{fair value} = s + 3.5\,h, \qquad \sigma = \sqrt{\tfrac{35}{12}\,h}.

At the start that is 17.5±3.817.5 \pm 3.8. The readout shows it live; the quote boxes are pre-filled with fair value ± 2, which you are free to change.

Figure 19.1Dice market game
Enter a bid and an ask and press “Show this market”. Watch what the trader does: a buy means the next die is probably high, a sell that it’s probably low. Your position, cash and PnL marked to fair value update after every trade. Play a few games and watch your session total.

How to play it well

  • Width follows uncertainty. Early, with five dice hidden, you know little and the trader knows a lot relative to you. Late, the uncertainty is small, so you can tighten.
  • Trades are information. If they buy, the die they’ve seen is likely 5 or 6. If you are now short, raising your market both protects you and reflects the news.
  • Watch your position. Ending long 3 when the last die comes up 1 is how games are lost. Skew to get flat before the end.
  • You will lose sometimes. An informed trader takes money from a market maker on average. The skill is losing small when you’re picked off and earning the spread from the random trades.

In code

import numpy as np
rng = np.random.default_rng(15)

def play(width=4.0, games=20_000):
    pnl = 0.0
    for _ in range(games):
        dice = rng.integers(1, 7, 5)
        pos = cash = 0.0
        for shown in range(5):
            fair = dice[:shown].sum() + 3.5 * (5 - shown)
            bid, ask = fair - width / 2, fair + width / 2
            trader = dice[:shown + 1].sum() + 3.5 * (5 - shown - 1)   # sees one die ahead
            if trader - ask >= 1:  pos -= 1; cash += ask
            elif bid - trader >= 1: pos += 1; cash -= bid
        pnl += cash + pos * dice.sum()
    return pnl / games

for w in (2, 4, 6):
    print(w, round(play(w), 3))      # wider markets lose less to the informed trader

Check yourself

Three dice are revealed (sum 9) and two are hidden. What is your fair value for the final sum?

Progress is saved in this browser only.