mmd · Musicsimulated in browserconnecting to mmd…

Help · how the market maker thinks

no maths needed for part 1; part 2 derives every formula · every demo runs the desk's real formulas · each field on Params has a ? that links back here

Contents

The desk is a used-car lot

Forget crypto for a minute. You run a used-car lot. You do not care whether car prices go up or down. You make money by buying cars a little below what they are worth and selling them a little above, over and over, all day. That is all a market maker is.

  on the lot                          on the desk
  ──────────────────────────────      ─────────────────────────────────────────────
  a used car                          1 BTC (or ETH)
  what it goes for at other lots      fair price, from Binance, OKX … (the reference venues)
  "we buy at" sign                    our bid on Music
  "we sell at" sign                   our ask on Music
  cars sitting on the lot             inventory / position / delta
  the wholesale auction               Binance perp, where the desk hedges
  a customer who knows the car        an informed or faster trader
    is a lemon before you do
  a price-lock voucher                an option

The desk goes round this loop four times a second, on four markets at once (BTC and ETH, spot and perp) plus the BTC option board:

   other lots ───▶ what is a car worth? ───▶ paint two prices ───▶ customers trade
   (Binance, OKX)        (fair price)             (bid / ask)                │
        ▲                                                                    ▼
        │                                                         count the cars on the lot
        │                                                                    │
        └──── sell extras at the auction ◀──── too many? ◀───────────────────┘
                     (hedge)                  (band, limits)

1 · Two prices on the windscreen

A car goes for $10,000 at every other lot. You paint two prices on it: we buy at $9,700 and we sell at $10,300. The gap between them is the spread; half of it ($300) is your markup on each side, the half-spread.

   customer SELLS to you                                  customer BUYS from you
  ──────────────────────── $9,700 ──── $10,000 ──── $10,300 ────────────────────────
                             BID         fair         ASK
                              └────── spread $600 ──────┘
   one car bought + one car sold = $600 earned … if the going rate did not move meanwhile

How wide? A big markup earns a lot per car, but customers go elsewhere. A tiny markup brings everyone in and earns nothing. Somewhere in between is the most money per day. Two numbers decide where: how many customers walk in when you charge the going rate (A), and how picky they are about a few dollars more (k).

▶ try it · how wide should the markup be?
markup   customers/day   profit/day
    $0       40.0                                     $0
  $100       26.8        ████████████████████         $2,681
  $200       18.0        ███████████████████████████  $3,595
  $300       12.0        ████████████████████████████ $3,614  ◀ you
  $400        8.1        █████████████████████████    $3,230
  $500        5.4        █████████████████████        $2,707
  $600        3.6        █████████████████            $2,177
  $800        1.6        ██████████                   $1,304
$1,000        0.7        ██████                       $733

you: $300 markup → 12.0 customers → $3,614 a day
best markup = 1 / k = $250 → $3,679 a day

Too small a markup: lots of customers, nothing earned on each. Too big: a lot earned on each, nobody comes. The best markup is 1 / k. That is the first half of the desk's spread formula (c₁). The desk pulls it a little tighter when it is nervous (γ), because then it wants the car gone sooner.

↓ where does this formula come from?

2 · Too many cars: lean the prices

Say you bought five cars this morning and sold none. Now you are worried: if car prices fall tomorrow, you lose on all five. What does a sensible dealer do? Drops both prices a bit. Less for the next car (you do not want more) and cheaper to sell (you want these gone). The lot empties itself without a fire sale.

   empty lot:          BID ──── $300 ────  fair  ──── $300 ──── ASK
   five cars too many: BID ─ $450 ─────────── fair ─ $150 ─ ASK        both prices slide down
   five cars short:    BID ─ $150 ─ fair ─────────── $450 ─ ASK        both prices slide up

The formula the desk uses for this is called GLFT. Stripped of symbols it says: distance from fair = the markup customers allow + a charge for risk × how many cars you hold. The risk charge grows with how nervous you are (gamma) and how jumpy the market is (volatility), and shrinks when customers are plentiful (A): a car is less scary when you can sell it in a minute.

   distance of the bid below fair  =  c₁ + (cars + ½) × c₂
   distance of the ask above fair  =  c₁ − (cars − ½) × c₂

   c₁  the markup customers allow      set by k and gamma
   c₂  the risk charge per lot held    set by volatility, gamma, k and A
▶ try it · BTC-USDT's real quote formula (GLFT)
        ──────────────────────────B───│───A──────────────────────────
        $63,940                    $64,000                     $64,060

  B  we buy at   63,991.2   (8.85 $ below fair)
  │  fair        64,000.0
  A  we sell at  64,008.8   (8.85 $ above fair)

  markup part  c₁ = 8.16 $    what the customers allow
  risk part    c₂ = 1.37 $    added per lot of 0.1 BTC you hold, and half of it even when flat

Move the position to the right. Both prices slide down: you pay less for the next car (you do not want it) and you sell cheaper (you want to be rid of one). The lot empties itself. A higher gamma or a jumpier market makes the slide steeper. At the limit (±2 BTC) the side that would add more stops quoting.

↓ where does this formula come from?

On a perp there is one more thing: funding is like a daily parking fee paid by whoever holds cars. When holders pay, the desk quotes lower to avoid holding. perp.tauHoldMin says how long it expects to hold.

3 · Price tags for bigger trades

A customer who wants one car pays the headline price. One who wants to dump ten gets a worse price for each extra car. The desk does the same with a ladder: several orders on each side, each a step further from fair and a bit bigger (z0 is the first size, rho the growth, levels the number of steps).

▶ try it · the price tags (the ladder)
  sell L4  64,026.6  ████████████████████ 0.143
  sell L3  64,022.1  ███████████████      0.110
  sell L2  64,017.7  ████████████         0.085
  sell L1  64,013.3  █████████            0.065
  sell L0  64,008.9  ███████              0.050
          64,000.0  ── fair ──
  buy  L0  63,991.2  ███████              0.050
  buy  L1  63,986.7  █████████            0.065
  buy  L2  63,982.3  ████████████         0.085
  buy  L3  63,977.9  ███████████████      0.110
  buy  L4  63,973.5  ████████████████████ 0.143

  on each side: 0.452 BTC ≈ $28,938 resting

One price tag for a small trade near fair, better prices for bigger trades further out. Someone dumping a lot of BTC at once walks down the ladder and pays more for the privilege. More resting size earns more when the market is calm and loses more when it jumps through all of it.

4 · When the lot makes money

Every car you trade brings in the markup. But three things eat it:

   earned   the markup on each car                                      h
   lost     lemons: the seller knew the price was about to drop            AS  (adverse selection)
   lost     auction trips: cars you could not sell to your own customers   r × c
            had to go to the wholesale auction, which charges a fee
            (r = the share that goes to auction, c = its cost)

   ─────────────────────────────────────────────────────────────
   the lot makes money when     h  >  AS  +  r × c
   … and a trend does not run over the cars you are holding

In crypto money: the half-spread is about 4 bp (0.04 %). A lemon costs whatever the price moves against you in the next 10 seconds. The auction is the Binance perp at about 6 bp. So if every trade went one way (r = 100 %), each 4 bp earned would pay 6 bp at the auction and lose money. The desk only wins when buyers and sellers mostly cancel each other out and most customers are ordinary people, not traders who know something.

▶ try it · plan.md §3–4: is the lot making money?
  markup earned      h     +4.0 bp  ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
  lemons             AS    −1.0 bp  ░░░░░░                  
  auction trips     r×c    −1.8 bp  ░░░░░░░░░░░                (30 % × 6 bp)
  ────────────────────────────────
  edge per $1 traded       +1.2 bp   ✓ making money

  × $2M a day  =  +$240 a day for the desk

The whole plan in one line: edge = h − AS − r × c. The three presets are the table in plan.md §4.3. Look how thin it is: one or two basis points decide whether the day is green or red. Separately, the exchange earns the crowd's taker fees (4.5 bp × volume). That is a different pocket from the desk's PnL.

↓ where does this formula come from?

5 · A day on the lot

The formula above is an average. A real day is noisy. This toy lot runs 8 hours of one BTC market, minute by minute: ordinary customers, a few fast traders, the price wobbling and trending, the dealer leaning and hedging. Each button is one scenario from plan.md §4. Green ones should make money; red ones show how a lot loses it.

▶ try it · a day on the lot: every scenario of plan.md §4

plan.md §4.1 #1–2: Ordinary customers, buyers and sellers in balance. They cancel each other out, so the lot rarely fills up and the auction is rarely needed. Each round trip earns the markup.

63,00063,50064,0009:0012:5916:59
totalmarkup earnedcars held as price movedauction trips
0+250+500+7509:0012:5916:59
  markup earned                 +$688   256 ordinary + 5 fast-trader fills
  cars held as price moved      −$113   lemons and trends land here
  auction trips                 −$133   3.5 BTC hedged
  ─────────────────────────────────────
  the day                       +$442   ✓  on $1.72M traded

A toy lot, not the desk: one market, fixed customer types, no fees to Music. Press 🎲 a few times on each preset. The good days are not always green and the bad days are not always red. It is the average over many days that the plan is about.

Two scenarios from plan.md are not in the toy. Funding (§4.1 #4, §4.2 #6): when the crowd is mostly long the perp, the desk is short and receives the parking fee every hour. When the crowd is mostly short, it pays. Bugs (§4.2 #8): an order left behind after a crash costs whatever the market does to it. That is why the watchdog and the kill switch come before real money.

6 · Stale prices and fast traders

The biggest loss in plan.md is the stale quote. Binance moves first. The news reaches our bus, then mmd, then Music. For that moment our price on the windscreen is out of date, and anyone who sees the new price first can buy our “cheap” car before we repaint it.

   time ──▶   Binance moves +$50        our quote still old      we repaint
              ────────●──────────────────────────●────────────────────●───────
                      │◀────── the open door (latency) ──────▶│
                                    a fast trader buys here: we lose $50 minus our markup

What the desk does about it, and the params that control it:

   repaint quickly            oms.thetaFrac         repaint once fair moved this share of the markup
                              oms.maxActionsPer10s  an order budget (0 = unlimited)
   widen when flow is one-way cVpin                 lots of sellers at once = someone knows something
   widen after lemons         (automatic)           the spread grows by the measured 10-second loss
   pull everything on a burst option.mmpQ/Delta/Vega  too many option fills in 2 s → quotes off for 5 s

Try the fast traders preset in the day demo: the markup is earned as usual, but the “cars held” line slides down with every one of their trades.

7 · The wholesale auction (hedging)

When the lot fills up with more cars than you can sell to your own customers, you take the extras to the wholesale auction (Binance perp). The auction charges a fee, so you do not go for every single car. You wait until the extras pass a line, the band, and then sell back to the line, not all the way to zero.

The desk counts all its exposure as one number, delta: BTC spot held + BTC perp held + how much the options behave like BTC. The band formula (Whalley–Wilmott) balances two costs: the fee of each trip against the risk of holding extras in between.

▶ try it · when to drive to the auction (hedge band)
  −6 BTC ─────╳──────────────────────[─┼─●──────────────────────╳───── +6 BTC
  ● the desk now    [ ] the band: do nothing inside    ╳ hard limit ±5: hedge straight to zero

  band from the formula  0.402 BTC   (cost 5 bp, gamma 3.69e-4, aversion 1e-4)
  band used              ±0.402 BTC  

  delta +0.30 BTC → inside the band: do nothing

You do not drive to the auction for every car: the trip costs money. You go when you have more extra cars than the band allows, and you only sell back to the edge of the band, not to zero. Expensive trips (λ↑) mean a wider band; worrying more (risk aversion↑) means a narrower one. Holding options (gamma) widens it, because their delta swings back and forth by itself.

↓ where does this formula come from?

8 · Options are price-lock vouchers

A customer loves a car at $64,000 but is not ready. You sell them a voucher: “for the next 30 days you may buy this car for $70,000, whatever it costs by then.” That is a call option. $70,000 is the strike. The other kind is a trade-in guarantee: “you may sell me your car for $60,000”. That is a put, which is really insurance against a price drop.

   what the call voucher is worth on its last day

     worth │                                        ╱
           │                                      ╱   the car is worth more than 70k:
           │                                    ╱     the voucher is worth the difference
           │                                  ╱
         0 ┼━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━●━━━━━━━━━━━━━━━━  BTC price on expiry day
           │    below 70k: nobody uses it,    70,000
           │    worth nothing (never less)    strike

So what should the voucher cost today? Nobody knows where BTC will be in 30 days. But we can list the possibilities: it might be 50k, 64k, 80k, each with some chance. For each one we know what the voucher would be worth. The fair price is the average. That is exactly what the famous formula (Black–Scholes; the desk uses its forward-price cousin Black-76) computes in one go. The only unknown input is how jumpy BTC is, the volatility. Jumpier means more far-away outcomes, and the voucher only gains from those, so it costs more.

▶ try it · what is a price-lock voucher worth today? (Black-76)
  BTC at expiry           chance                              voucher worth then   × chance
  below 43,933           0.6 %  █                                   $0           $0
  43,933–47,265          1.7 %  ██                                  $0           $0
  47,265–50,850          4.4 %  ██████                              $0           $0
  50,850–54,706          9.2 %  ████████████                        $0           $0
  54,706–58,856         15.0 %  ████████████████████                $0           $0
  58,856–63,320         19.1 %  ██████████████████████████          $0           $0
  63,320–68,122         19.1 %  ██████████████████████████          $0           $0
  68,122–73,289         15.0 %  ████████████████████              $913         $137
  73,289–78,847          9.2 %  ████████████                    $5,749         $528
  78,847–84,827          4.4 %  ██████                         $11,374         $501
  84,827–91,261          1.7 %  ██                             $17,420         $288
  above 91,261           0.6 %  █                              $25,767         $160
  ──────────────────────────────────────────────────────────────────────────────────────────
  add up the last column (the average worth)   $1,614.05
  Black-76 formula                              $1,614.04   ← the same number, without the table

  chance it ends up worth something   24.6 %
  delta  +0.295   BTC +$100 → voucher +$29.47
  theta  −53.78   $ lost per day if nothing happens
  vega   63.28    $ gained if the market gets 1 point jumpier
  gamma  3.69e-5   how fast delta changes as BTC moves

That is all the option formula does. List the prices BTC might have at expiry, how likely each one is, and what the voucher would be worth there. The average is the fair price. Stretch the days or the jumpiness: more outcomes land far from today's price, and the voucher gets dearer. It can never be worth less than zero, so wild outcomes only help its owner.

↓ where does this formula come from?

The four “greeks” below the table are just ways the voucher's price reacts. Delta: to BTC moving (and roughly the chance it pays off). Theta: to a day passing. Vega: to the market getting jumpier. Gamma: how fast delta itself changes. The desk hedges delta at the auction and keeps the others within limits.

↓ how each greek is derived, and how its number is worked out

9 · Selling vouchers: who wins?

The desk mostly sells vouchers, like an insurance company sells policies. It collects the premium up front, and every quiet day a slice of it becomes the desk's (theta). Every wild day the buyer's voucher gains and the desk pays (gamma). The price assumed a certain jumpiness. If the market turns out calmer than that, the desk wins. If it turns out wilder, the desk loses.

▶ try it · the desk sold a voucher: who wins today?
  sold 1 at-the-money call, 30 days, delta hedged
  theta earned per day  +$62.05      break-even move ±$1,708 a day  (= price × vol / √365)

  BTC moved   desk's day
       $0                    │▓▓▓▓             +$62
     $500                    │▓▓▓              +$57
   $1,000                    │▓▓               +$41
   $1,500                    │▓                +$14
   $2,000                   ░│                 −$23
   $2,500                ░░░░│                 −$71
   $3,000             ░░░░░░░│                 −$129
   $4,000    ░░░░░░░░░░░░░░░░│                 −$278

  today: moved $1,000 → +$41  ✓ the market moved less than priced: the desk keeps the premium

Selling a voucher is selling insurance. Every quiet day the desk earns a slice of the premium (theta). A big day costs it: the buyer's voucher gains, and re-hedging after the move locks the loss in (gamma). Over the life of the option, the desk wins if BTC moved less than the price assumed (plan.md §4.1 #5) and loses if it moved more (§4.2 #5).

↓ where does this formula come from?

plan.md adds a warning: today there is no outside option price (no Deribit feed) to check our volatility against. If our jumpiness guess is wrong, every voucher is mispriced, and customers will buy exactly the ones that are too cheap.

10 · How the desk quotes options

Option dealers do not think in dollars; they think in jumpiness. “I buy at 50 %, I sell at 52 %”. h0 is that gap in vol points for an at-the-money option. Far strikes (cW) and short expiries (cT) get a wider gap because they are harder to price. Vega turns the gap into dollars, and the cost of hedging the option's delta is added on top.

▶ try it · option quote = fair ± (vega × vol spread) + hedge cost
  BTC $64,000, 30-day $70,000 call at 51 % vol

  vol spread   1.00 × (1 + 0.30·far-ness 0.61) × (1 + 1.0/√30)  = 1.40 vol pts
  in dollars   1.40 vol pts × vega 63.28 $                        = $88.59
  + hedging its delta 0.29 BTC at 3.5 bp                        + $6.60

  bid   $1,518.7   ◀── $95.3 ──   fair $1,614.0   ── $95.3 ──▶   ask $1,709.3

Option dealers think in jumpiness, not dollars: “I sell at 52 %, I buy at 50 %”. Vega turns that into dollars. Far strikes and short expiries are harder to price, so they get a wider vol spread. The desk also leans each quote by what it does to the whole book (gammaVega): long too much vega, and every bid and ask drops a little, so the desk sells more easily than it buys.

↓ where does this formula come from?

Like the car lot leaning its prices, the options desk leans too, but by what each voucher does to the whole book (gammaVega). Sold too many already? Both its prices move up: it pays more to buy vouchers back and asks more for new ones, so the next voucher is more likely bought back than sold. Selling a voucher also locks up margin at the bank; capCost adds a week of interest on it to the ask.

11 · Limits and the kill switch

Every lot has rules that override the clever pricing:

   soft limit   the lot is getting full        yellow on the Risk page; lean harder, warn
   hard limit   the lot is full                stop buying (inventory, vega), or hedge straight
                                               to zero (delta past deltaHardBtc)
   daily loss   lost lossHardPct of capital    KILL: cancel every order, stop quoting
   KILL button  close the lot now              the same, by hand; Flatten also hedges delta to zero

The scenario grid on the Risk page asks: “if BTC jumped 10 % and got 10 points jumpier right now, what would we gain or lose?” Blue is a gain, red a loss. If a plausible jump in the grid shows a loss you could not live with, lower qMax or the option size before the market does it for you.

Part 2 · Where the formulas come from

Part 1 told you what each formula does. Part 2 shows how people found them, one small step at a time. You need nothing but the eight tools in the first card; each of them is explained from scratch. Every step ends in a number you can check against part 1, and every card links back to the section it explains.

W0 · The toolbox: eight ideas, explained from zero

1. The slope (derivative). Take any machine that turns a number into another number, like “markup in, dollars a day out”. Turn the knob a tiny bit. How much does the output change, per bit of knob? That ratio is the slope. Written f′(x), or ∂f/∂x when the machine has several knobs and you turn only one.

   f(x) = x²      at x = 3:  f(3) = 9,  f(3.001) = 9.006001
                  slope ≈ (9.006001 − 9) / 0.001 = 6.001  →  exactly 6 = 2·3 when the nudge shrinks to nothing

2. The top of a hill is flat. Walk up a hill: the ground slopes up. Walk past the top: it slopes down. Exactly at the top it is flat, slope 0. So to find the best of anything, write down its slope and ask “where is it zero?”. Most formulas in this guide are found that way.

3. Six slope rules. You never need the nudge-and-divide by hand; these rules do it for you:

   machine                 its slope                 in words
   ────────────────────    ──────────────────────    ────────────────────────────────────────────
   c  (a constant)         0                         a knob that does nothing
   xⁿ                      n·xⁿ⁻¹                    x² → 2x,   x³ → 3x²,   √x = x^½ → 1/(2√x)
   e^(a·x)                 a·e^(a·x)                 e grows in proportion to itself
   ln x                    1 / x
   f·g  (product)          f′·g + f·g′               wiggle one, hold the other; then swap; add
   f(g(x))  (chain)        f′(g(x)) · g′(x)          slope of the outside × slope of the inside

4. e and ln. e = 2.71828… is the number that makes rule 3 so tidy. ln (natural log) undoes it: ln(e^x) = x. Handy facts: e^(a+b) = e^a·e^b, ln(a·b) = ln a + ln b, and for a small x, ln(1 + x) ≈ x and e^x ≈ 1 + x.

5. The average (expected value). List what can happen, multiply each outcome by its chance, add up. A game that pays $10 with chance ¼ and $0 otherwise is worth 10·¼ + 0·¾ = $2.50 on average. When the outcomes are a smooth range, the “add up” becomes an integral ∫, but it is the same idea.

6. Wobbles add in squares. The size of a wobble is measured by its variance (the average of the squared distance from the average). Its square root is the standard deviation, the “typical distance”. Two wobbles that do not care about each other: their variances add, not their sizes. That one fact is behind every √ of time on this page (W1).

7. The bell curve. Roll a special die that gives a number Z, usually near 0, sometimes ±2, very rarely ±4. Its chances follow the bell curve. Two helpers name it:

   φ(z) = e^(−z²/2) / √(2π)      height of the bell at z                (phi, small)
   Φ(z) = area under φ left of z  the chance the die rolls below z       (Phi, big)

   Φ(0) = 0.5    Φ(1) = 0.841    Φ(−1) = 0.159    Φ(2) = 0.977

   three facts we will use:
     Φ′(z) = φ(z)              the area grows by the height at its edge
     φ′(z) = −z·φ(z)           chain rule on e^(−z²/2): slope of −z²/2 is −z
     Φ(−z) = 1 − Φ(z)          the bell is symmetric: "above −z" is as likely as "below z"

8. Zooming in (Taylor). Zoom into any smooth curve and it looks straight; zoom a little less and it looks like a gentle bowl. So for a small step h:

   f(x + h)  ≈  f(x)  +  f′(x)·h  +  ½·f″(x)·h²
                         └ straight part ┘  └ bend: f″ is the slope of the slope ┘

W1 · Why jumpiness grows with √time

Step 1. Picture the price as a walker who flips a coin every second: heads a step up, tails a step down. After one step the walker is ±1 away: variance 1.

Step 2. The steps do not care about each other, so by tool 6 their variances add. After n steps the variance is 1 + 1 + … = n. The typical distance is the square root: √n.

▶ try it · 2,000 walkers flip a coin every step
  steps n   average position   typical distance from start   √n
        1              −0.01                          1.00     1.00
        4              −0.01                          2.00     2.00
       16              −0.04                          4.00     4.00
       64              −0.07                          7.95     8.00
      256              +0.04                         15.79    16.00
     1024              +0.24                         31.12    32.00

The average stays near 0: left and right cancel. But the typical distance (the square root of the average squared distance) is always about √n. Four times as many steps only doubles it. That is why every “how far can the price get” formula on this page has a square root of time in it.

Step 3. Volatility σ is quoted as “typical move in one year”. A year has 365 × 86,400 = 31,536,000 seconds, so the typical move in one second is σ / √31,536,000 = σ / 5,615.7, and in one day σ / √365 = σ / 19.1.

   σ_$ (per √second)  = price · σ / 5,615.7  = 64,000 · 0.50 / 5,615.7 = $5.70     used by the quotes, §2
   typical day        = price · σ / √365     = 64,000 · 0.51 / 19.105  = $1,708    the option break-even, §9
   typical 30 days    = price · σ · √(30/365)= 64,000 · 0.51 · 0.2867  = $9,357    the "typical move" on the voucher demo

Step 4 (bonus: when to repaint, §6). A walker starting in the middle of a fence ±θ wide needs on average θ² / σ² seconds to touch it (flip the √ around: distance θ needs time θ²/σ²). If you can only afford to repaint 3 times a second, pick θ so that θ²/σ² = ⅓ s: θ = σ/√3 = 5.70/1.732 = $3.29, the example in strategy.md §3.8.

W2 · The best markup: 1/k, then c₁

Step 1: count the customers. At markup d, customers per day on one side = A·e^(−k·d). At d = 0 that is A (all the walk-ins). Each extra dollar of markup keeps the same share of them, so the count shrinks like interest in reverse; that is what e^(−k·d) means. k is how fast they drop off.

Step 2: money per day on one side = markup × customers = d · A·e^(−k·d).

Step 3: find the top of the hill (tool 2), using the product rule (tool 3) on d times A·e^(−k·d):

   slope = 1 · A·e^(−k·d)  +  d · (−k)·A·e^(−k·d)
         = A·e^(−k·d) · (1 − k·d)

   A·e^(−k·d) is never 0, so the slope is 0 only when  1 − k·d = 0   →   d = 1 / k

   check with the demo in §1:  k = 4 per $1,000 = 0.004 per $   →   best markup = 1/0.004 = $250
                               money a day = 2 sides · 20 · e^(−1) · 250 = $3,679

Step 4: a nervous dealer. A dealer who fears risk does not feel dollars equally: the first dollar feels great, the thousandth a bit less. Economists model that feeling with the happiness curve (1 − e^(−γ·x)) / γ. For a tiny γ it is just x (tool 4: e^(−γx) ≈ 1 − γx). For a bigger γ it bends over. Put the feeling of the markup in place of the markup:

   happiness a day  =  A·e^(−k·d) · (1 − e^(−γ·d)) / γ

   slope = A·e^(−k·d) · [ −k·(1 − e^(−γd))/γ  +  e^(−γd) ]        product rule again
   set to 0:          k·(1 − e^(−γd)) = γ·e^(−γd)
                      k = (k + γ)·e^(−γd)
                      e^(γd) = 1 + γ/k                             take ln of both sides
                      d = (1/γ)·ln(1 + γ/k)   =  c₁                 the desk's formula, §2

   check:  γ = 0.001, k = 0.3:   c₁ = 1000 · ln(1.00333) = $3.328      (1/k = $3.333)
   and as γ → 0, ln(1 + γ/k) ≈ γ/k (tool 4), so c₁ → 1/k: a fearless dealer is back to step 3

A nervous dealer asks a little less, because a sale that happens sooner is worth more to someone who dislikes waiting with risk.

W3 · The lean: where c₂ and the ½ come from

Step 1: how a nervous dealer values a gamble. Money that wobbles feels like less than the same money for sure. For a bell-curve wobble and the happiness curve of W2, the exact answer is short:

   feels like  =  average  −  (γ/2) · variance

Step 2: the lot's wobble. Holding q cars for τ seconds, each car wobbles by σ√τ (W1) and they all move together, so the lot wobbles by q·σ√τ. Variance: q²·σ²·τ. The lot feels like q·s − (γ/2)·q²·σ²·τ.

Step 3: what would you pay for one more car? The price that leaves your happiness unchanged. Compare q + 1 cars with q cars:

   pay for car q+1  =  feels(q+1) − feels(q)
                    =  s − (γ/2)·σ²τ·[ (q+1)² − q² ]
                    =  s − (γ/2)·σ²τ·(2q + 1)
                    =  s − (q + ½)·γσ²τ            ← there is the ½

   sell car q       =  feels(q) − feels(q−1)  =  s − (q − ½)·γσ²τ

   call γσ²τ = c₂, add the markup c₁ of W2, and you have §2 exactly:
     bid below fair  = c₁ + (q + ½)·c₂        ask above fair = c₁ − (q − ½)·c₂

The ½ is fair play: even the first car makes the lot wobble, so even an empty lot shades both prices by half a step.

Step 4: how long is τ? As long as the car sits on the lot. And the lean itself decides that: leaning by c₂ per car moves the ask closer (more buyers) and the bid further (fewer sellers). Here is a back-of-envelope with only tools 2–4:

   fills per second near the quote     A·e^(−k·c₁)
   extra fills per $ closer            k·A·e^(−k·c₁)             the slope of A·e^(−kd)
   q cars, lean q·c₂ on both sides     cars leave at  2·k·A·e^(−k·c₁)·c₂·q  per second
   so each car stays on average        τ = 1 / (2·k·A·e^(−k·c₁)·c₂)

   plug into c₂ = γσ²τ:                c₂² = γσ² / (2·k·A·e^(−k·c₁))
   and e^(−k·c₁) = (1+γ/k)^(−k/γ)      (from W2, e^(γc₁) = 1+γ/k)

   back-of-envelope   c₂ = √( γσ²/(2kA) · (1+γ/k)^(k/γ) )       = 0.3832
   the exact GLFT     c₂ = √( γσ²/(2kA) · (1+γ/k)^(1+k/γ) )     = 0.3839   (γ 0.001, k 0.3, A 1, σ² 32.47)

The two agree to 0.2 %. The exact version (Guéant, Lehalle and Fernandez-Tapia, 2013) solves the dealer's whole never-ending day at once with an equation called HJB; that is beyond this page, but its answer has exactly the shape the steps above found.

W4 · When the lot makes money: h > AS + r·c

This one is only bookkeeping. Follow one dollar of trade through the lot:

   +h        every fill earns the markup
   −AS       right after a fill the price moves against us on average by AS (the lemons)
   −r·c      a share r of fills are not cancelled by a customer on the other side;
             each of those needs an auction trip costing c
   ─────
   edge per $ traded  =  h − AS − r·c        positive → the lot makes money

Where does AS come from? Say a share π of customers know the price is about to move by J (Glosten and Milgrom, 1985). Each of them costs you J, the others cost nothing, so on average one fill costs π·J (tool 5). 5 % informed traders who know about a 20 bp move cost 0.05 · 20 = 1 bp per fill: the “calm” preset.

W5 · The option formula (Black-76), built by hand

Step 1: a model of the future. Where will BTC be in T years? Roll the bell-curve die Z and say:

   price at expiry  =  F · e^( σ√T·Z − σ²T/2 )

   F       the forward: today's price plus the perp's drift (with no drift, F = today's price)
   σ√T·Z   a bell-curve wobble whose size grows with √time (W1)
   e^(…)   prices move by percentages, and can never drop below 0
   −σ²T/2  a small correction so that the AVERAGE price at expiry is exactly F (step 2)

Step 2: the trick of the whole page, “completing the square”. Write a = σ√T. Multiply the bell by e^(a·z):

   e^(a·z) · φ(z)  =  e^(a·z − z²/2) / √(2π)
                   =  e^(a²/2) · e^(−(z−a)²/2) / √(2π)       since  −(z−a)²/2 = −z²/2 + a·z − a²/2
                   =  e^(a²/2) · φ(z − a)

   in words: multiplying the bell by e^(a·z) gives the SAME bell slid right by a, scaled by e^(a²/2).

   average of e^(a·Z) = e^(a²/2) × (area under a whole bell = 1) = e^(a²/2)
   so average price = F · e^(a²/2) · e^(−a²/2) = F                      ✓ the correction works

Step 3: when does the voucher pay? When the price ends above K:

   F · e^(aZ − a²/2) > K
   aZ − a²/2 > ln(K/F)                     take ln of both sides
   Z > [ ln(K/F) + a²/2 ] / a  =  −d₂       where   d₂ = [ ln(F/K) − σ²T/2 ] / (σ√T)

   chance it pays = chance Z > −d₂ = Φ(d₂)      (tool 7, symmetry)

Step 4: the average payment (tool 5) splits in two: the average price when it pays, minus K times the chance it pays.

   K part:      K · Φ(d₂)

   price part:  average of  F·e^(aZ − a²/2)  over the rolls with Z > −d₂
              = F · e^(−a²/2) · (area of e^(a·z)·φ(z) right of −d₂)
              = F · e^(−a²/2) · e^(a²/2) · (area of φ(z − a) right of −d₂)       step 2
              = F · (chance a slid-over roll lands above −d₂)
              = F · Φ(d₂ + a)  =  F · Φ(d₁)          where  d₁ = d₂ + σ√T

   call  =  F·Φ(d₁) − K·Φ(d₂)                                          ✓ the formula of §8

Step 5: the put for free. A call minus a put pays (price − K) whatever happens: if the price ends high, the call pays it; if low, you owe it on the put. Its average is F − K. So put = call − F + K.

Step 6: the numbers. BTC 64,000, strike 70,000, 30 days, σ = 51 %:

   T      = 30 / 365                               = 0.08219 years
   σ√T    = 0.51 · √0.08219 = 0.51 · 0.28669         = 0.14621
   ln(F/K)= ln(64,000 / 70,000)                    = −0.08961
   σ²T/2  = 0.2601 · 0.08219 / 2                   = 0.01069
   d₁     = (−0.08961 + 0.01069) / 0.14621          = −0.53978
   d₂     = d₁ − σ√T = −0.53978 − 0.14621           = −0.68600
   Φ(d₁)  = 0.29467          Φ(d₂) = 0.24636        (from a Φ table, or ncdf() in src/lib/quant.ts)

   call   = 64,000 · 0.29467 − 70,000 · 0.24636
          = 18,859.08 − 17,245.04                  = $1,614.04
   put    = 1,614.04 − 64,000 + 70,000             = $7,614.04
▶ try it · price the 70,000 call by rolling dice
  BTC today 64,000 · strike 70,000 · 30 days · 51 % a year

                                   by rolling dice      by the formula
  average BTC price at expiry             $63,975             $64,000   (F)
  share of futures that pay               25.07 %             24.64 %   (Φ(d₂))
  average payment = fair price          $1,600.39           $1,614.04   (F·Φ(d₁) − K·Φ(d₂))

With 100 rolls the dice are rough. With a million they agree with the formula to a few dollars. The formula is simply the answer you would get with infinitely many rolls, worked out once with pencil and paper.

W6 · Every greek, derived, with its number

A greek is just a slope (tool 1) of the option price: turn one knob, hold the others, see how the price moves. Four knobs, so four first greeks, plus two “slopes of slopes”:

   greek   the knob turned                      slope of
   ─────   ──────────────────────────────────   ──────────────────
   Δ       BTC price F                          price
   Γ       BTC price F                          Δ   (slope of a slope)
   ν vega  volatility σ                         price
   Θ       time (one day passes)                price
   vanna   volatility σ                         Δ
   volga   volatility σ                         ν

Two helper facts first. They make every greek short.

   (a)  d₁ and d₂ react to F the same way. d₂ = d₁ − σ√T, and σ√T has no F in it:
          ∂d₁/∂F = ∂d₂/∂F = 1 / (F·σ√T)          since d₁ = [ln F − ln K + σ²T/2]/(σ√T), and (ln F)′ = 1/F

   (b)  the magic cancellation:   F·φ(d₁) = K·φ(d₂)
          φ(d₂)/φ(d₁) = e^((d₁² − d₂²)/2) = e^((d₁ − d₂)(d₁ + d₂)/2)
          d₁ − d₂ = σ√T  and  d₁ + d₂ = 2·ln(F/K)/(σ√T),  so the exponent is ln(F/K)
          φ(d₂)/φ(d₁) = F/K                                      ✓
          check: 64,000 · φ(−0.53978) = 64,000 · 0.34486 = 22,070.93
                 70,000 · φ(−0.68600) = 70,000 · 0.31530 = 22,070.93   the same

Δ, delta. Take the slope of call = F·Φ(d₁) − K·Φ(d₂) with respect to F. Product rule on the first part, chain rule (Φ′ = φ) on both:

   ∂call/∂F = Φ(d₁)  +  F·φ(d₁)·∂d₁/∂F  −  K·φ(d₂)·∂d₂/∂F
            = Φ(d₁)  +  [ F·φ(d₁) − K·φ(d₂) ] / (F·σ√T)        by (a)
            = Φ(d₁)  +  0                                      by (b)

   Δ_call = Φ(d₁) = Φ(−0.53978) = 0.2947     BTC +$100 → voucher +$29.47
   Δ_put  = Φ(d₁) − 1 = −0.7053              (slope of put = call − F + K: subtract 1)

Γ, gamma. The slope of Δ. Chain rule on Φ(d₁):

   Γ = φ(d₁) · ∂d₁/∂F = φ(d₁) / (F·σ√T)
     = 0.34486 / (64,000 · 0.14621) = 0.34486 / 9,357.6 = 0.00003685        same for the put

ν, vega. Turn σ. d₁ and d₂ both move, but their gap is σ√T, so ∂d₁/∂σ − ∂d₂/∂σ = √T:

   ∂call/∂σ = F·φ(d₁)·∂d₁/∂σ − K·φ(d₂)·∂d₂/∂σ
            = F·φ(d₁) · (∂d₁/∂σ − ∂d₂/∂σ)                  by (b)
            = F·φ(d₁)·√T                                   per 1.00 of σ (100 vol points)

   ν per vol point = 64,000 · 0.34486 · 0.28669 / 100 = 22,070.93 · 0.28669 / 100 = $63.28

Θ, theta. Turn T. Exactly the same trick: the gap σ√T has slope σ/(2√T) in T (rule xⁿ with n = ½). Time passing makes T smaller, so the sign flips:

   ∂call/∂T = F·φ(d₁) · σ / (2√T)                     per year of extra life
   Θ per day = −F·φ(d₁)·σ / (2√T) / 365
             = −22,070.93 · 0.51 / (2 · 0.28669) / 365 = −11,256.2 / 0.57338 / 365 = −$53.78

vanna and volga. One more small slope, ∂d₁/∂σ. Write d₁ = ln(F/K)/(σ√T) + σ√T/2 and use rule xⁿ with n = −1 on the first part:

   ∂d₁/∂σ = −ln(F/K)/(σ²√T) + √T/2  =  −d₂/σ          (tidy up using ln(F/K)/(σ√T) = d₁ − σ√T/2)
   ∂d₂/∂σ = ∂d₁/∂σ − √T                =  −d₁/σ

   vanna = ∂Δ/∂σ = φ(d₁)·∂d₁/∂σ = −φ(d₁)·d₂/σ
         = −0.34486 · (−0.68600) / 0.51             = 0.4639 per 1.00 of σ → Δ +0.0046 per vol point
   volga = ∂ν/∂σ = F√T · φ′(d₁)·∂d₁/∂σ = F√T · (−d₁φ(d₁)) · (−d₂/σ) = ν·d₁·d₂/σ    (tool 7: φ′ = −zφ)
         = 63.28 · (−0.53978)(−0.68600) / 0.51       = 45.94 per 1.00 of σ → ν +$0.46 per vol point

Check any greek by brute force. A greek is a slope, so nudge the knob and re-price with the formula from W5:

   nudge                      price before → after        change    formula greek
   ───────────────────────    ────────────────────────    ───────   ──────────────────────
   BTC ±$100                  1,584.75 → 1,643.69          /200 = 0.2947     Δ  0.2947     ✓
   σ 51 % → 52 %              1,614.04 → 1,677.54          +63.50            ν  63.28 + ½·volga/100 ≈ 63.51
   one day passes (29 days)   1,614.04 → 1,559.97          −54.07            Θ  −53.78 (+ its own bend)

The vega and theta rows differ from the formula by a few tenths. That is not an error: a greek is the slope at the point, and a whole vol point or a whole day is a step long enough for the curve to bend (tool 8). The ½·volga term of Taylor accounts for vega's gap exactly.

W7 · Selling vouchers: theta against gamma

Step 1: zoom in on one day (tool 8). BTC moves by dS, one day passes:

   voucher change  ≈  Δ·dS  +  ½·Γ·dS²  +  Θ

Step 2: the desk sold it and hedged Δ. The hedge earns Δ·dS back, so the Δ·dS cancels. What is left for the seller is the voucher change with the sign flipped:

   seller's day  ≈  −Θ  −  ½·Γ·dS²   =   |Θ|  −  ½·Γ·dS²
                     └ rent collected ┘  └ paid when BTC moves, grows with the SQUARE of the move ┘

Step 3: Θ and Γ are tied together. Put the W6 formulas side by side:

   ½·Γ·F²·σ²  =  ½ · φ(d₁)/(F·σ√T) · F²·σ²  =  F·φ(d₁)·σ / (2√T)  =  |Θ| per year
   so per day:   |Θ| = ½·Γ·F²·σ² / 365

Step 4: break-even. The seller's day is 0 when ½·Γ·dS² = ½·Γ·F²σ²/365. Γ cancels:

   dS = F·σ / √365 = 64,000 · 0.51 / 19.105 = $1,708               the typical day of W1

   check with the demo in §9 (at-the-money, 30 days):
     Θ = $62.05 a day,  Γ = 0.00004252
     ½ · 0.00004252 · 1,708² = $62.05                                 ✓ exactly the rent

So the price of a voucher is a bet on jumpiness: the rent is set by the σ that was priced in, the payments by the moves that actually happen.

W8 · The option quote and the greek lean

The spread in dollars. Vega is the slope of the price in vol points, so a step of h_σ vol points is worth about ν·h_σ dollars (tool 8, straight part). Selling the voucher also means buying |Δ| BTC to hedge it, paying the taker fee:

   h = ν·h_σ + |Δ|·F·fee
     = 63.28 · 1 + 0.2947 · 64,000 · 0.00035 = 63.28 + 6.60 = $69.88       (plus one tick)

The wider spread for far strikes (cW) and short expiries (cT) is not derived: it is a rule of thumb that says “we are less sure there”.

The greek lean (gammaVega). Give the desk a penalty for holding vega: U = ½·γ_ν·ν_P², a bowl that is 0 when flat and grows fast on either side. Taking on one more voucher with vega ν_i changes the penalty by:

   ½·γ_ν·(ν_P + ν_i)² − ½·γ_ν·ν_P²  =  γ_ν·ν_P·ν_i  +  ½·γ_ν·ν_i²  ≈  γ_ν·ν_P·ν_i
   (the second part is tiny for one voucher)

   so the desk values voucher i at  fair − γ_ν·ν_P·ν_i
   example: γ_ν 0.0002, desk long 2,000 vega, the 70k call ν 63.28:
            0.0002 · 2,000 · 63.28 = $25.3 lower on both bid and ask

It is the same idea as W3: the cost of one more unit is the slope of the discomfort, and the slope of a bowl grows with how far up the side you already are.

W9 · The hedge band (Whalley–Wilmott)

Two costs pull the band H in opposite directions. Write each one as “dollars per unit of time”, then find the bottom of the valley (tool 2, upside down).

Step 1: how fast delta wanders. BTC moves by S·σ per √year, and each $1 of move changes delta by Γ. So delta is a random walker (W1) with variance Γ²·S²σ² per year.

Step 2: the cost of trips. A walker kept inside a fence ±H by pushing it back at the edge needs pushing at a rate of (its variance per year) / (2H). Each BTC pushed costs λ·S:

   trip cost per year  =  λ·S · Γ²S²σ² / (2H)             wider band → fewer trips

Step 3: the cost of risk. Inside the band the desk is off by x, spread evenly between −H and +H, so the average of x² is H²/3. Being off by x BTC wobbles the PnL with variance x²·S²σ² per year, and a nervous desk charges (γ/2) per unit of variance (W3 step 1):

   risk cost per year  =  (γ/2) · (H²/3) · S²σ²  =  γ·S²σ²·H² / 6          wider band → more risk

Step 4: add, take the slope, set to 0.

   total  =  λ·S·Γ²S²σ²/(2H)  +  γ·S²σ²·H²/6

   slope  = −λ·S·Γ²S²σ²/(2H²)  +  γ·S²σ²·H/3  =  0          rule xⁿ: 1/H → −1/H²,  H² → 2H
            S²σ² is in both parts and cancels (the jumpiness does not matter!)
            H³ = 3·λ·S·Γ² / (2γ)
            H  = ( 3·λ·S·Γ² / (2γ) )^(1/3)                             ✓ the formula of §7

   check:  λ 5 bp, S 64,000, Γ = 10 contracts · 0.00003685, γ 0.0001
           H = (3 · 0.0005 · 64,000 · (0.0003685)² / 0.0002)^(1/3) = 0.40 BTC

And why hedge only back to the edge? Trading costs grow with every BTC traded. Going all the way to zero trades more now, and the walker will wander back out anyway.

W10 · What part 2 did not derive

Being honest about the edges:

   exact c₂ (GLFT)          needs the HJB equation for a never-ending day; W3 gets within 0.2 %
   Φ itself                 no pencil formula exists; the code uses a fast series (ncdf in quant.ts)
   the ladder sizes z0·ρⁱ   a design choice, not a result: more size where fills are rarer and better
   cW, cT, hedge fee        rules of thumb for "we are less sure here"
   the bell-curve model     real BTC has fatter tails; the volatility smile (strategy.md §5.3) patches it

Symbols in plain words

bpbasis point0.01 %. On one BTC at $64,000, 1 bp = $6.40
bid / askbuy price / sell pricethe two prices on the windscreen
h, half-spreadmarkupdistance from fair to one of our prices
q, inventorycars on the lot+ we hold BTC, − we owe it
Δ, deltatotal exposure to BTCspot + perp + what the options behave like
γ, gamma (quotes)nervousnesshow much a position pushes our prices
kpickinesshow fast customers vanish as the price moves away from fair
Awalk-insfills per second at fair
σ, volatilityjumpinessa typical yearly move, as a %
AS, markoutlemonshow far the price moved against us 10 s after a fill
VPINone-way-ness0 = buyers and sellers balance, 1 = all one way
r × cauction costshare of volume we must hedge × what hedging costs
strike Klocked pricethe price written on the voucher
call / putright to buy / right to sellat the strike, until expiry
IV, implied volpriced-in jumpinessthe volatility that makes the formula give the market price
Γ, gamma (options)how fast delta changesbig near the strike and near expiry
ν, vegajumpiness exposure$ gained per 1 point more volatility
Θ, thetatime decay$ an option loses per day if nothing happens
MMPcircuit breakertoo many option fills too fast → pull all option quotes
bandwhen to go to the auctionthe desk hedges only when delta passes it

The full maths is in marketmaker/doc/strategy.md; the money question in plan.md §3–4. This page and those documents describe the same formulas.