Quantitative Finance · Book 18 · Careers

Interviews I: Maths, Probability and Speed

Interviews I: Maths, Probability and Speed · Careers

5Estimation

Getting within a factor of two or three with no data: break the quantity into pieces you can bound, say the interval as well as the number, and check it by a second route. The later questions test claims about markets and systems, where a good estimate shows that something cannot be true. Assumptions you must make are yours; any number the stem gives is exact.

Question 5.1 ★ QT, Trader, Analyst, QD, Risk • any • junior

Roughly how many seconds are there in a year? How many of them fall in trading hours, for a market open 6.56.5 hours a day on 252 days a year?

Answer

Answer to Question 5.1.

A year has about 3.16×1073.16 \times 10^7 seconds, which is close to π×107\pi \times 10^7. Trading hours hold about 5.95.9 million of them.

The year is 365.25⋅86 400=31 557 600365.25 \cdot 86\,400 = 31\,557\,600 seconds. The shortcut π×107\pi \times 10^7 is within half a percent, and it is worth memorising. A trading year is 252⋅6.5⋅3600=5 896 800252 \cdot 6.5 \cdot 3600 = 5\,896\,800 seconds, so the market is open for about 18.7%18.7\% of the time, a little less than a fifth.

Follow-up. How many trading minutes in a year? 252⋅390=98 280252 \cdot 390 = 98\,280, or about 100 000100\,000.

Why it matters. Annualising intraday figures needs the trading clock. A rate of one event per trading second is about six million events a year, not thirty million.

Question 5.2 ★ QT, Trader, Analyst • any • junior

A swimming pool is 50 metres long, 25 metres wide and 2 metres deep. Roughly how long would it take to fill with a single garden hose? Give an interval as well as a number.

Answer

Answer to Question 5.2.

About three months, with an interval from six weeks to six months.

The pool holds 50⋅25⋅2=250050 \cdot 25 \cdot 2 = 2500 cubic metres. A garden hose fills a 10-litre bucket in about 30 seconds, which is 20 litres a minute, or 1.21.2 cubic metres an hour. So the pool takes 2500/1.2≈20832500/1.2 \approx 2083 hours, or 87 days running without pause.

The volume is exact, so the whole uncertainty lies in the flow. Between 10 and 40 litres a minute, a factor of two each way, the time runs from 174 days down to 43.

Classic wrong answer. “It would take a few days.” Nobody has a feel for 2 500 cubic metres. That is why you turn it into litres, and the hose into a bucket you can picture filling.

Question 5.3 ★ QD, Dev, LLE • any • junior

An exchange numbers its orders with a counter and receives one million orders per second, without pause. How long until an unsigned 32-bit counter runs out? And a 64-bit one? If the counter resets each day and the market is open 6.56.5 hours, how many bits does it need?

Answer

Answer to Question 5.3.

A 32-bit counter lasts about 72 minutes, a 64-bit one lasts about 585 000 years, and a daily reset needs 35 bits.

The first is 232/106≈42952^{32}/10^6 \approx 4295 seconds, using 210≈1032^{10} \approx 10^3 to get 4×1094 \times 10^9 at once. The second is 264/106≈1.8×10132^{64}/10^6 \approx 1.8 \times 10^{13} seconds, and a year is about π×107\pi \times 10^7 seconds. A day holds 6.5⋅3600⋅106=2.34×10106.5 \cdot 3600 \cdot 10^6 = 2.34 \times 10^{10} orders, which lies between 234≈1.7×10102^{34} \approx 1.7 \times 10^{10} and 235≈3.4×10102^{35} \approx 3.4 \times 10^{10}. So 35 bits suffice.

Why it matters. Thirty-two bits looks plentiful until a busy day. A counter that overflows at an hour and a quarter fails in production, not in a test with a small sample. Choose the width by this sum, and leave room for the rate to grow.

Question 5.4 ★ QT, Trader, Analyst, Risk • any • junior

Someone tells you a stock moves about 5% on a typical day and has a volatility of 20% a year. Volatility here means the standard deviation of returns, and there are 252 trading days in a year. Can both statements be true?

Answer

Answer to Question 5.4.

Not if days are independent: 5% a day scales to about 79% a year, and 20% a year is only about 1.3%1.3\% a day.

With independent days, variances add, so volatility scales with the square root of time. The shortcut is 252≈16\sqrt{252} \approx 16. Either 5%⋅16≈80%5\% \cdot 16 \approx 80\% a year, or 20%/16≈1.25%20\%/16 \approx 1.25\% a day.

For both statements to hold, the daily moves would have to cancel almost completely. The actual yearly variance would be only (20/79.4)2≈6.3%(20/79.4)^2 \approx 6.3\% of what independent days give, and that would need extreme mean reversion.

Follow-up. Could a few violent days reconcile them? They can make the average misleading. With 248 days at 1% and 4 earnings days at 5%, annual volatility is 248+4⋅25≈18.7%\sqrt{248 + 4 \cdot 25} \approx 18.7\%, so 5% moves can occur. But then 5% is not a typical day.

Question 5.5 ★ QT, QD, Dev, LLE • market maker, hedge fund • junior

Two cities are 1 200 km apart. Light travels at about 300 000 km per second in air and at about two-thirds of that in glass fibre. What is the one-way delay along a straight fibre, and what could a straight radio link save? How far does a signal in fibre travel in one nanosecond?

Answer

Answer to Question 5.5.

The fibre takes 6 milliseconds one way, a straight radio link takes 4, and a signal in fibre covers 20 centimetres per nanosecond.

Fibre runs at 200 000200\,000 km per second, so 1200/200 0001200/200\,000 seconds is 6 ms. Radio through air takes 1200/300 0001200/300\,000 seconds, or 4 ms, which saves up to 2 ms each way. In air the signal covers about 30 cm in a nanosecond.

A real fibre route is longer than the straight line, so the true saving is larger. A radio link is less reliable and carries less data, which is why both are used.

Why it matters. This is the floor under any two-city trade: no software or hardware beats it. Within a building, 20 cm per nanosecond means a few metres of extra cable costs 10 to 20 nanoseconds, which can use up a hard-won software saving.

Question 5.6 ★ QD, Dev, LLE, Analyst • any • junior

A server draws 500 watts all year. Electricity costs 10 cents per kilowatt-hour, and cooling and other overheads in the building add 50% to the power used. What does a year of power cost? If the server costs $10 000 and lasts four years, what share of its yearly cost is power?

Answer

Answer to Question 5.6.

Power costs about $657 a year, which is about a fifth of the server’s yearly cost.

A year holds about 8 760 hours, so 0.50.5 kW draws 43804380 kWh, which costs $438 at 10 cents. The building’s overhead makes that 1.5⋅438=$6571.5 \cdot 438 = \$657. The machine costs 10 000/4=$250010\,000/4 = \$2500 a year, so power is 657/(2500+657)≈21%657/(2500 + 657) \approx 21\% of the total.

Classic wrong answer. Forgetting the overhead, or dividing by the machine cost alone. A share is a part over the whole, so the power belongs in both places.

Why it matters. When someone offers to save 10% of a server’s power, this tells you the saving is about 2% of the bill, before any change in the rate of failure or rack space.

Question 5.7 ★ QT, Trader, Analyst • any • junior

About 200 000 tonnes of gold have been mined in all of history. Gold has a density of 19.319.3 grams per cubic centimetre, and a troy ounce is 31.131.1 grams. If all of it were cast as one cube, how long would its side be? At $3 000 an ounce, what is the cube worth?

Answer

Answer to Question 5.7.

The cube has a side of about 22 metres, and it is worth about $19 trillion.

Density is 19 30019\,300 kg per cubic metre, so 2×1082 \times 10^8 kg fills about 10 36010\,360 cubic metres. Since 223=10 64822^3 = 10\,648, the side is about 21.821.8 metres. In ounces, 2×1011/31.1≈6.43×1092 \times 10^{11}/31.1 \approx 6.43 \times 10^9, which at $3 000 gives about $19.319.3 trillion.

Follow-up. Per person, with 8 billion people? About 25 grams each, which is less than one ounce.

Why it matters. The size is the surprise: all that value would fit in a modest building. That is a good habit in sizing, since a figure that sounds huge may be small once it is put into units that you can see.

Question 5.8 ★★ QT, Trader, Analyst • any • junior

Estimate the number of hairdressers and barbers working in a city of one million people. Give a central figure, an interval, and one check that does not use the same reasoning.

Answer

Answer to Question 5.8.

About 2 400, with an interval from 1 000 to about 7 000.

Work from demand. One million people, each with about 6 cuts a year, means 6 million cuts. A hairdresser does about one cut every 45 minutes, so around 10 cuts in a day, on about 250 days: 2 500 cuts a year. Dividing gives 2 400.

For the interval, push both inputs together. At 4 cuts a year and 4 000 cuts per worker you get 1 000. At 10 cuts a year and 1 500 cuts per worker you get about 6 700. Their geometric mean is about 2 600, close to the central figure, which is a good sign that the two ends are balanced.

The check uses experience of a street, not of a haircut. The central figure means one worker for each 400 people. A neighbourhood of 2 000 people would then have five workers, one or two salons, and that looks about right.

Classic wrong answer. Giving one number. The interviewer wants to see which inputs you are unsure of, and that you know the width of the answer.

Question 5.9 ★★ QT, Trader, Analyst • any • junior

A school bus measures about 12 metres by 2.52.5 metres by 2 metres inside, and a golf ball is about 4.34.3 centimetres across. How many golf balls would fit in the bus? Reach your answer by two routes.

Answer

Answer to Question 5.9.

About 650 000, and the two routes give about 690 000 and 600 000. An interval of 500 000 to 800 000 is fair.

Seats and fittings take about a fifth of the 12⋅2.5⋅2=6012 \cdot 2.5 \cdot 2 = 60 cubic metres, which leaves 48.

Route one uses volume. A ball of radius 2.152.15 cm has a volume 43πr3≈41.6\tfrac43 \pi r^3 \approx 41.6 cubic centimetres. Spheres poured at random fill about 60% of a space, so the count is 48⋅0.6/(41.6×10−6)≈692 00048 \cdot 0.6/(41.6 \times 10^{-6}) \approx 692\,000.

Route two stacks them in a cubic grid: every ball owns a cube of side 4.34.3 cm, or 79.579.5 cubic centimetres, and 48/(79.5×10−6)≈604 00048/(79.5 \times 10^{-6}) \approx 604\,000. A grid fills only π/6≈52%\pi/6 \approx 52\% of the space, which is why this is lower.

Classic wrong answer. Dividing the volume of the bus by the volume of a ball and ignoring the gaps. That overstates it by more than half. Even the densest possible packing fills only 74%, which caps the answer below a million.

Question 5.10 ★★ QT, Trader, Analyst • any • junior

Estimate how many people in the world are in the air on commercial flights right now. Use one estimate built from passengers and another built from aircraft, and say how far they differ.

Answer

Answer to Question 5.10.

About a million and a quarter, with an interval from about half a million to 2.52.5 million. The two routes differ by about 20%.

Route one uses passengers. With 8 billion people taking half a flight each a year on average, there are 4 billion passenger flights. At about 2.52.5 hours each, that is 101010^{10} passenger-hours in the 87608760 hours of a year, so 1.141.14 million people are in the air at an average moment.

Route two uses aircraft. With about 25 000 airliners, each flying 10 hours in 24, about 10 40010\,400 are aloft at any moment. At about 130 passengers each, that is 1.351.35 million.

The agreement is what gives you confidence, because the routes share no input. The result means that about one person in 7 000 is flying now. Averages hide a daily pattern, so the moment you ask may be somewhat above or below.

Why it matters. Two independent routes reveal a mistaken input. If they had differed by a factor of ten, you would know that one of them is wrong, and that is more useful than a single confident number.

Question 5.11 ★★ QT, Trader, Analyst • any • junior

Estimate the number of petrol stations in a country of 300 million people, where most adults drive. Check the result from the supply side, by asking whether a typical station could survive on what your number implies.

Answer

Answer to Question 5.11.

About 100 000, with an interval from 50 000 to 200 000.

Start from demand. Of 300 million people, take 200 million cars. If each fills up about every 10 days, that is 20 million fills a day. A station with 8 pumps sees about 200 fills a day, or one every five minutes through a long day, so the country needs 20 000 000/200=100 00020\,000\,000/200 = 100\,000 stations. Between 400 and 100 fills a day, the count is 50 000 to 200 000.

Now check it from the supply side. That number means one station for every 3 000 people. A station earns on each fill: at 40 litres and 5 cents of margin per litre, each fill brings $2, or $400 a day, or about $146 000 a year. That pays for a couple of workers on the site, and the shop adds more. So a station at 200 fills a day just about survives, and this suggests that the number cannot be much higher.

Why it matters. Supply and demand give different kinds of check. The demand side tells you what is needed, and the supply side tells you what can stay in business, and a real business has to pass both.

Question 5.12 ★★ QR, QT, Risk, DS • any • junior, experienced

You estimate a quantity as a product of four independent factors, and for each factor your 90% interval runs from half your guess to twice your guess. What is your 90% interval for the product? Why is the answer not “from one sixteenth to sixteen times”? When would it be?

Answer

Answer to Question 5.12.

From a quarter of your guess to four times it, when the factors are independent and the errors are normal in logarithms.

Take logarithms. A product of independent factors becomes a sum of independent errors, and in a sum variances add, so widths grow as the square root of the number of terms. A 90% interval of a factor of 2 is ±ln⁡2\pm \ln 2 in logs, and so σ=ln⁡2/1.645≈0.42\sigma = \ln 2/1.645 \approx 0.42. With four factors the width doubles, to ±2ln⁡2=±ln⁡4\pm 2 \ln 2 = \pm \ln 4. With nine it would triple, to a factor of 8.

Sixteen is what you get only if all four errors go the same way at once, as they do if the factors are perfectly correlated, because a single mistake drives them all. For independent factors, the interval from one sixteenth to sixteen would hold about 99.9% of outcomes.

Follow-up. Where is the mean of the product, compared with the central guess? Above it. A lognormal’s mean is its median times eσ2/2e^{\sigma^2/2}, with σ=0.84\sigma = 0.84 here, so about 1.431.43 times. A central Fermi figure is a median, and it understates an average.

Why it matters. Breaking a quantity into many pieces is what makes Fermi estimates work: independent errors partly cancel. But it works only if the pieces do not share one assumption.

Question 5.13 ★★ QT, Trader, QD, LLE • market maker, hedge fund • junior

A stock market has a total value of $60 trillion, and each share changes hands about twice a year. An average trade is worth $20 000. The market is open 6.56.5 hours a day on 252 days a year. How many trades happen per second? If each trade comes with 30 order messages, and peaks run at 20 times the average, what bandwidth does a 40-byte message need at the peak?

Answer

Answer to Question 5.13.

About 1 000 trades per second. At peak the feed is about 610 000 messages per second, or about 200 megabits per second.

The daily traded value is 60×1012⋅2/252≈$47660 \times 10^{12} \cdot 2/252 \approx \$476 billion. Dividing by $20 000 gives about 23.823.8 million trades a day. A trading day has 6.5⋅3600=23 4006.5 \cdot 3600 = 23\,400 seconds, so that is about 1 020 trades a second.

With 30 messages a trade, the average is about 30 50030\,500 messages a second, and 20 times that is 610 000610\,000. At 40 bytes each that is 24.424.4 million bytes a second, or 195195 megabits a second.

Classic wrong answer. Sizing a system for the average. Message rates cluster heavily around the open, the close and news, and a design that copes with the average falls behind exactly when the data matter most.

Why it matters. A figure of this kind tells you at once which hardware you need: a 1-gigabit link has room to spare here, but only until you add more venues.

Question 5.14 ★★ QT, Trader, Analyst • market maker • junior

A market trades 10 billion shares a day on 252 days a year. A market maker is on one side of 5% of those shares and keeps, after all costs of trading, between 0.050.05 and 0.20.2 cents per share. Estimate its yearly trading revenue, with an interval. The spread on most of these stocks is 1 cent: what does your central figure imply about how much of the half-spread it keeps?

Answer

Answer to Question 5.14.

About $126 million a year, with an interval of $63 million to $252 million. The central figure means it keeps about a fifth of the half-spread.

Five percent of 10 billion is 500 million shares a day. At 0.10.1 cents, which is the geometric middle of 0.050.05 and 0.20.2, each day brings $500 000, and over 252 days that is $126 million. The ends scale directly with the cents kept.

The half-spread is 0.50.5 cents, which is what a market maker earns if it trades at its quote and the price then stays put. Keeping 0.10.1 cents means that about 0.40.4 cents is lost to adverse selection, fees and the cost of holding the position.

Why it matters. Market-making revenue looks enormous in shares and thin per share. The spread is not the profit: most of it pays for being on the wrong side of informed traders.

Question 5.15 ★★ QD, Dev, LLE, DS • market maker, hedge fund • junior

You store every quote update for 5 000 stocks, with an average of 10 updates per second per stock over a 6.56.5-hour day, on 252 days a year. Each update is 40 bytes, and compression reduces the data by a factor of 5. How much storage does a year need? How long does it take to read one uncompressed day at a gigabyte per second?

Answer

Answer to Question 5.15.

About 11.811.8 terabytes a year uncompressed, or about 2.42.4 terabytes compressed. One uncompressed day takes about 47 seconds to read.

A day has 5000⋅10⋅6.5⋅3600=1.17×1095000 \cdot 10 \cdot 6.5 \cdot 3600 = 1.17 \times 10^9 updates. At 40 bytes each that is 46.846.8 gigabytes. Over 252 days it comes to 11.811.8 terabytes, and dividing by 5 gives 2.362.36 terabytes. At one gigabyte a second, 46.846.8 gigabytes takes about 47 seconds.

The average hides skew: a few hundred active names produce most of the updates, so a busy stock holds many times its 1/50001/5000 share of the day, about 9 milliseconds of reading, and a quiet one far less. Either way, reading one stock alone is far quicker than scanning the whole day, if the file layout lets you.

Why it matters. The bottleneck in research is rarely the disk space for a year. It is the time to scan many days, and that is why tick stores partition by date and symbol.

Question 5.16 ★★ QR, QD, Dev, DS • hedge fund, bank • junior

A backtest reads one-minute bars for 5 000 stocks over 20 years, with 252 days a year and 390 minutes a day. Each bar is 40 bytes. You can read data from disk at 1 gigabyte per second, and processing one bar takes 1 microsecond on one core. How long does a run take on one core? And on 16 cores? What limits you then?

Answer

Answer to Question 5.16.

About 2.72.7 hours on one core and about 10 minutes on 16 cores, at which point the 6.5-minute disk read is close to binding.

The bars number 5000⋅252⋅20⋅390≈9.83×1095000 \cdot 252 \cdot 20 \cdot 390 \approx 9.83 \times 10^9. At 40 bytes each that is 393 gigabytes, so reading takes 393 seconds, or about 6.556.55 minutes, whatever the number of cores. Processing at 1 microsecond a bar takes 9 828 seconds, or 2.732.73 hours, on one core.

The two run together, so on one core processing is by far the limit. On 16 cores the processing takes 614 seconds, still slower than the disk. They become equal at 9828/393=259828/393 = 25 cores, and past that more cores do nothing. You need a faster disk, or to read less data.

Why it matters. The useful result is the ratio, not the 2.72.7 hours. Know which resource binds before spending money: at 25 cores, more cores buy nothing, and storing the data by column, so that a run reads a tenth of it, helps everyone.

Question 5.17 ★★ QT, Trader, Analyst, Risk • market maker, hedge fund, bank • junior

Every trade has one side crossing the spread and one side resting on the book. A stock market trades $500 billion a day, on 252 days a year, at an average quoted spread of 2 basis points (hundredths of a percent). Estimate what investors pay in spread each year. What is that against a total market value of $60 trillion?

Answer

Answer to Question 5.17.

About $12.612.6 billion a year, which is about 2.12.1 basis points of the market’s value.

Each trade has one side crossing the spread, and that side pays half of the quoted spread compared with the mid-price, 1 basis point here. So the daily toll is 500×109⋅10−4=$50500 \times 10^9 \cdot 10^{-4} = \$50 million, and over 252 days that is $12.612.6 billion. Against $60 trillion, the total market value, it is 2.12.1 basis points a year.

Classic wrong answer. Charging the full spread, which gives $25.225.2 billion. A taker pays half the spread against the mid-price, and paying the full spread would need the same party to buy and then sell. Another mistake is to charge both sides of each trade: the resting side earns what the crossing side pays.

Why it matters. That is a useful ceiling on what spread-capturing businesses can share between them, before impact and adverse selection. It also shows how small the toll is for a long-term holder.

Question 5.18 ★★ QT, Trader, Analyst, Risk • hedge fund, market maker • junior

A candidate says their strategy made $1 million a day trading a single stock. That stock trades $100 million a day and has a daily volatility of 2%. Without any more detail, is that plausible? Show the figure that decides it.

Answer

Answer to Question 5.18.

No. It implies 1% of the stock’s whole traded value every day, which is far more than any plausible edge.

The deciding figure is profit over volume: $1\$1 million over $100 million is 100 basis points on every dollar traded by anyone that day, even if the strategy did all of the trading. A realistic share of 10% means $10 million traded, so it earns 10% per dollar traded. That is five times the stock’s daily standard deviation of 2%, every day.

Even one day like that is a large outlier, and doing so every day with no losses cannot be skill in the ordinary sense. It suggests a stale mark, a data error, an unrealistic fill model or a misattribution.

Follow-up. What would you ask next? How the fills were modelled, whether the P&L was marked at prices at which you could really trade, and what the position size was at the close. These find the error faster than any argument about the signal.

Why it matters. Dividing profit by volume is the fastest check on a track record, and it needs no details of the strategy.

Question 5.19 ★★★ QR, QT, Trader • any • junior, experienced

Estimate how many molecules from Julius Caesar’s last breath are in the breath you just took. Assume that a breath is half a litre, a mole of gas occupies 24 litres at room conditions, Avogadro’s number is 6×10236 \times 10^{23}, air has a molar mass of 29 grams, surface pressure is 10510^5 pascals, gravity is 10 m/s210\ \mathrm{m/s^2}, the Earth’s radius is 6 400 km, and that those molecules have since spread evenly through the atmosphere. What is the chance your breath contains at least one?

Answer

Answer to Question 5.19.

About 1.51.5 molecules on average, so the chance of at least one is about 77%.

First the atmosphere. Pressure is the weight of the air above a square metre, so each square metre carries 105/10=10410^5/10 = 10^4 kg. The Earth’s surface is 4πR2≈5.15×10144\pi R^2 \approx 5.15 \times 10^{14} square metres, so the atmosphere weighs about 5.15×10185.15 \times 10^{18} kg. At 29 grams a mole that is about 1.77×10201.77 \times 10^{20} moles, or about 1.06×10441.06 \times 10^{44} molecules.

A breath is 0.5/24≈0.02080.5/24 \approx 0.0208 moles, or n≈1.25×1022n \approx 1.25 \times 10^{22} molecules. Caesar’s breath, mixed evenly, is a share n/Nn/N of the atmosphere, and each of your nn molecules has that chance of being his, so the mean is n2/N≈1.46n^2/N \approx 1.46.

The count is a sum of many very rare independent events, so it is Poisson, and P(at least one)=1−e−1.46≈0.77P(\text{at least one}) = 1 - e^{-1.46} \approx 0.77.

Classic wrong answer. Assuming the answer must be tiny, or vast, since one breath is so small and the air so large. The two huge numbers nearly cancel: nn appears squared, and n2n^2 happens to be close to NN.

Follow-up. What assumption is weakest? Even mixing, and that the molecules survive unchanged. Over 2 000 years air mixes well, but much of the carbon dioxide and some of the oxygen are taken up and replaced. Nitrogen is the most stable part, so the estimate is an upper end.

Question 5.20 ★★★ QR, QT, Trader, QD • any • junior, experienced

By hand, estimate the number of orderings of a 52-card deck. Compare it with the number of atoms in the Earth, whose mass is 6×10246 \times 10^{24} kg, taking 30 grams per mole of atoms and Avogadro’s number as 6×10236 \times 10^{23}. If a machine checked 10910^9 orderings a second since the Big Bang, 4.4×10174.4 \times 10^{17} seconds ago, how many would it have seen? How many random shuffles give an even chance that two of them match?

Answer

Answer to Question 5.20.

52!52! is about 8×10678 \times 10^{67}, about 7×10177 \times 10^{17} times the number of atoms in the Earth. The machine would have seen 4.4×10264.4 \times 10^{26} orderings, and an even chance of a match needs about 103410^{34} shuffles.

Use Stirling’s formula: ln⁡n!≈nln⁡n−n+12ln⁡(2πn)\ln n! \approx n \ln n - n + \tfrac12 \ln(2\pi n). Here 52ln⁡52≈205.552 \ln 52 \approx 205.5; subtract 52 and add 2.92.9 to get 156.4156.4. Dividing by ln⁡10≈2.303\ln 10 \approx 2.303 gives 67.967.9, so 52!≈8×106752! \approx 8 \times 10^{67}. The rough form nln⁡n−nn \ln n - n alone gives 66.6, which shows why the last term matters at this precision.

The Earth holds 6×10276 \times 10^{27} grams, or 2×10262 \times 10^{26} moles of atoms, or 1.2×10501.2 \times 10^{50} atoms. The ratio is about 6.7×10176.7 \times 10^{17}. The machine has checked 109⋅4.4×1017=4.4×102610^9 \cdot 4.4 \times 10^{17} = 4.4 \times 10^{26} orderings, leaving a factor of 1.8×10411.8 \times 10^{41}.

For a match, use the birthday estimate. With kk shuffles there are about k2/2k^2/2 pairs, each matching with chance 1/52!1/52!, so an even chance needs k≈2ln⁡2⋅52!≈1.06×1034k \approx \sqrt{2 \ln 2 \cdot 52!} \approx 1.06 \times 10^{34}.

Why it matters. This is why randomised identifiers with enough bits are safe in practice: the square root in the birthday count is what sets the size, so 128 bits are comfortable where 64 are not.

Question 5.21 ★★★ QR, QT, Trader, Risk, DS • hedge fund, market maker • junior, experienced

You give 90% intervals for ten unrelated quantities, and only five contain the truth. If your intervals really were 90% intervals, how unlikely is a score of five or fewer? Treating your errors as normal in logarithms, by what factor should you widen your intervals? Say what an interval of “within a factor of 3” should become.

Answer

Answer to Question 5.21.

Five or fewer has a chance of about 0.16%0.16\%. Widen intervals by about 2.442.44 times in logarithms, so “within a factor of 3” should become “within a factor of about 15”.

The score is binomial with n=10n = 10 and p=0.9p = 0.9, and P(X≤5)≈0.00163P(X \le 5) \approx 0.00163. So you are not unlucky: your intervals are too narrow. Even with so few, an exact 95% interval for your real coverage runs from about 19% to 81%, and it does not reach 90%.

For the scale, say your errors in logarithms are normal with true standard deviation σ\sigma. A real 90% interval is ±1.645σ\pm 1.645\sigma. You covered about 50%, which is ±0.674σ\pm 0.674\sigma. So what you called 1.6451.645 of your assumed σ\sigma is really 0.6740.674 of the true one, and the ratio is 1.645/0.674≈2.441.645/0.674 \approx 2.44. A factor of 3 is ln⁡3\ln 3 in logs, and e2.44ln⁡3≈14.6e^{2.44 \ln 3} \approx 14.6.

Classic wrong answer. Widening by the ratio of coverages, 90/5090/50. Coverage is not linear in width, because the tails of a normal are thin, so a good deal of extra width is needed to catch the last 40%.

Why it matters. Overconfidence is the usual result on this kind of quiz, and interviewers who ask for an interval are watching for it. On a desk, this calibration is what sets position limits: being wrong outside your interval half of the time is a risk problem.

Question 5.22 ★★★ QR, QT, Risk • bank, hedge fund • junior, experienced

An index has a daily volatility of 1% and returns with mean zero. If returns were normal, what is the largest one-day move you would expect in 100 years of 252 trading days? What does the same calculation give if returns follow a Student tt distribution with 3 degrees of freedom, scaled to the same volatility? What do you conclude from a one-day fall of about 20%?

Answer

Answer to Question 5.22.

About 4.1%4.1\% if normal, and about 22% under the Student tt with 3 degrees of freedom. A fall of about 20% rejects the normal model, and it is not surprising under the fat-tailed one.

There are 25 20025\,200 days, so look for the move exceeded on one of them, which is a two-sided tail of 1/25 2001/25\,200. For a normal, P(∣Z∣>z)=1/25 200P(|Z| > z) = 1/25\,200 gives z≈4.11z \approx 4.11, or 4.1%4.1\%.

A tt with 3 degrees of freedom has variance 3, so it must be scaled by 1/31/\sqrt{3} to have a daily volatility of 1%. Its tail falls only as a power, and the same tail point sits at about 22%. The median of the 100-year maximum is a little higher, about 4.2%4.2\% and about 25%, since it sits at a tail of ln⁡2/25 200\ln 2/25\,200.

A fall of 20 standard deviations under a normal has a chance of about 3×10−893 \times 10^{-89} a day, which is a wait of about 108610^{86} years. Yet the Dow Jones Industrial Average fell 22.6%22.6\% in one session in October 1987, so that model must be the one to go.

Why it matters. Estimates from a normal model look precise and can be wrong by a factor of five in the tail, where the capital is needed. Ask for the tail assumption whenever someone quotes a worst case.

Question 5.23 ★★★ QR, QT, Trader, Analyst • hedge fund • junior, experienced

A long-short equity strategy trades 1 000 stocks, each with a daily traded value of $50 million, and you will not exceed 5% of any stock’s daily value. Each position is held for 5 days, and the book is kept full, so every day you close a fifth of it and open a new fifth. How large can the book be, counting longs plus shorts? If each dollar traded earns 5 basis points after costs, what does the strategy make in a year of 252 days, and what is that as a return on the book?

Answer

Answer to Question 5.23.

The book can be $6.256.25 billion. It makes about $315 million a year, or about 5% on the book.

The daily limit on trading is 1000⋅50×106⋅5%=$2.51000 \cdot 50 \times 10^6 \cdot 5\% = \$2.5 billion. Now count the trading carefully. To keep a book of size GG with a holding period of 5 days, each day you close G/5G/5 and open another G/5G/5, so you trade 2G/52G/5 a day. Setting 2G/5=2.52G/5 = 2.5 billion gives G=6.25G = 6.25 billion.

The turnover is 2.52.5 billion a day, or $630 billion a year. At 5 basis points on each dollar traded, that is $315 million, or 5.04%5.04\% on $6.256.25 billion.

Classic wrong answer. Multiplying the daily limit by the holding period to get $12.512.5 billion. That counts only the opening side. A position has to be closed too, and each of those trades uses the same volume budget.

Follow-up. Without changing the signal, what is the simplest way to raise capacity? Hold for longer, if the signal lasts. With a 10-day holding period the same trading supports twice the book, although the return per dollar of the book falls unless the signal grows in step.

Why it matters. Capacity is usually decided by this sum, not by the model. Investors ask for it early, because 5% participation at five days is a statement about how large the fund can ever be.

Question 5.24 ★★★ QD, Dev, LLE, QT • market maker, hedge fund • junior, experienced

A program handles market data messages one at a time, in order of arrival, and each takes exactly 0.80.8 microseconds. Messages arrive at random, as a Poisson process, at one million per second. Estimate the average wait in the queue before handling starts. Now a burst arrives at a steady 1.51.5 million per second for 1 millisecond, after which arrivals fall to a steady 0.50.5 million per second. How long is the queue when the burst ends, and how long until it is empty?

Answer

Answer to Question 5.24.

The average wait is 1.61.6 microseconds. The burst ends with a queue of 250 messages, and it empties about 333 microseconds later.

The handler’s capacity is 1/0.8=1.251/0.8 = 1.25 messages a microsecond, so its load is ρ=0.8\rho = 0.8. With random arrivals and a fixed service time, the queue is an M/D/1 queue, and the Pollaczek-Khinchine formula gives

W=ρ s2(1−ρ)=0.8⋅0.82⋅0.2=1.6.W = \frac{\rho\, s}{2(1 - \rho)} = \frac{0.8 \cdot 0.8}{2 \cdot 0.2} = 1.6.

Total time in the system is 2.42.4 microseconds. If the service times were exponential the wait would double to 3.23.2. The term 1/(1−ρ)1/(1 - \rho) is the warning: at 90% load the wait is more than double.

During the burst, the excess is 1.5−1.25=0.251.5 - 1.25 = 0.25 messages a microsecond for 1 000 microseconds, or 250 messages, which is a delay of 200 microseconds. Afterwards the queue shrinks at 1.25−0.5=0.751.25 - 0.5 = 0.75 a microsecond, so it empties in 250/0.75≈333250/0.75 \approx 333 microseconds. In other words, a burst of 1 ms hurts for about 1.31.3 ms.

Why it matters. Average load hides this risk. A handler at 40% average load can still fall 200 microseconds behind in a burst, just as the market moves. Size for the burst, not for the average.

Question 5.25 ★★★★ QR, QT, Trader, Risk • hedge fund, market maker • experienced

A fund claims to return 30% a year on a $20 billion book of US stocks, counting longs plus shorts, while replacing the whole book every day, so that each day it closes $20 billion and opens $20 billion. The market trades $500 billion a day and daily volatility is 1.5%1.5\%. Assume the cost per dollar traded is σq\sigma\sqrt{q}, where σ\sigma is daily volatility and qq is the fund’s share of the day’s traded value. There are 252 days in a year. Is the claim believable? If the signal earns 10 basis points per dollar traded before costs, what book size maximises profit, and what does it earn then?

Answer

Answer to Question 5.25.

No: costs alone come to about 42 basis points per dollar traded, against about 6 of net profit claimed. With the 10-basis-point signal, the best book is about $490 million, earning about $83 million a year.

The fund trades 2⋅$202 \cdot \$20 billion a day, which is 8% of the market, so q=0.08q = 0.08, and the cost per dollar traded is σq=150⋅0.283≈42.4\sigma\sqrt{q} = 150 \cdot 0.283 \approx 42.4 basis points. The claim is 30% of $20 billion, or $6 billion a year. Spread over 252 days and $40 billion a day, that is about 5.955.95 basis points net. So the signal would have to earn about 4848 basis points on every dollar traded, every day, on a volume of about one-twelfth of the market. With a real signal of 10 basis points, this size loses about $130 million a day.

Now optimise. Profit per day, with qq as the fund’s share and VV the market’s value, is

π(q)=qV(a−σq),\pi(q) = qV\bigl(a - \sigma\sqrt{q}\bigr),

and setting the derivative to zero gives a=32σqa = \tfrac32\sigma\sqrt{q}, which is q∗=(2a/3σ)2≈0.00198q^* = (2a/3\sigma)^2 \approx 0.00198. So you trade about $988 million a day, on a book of about $494 million. A cost of two-thirds of the signal is the signature of the square-root law. The net is a/3≈3.33a/3 \approx 3.33 basis points, or about $329 000 a day and $83 million a year, about 17% on the book.

Classic wrong answer. Stopping when costs equal the signal. Profit is then zero: the optimum is well before that, where the marginal dollar breaks even but the average dollar still earns.

Why it matters. This is the check to apply to any large claim, and this result is why good signals support small books: return falls as the book grows, while dollar profit rises much more slowly.