Quant from Scratch by QuantWright

Introduction to Quant Finance · Lesson 3

What quants do

Pricing, research and trading, risk and development: the question each kind of work asks, who does it, and the loop most of it runs on.

Know the basics? Read the lesson notes

Two people, one chart

Two people look at the same price chart of one share. The price has risen five days in a row.

Person 1 (made up)“Five up days. It's on a run, so it will keep going.”
Person 2 (made up)“Over the last 20 years, after five up days, how often did it rise the next day, by how much on average, and was that more than it costs to trade?”

Which one is working the way a quant works?

Person 1 acted on a hunch that nothing can check. Person 2 turned the same hunch into a question past prices can answer.
Person 2 turned a hunch into a question past prices can answer: how often, how much, and whether it beats the cost of trading.
Both read the chart, but only person 2 asks something past prices can check: how often, how much, and whether it beats the cost of trading.
No one knows the next day. But you can measure what happened after past runs, and person 2 asks exactly that.

The answer is person 2. Quant is short for quantitative analyst: someone who uses numbers, statistics (methods for summing up data and judging what it shows) and computer code to make decisions about prices and risk. A quant doesn't need to know what happens tomorrow. The job is to measure what past data shows, say how sure that measurement is, and decide on it.

Four kinds of work

Quant jobs have many titles, but most of the work falls into four kinds. Each one answers its own question. Turn them over one at a time.

  1. Pricing: what is this contract worth?

    Banks sell contracts (agreements to pay or deliver something later) whose value depends on a price, such as an option: the right, but not the duty, to buy or sell something at a set price by a set date. A pricing quant works out a fair price for it, one neither side expects to gain from on average, using a model: a set of equations for how prices move.

They connect. Research finds a rule, development builds the system that runs it, risk sets how much it may lose, and pricing values the contracts it trades. At a small firm one person may do several of these; at a large one, each is a team.

Buy side and sell side

Finance splits firms into two sides. The sell side makes, sells and trades financial products for clients: mostly banks, on their trading desks (the teams that trade). The buy side invests money, its own or its clients'.

The situationA pension fund, which invests people's savings to pay their pensions, wants a contract that pays out if share prices fall. A bank's trading desk offers it one, at a price.

Which of the two is on the sell side?

The pension fund is the client, investing its members' savings, so it is on the buy side. The bank makes and sells the contract: the sell side.
They sit on opposite sides of the deal. The bank makes and sells the contract (sell side); the pension fund buys it to protect its savings (buy side).
The bank makes and sells the contract, so it is the sell side. The pension fund, investing its members' savings, is the buy side.
Each is on one side. The bank makes and sells the contract (sell side); the pension fund invests (buy side).

On the sell side, quants mostly price contracts like this one, measure the desk's risk and help it trade. On the buy side, they mostly look for patterns worth investing in and decide how much money goes where.

Who else hires quants

Some firms trade with no outside clients at all. Guess first: which of these trades only its own money?

“Proprietary” means “its own”: a proprietary trading firm trades only the firm's own money and has no outside clients.
An asset manager invests its clients' savings. A proprietary trading firm (“proprietary” means “its own”) trades only its own money.
A bank's desk trades with and for clients. A proprietary trading firm (“proprietary” means “its own”) trades only its own money.

The answer is the proprietary trading firm. So the employers of quants, by type:

  • banks, on the sell side: pricing, risk and trading desks;
  • firms that invest savings for clients (asset managers) and private funds for large investors (hedge funds), on the buy side: research and portfolio teams;
  • proprietary trading firms, some of them market makers: firms always ready to buy and to sell, earning the small gap between their two prices;
  • the exchanges and software companies that serve all of them.

Many smaller firms do the same work. A proprietary trading firm is not the same as the “prop firm” evaluations sold for a fee to individual traders (the Rules as risk limits lesson).

Whose job is it?

Six made-up tasks from a quant team's week. For each, pick the kind of work it belongs to. A wrong pick can be changed.

  1. Check whether a trading signal (a pattern that says when to trade) still pays after costs

    Research and trading: is this pattern worth acting on once trading costs are paid?

  2. Work out a fair price for an option a client wants to buy

    Pricing: what is this contract worth?

  3. Estimate how much the firm could lose on its worst day in 100

    Risk: how much could we lose on a bad day?

  4. Make a backtest run 10 times faster

    Development: the backtest is a system others rely on, and speed is part of building it.

  5. Check that a model's prices match the prices clients actually pay

    Pricing: checking the pricing model is part of pricing. It sounds like research, but the question is what contracts are worth.

  6. Set how much one trading desk may lose in a day

    Risk: limits on losses are the risk team's work.

All six placed.

Real jobs mix these: a researcher writes code, a developer checks prices. The four kinds are a map, not walls.

One loop

Whatever the kind, most quant work runs one loop of four stages. Tap them in the order you would do them.

The loop

The order: question, data, test, decision. Then the decision raises the next question.

If you took the first two lessons, you have run it twice. In Expectancy: does a strategy that wins 9 trades in 10 make money? The data were its win rate and the sizes of its wins and losses; the test, many simulated accounts; the decision, judge a strategy by its average result per trade, not by how often it wins. In Random walks, coin flips added up drew the same trends as price charts, so the decision was: a trend on its own is not evidence.

The other kinds run it too, with other questions. Pricing: does the model's price match prices clients actually pay? Risk: would today's limit have held on the worst past days? Development: is the new code faster, and does it give the same answers?

One made-up morning

Here is the loop on one task from the sorter. Question: does a trading signal still pay after costs? Data: its backtest, the trades the signal would have made in the past. R is a unit of money, the same on every trade, like €10: a win of +1.2R is €12.

The backtest (made up)400 trades: 200 wins of +1.2R each and 200 losses of −1.1R each. Every trade also costs 0.08R: the fee paid to the broker (the firm that places the trade) plus the gap between the price wanted and the price got.

Guess before the test: over the 400 trades, after costs, does it make money or lose it?

Keep your answer in mind. The test is on the next screen.

The test

The test adds up the 400 trades in the order they came: one line before costs, one after. Press play.

The made-up backtest, 400 trades

Running total in R. Upper line: before costs. Lower line: after costs of 0.08R a trade.

Trade0
Before costs0R
After costs0R

It loses money: −12R after costs, though it made +20R before them.

The reason is the one line from the Expectancy lesson: the average result per trade, called its expectancy, is the win rate (the share of trades that win) × the average win − the loss rate (the share that lose) × the average loss. Here 0.5 × 1.2R − 0.5 × 1.1R = 0.60R − 0.55R = +0.05R a trade before costs. Costs take 0.08R a trade, which leaves −0.03R. Over 400 trades: 400 × 0.05R = +20R before costs, 400 × −0.03R = −12R after.

Decision: as it stands, the signal doesn't pay. The next question might be whether some version of it makes more per trade than it costs. A real backtest only estimates its average, and 400 trades leave room for luck (the Sample size lesson).

Theory

Expected value after costs

A test of a trading rule often comes down to one number: its expected value per trade (its expectancy, the average result per trade) after transaction costs (everything paid to trade: fees and the gap between the price wanted and the price got). The rule pays on average only if that number is above zero, which happens exactly when the cost per trade is smaller than the expected value before costs. Over n trades the total is about n times it (≈ because real results vary around the average).

Enet = p × W − (1 − p) × L − c
total ≈ n × Enet
p
the win rate, as a share (0.5 for 50%); 1 − p is the loss rate
W
the average win, in R
L
the average loss, in R, as a positive size (1.1, not −1.1)
c
the cost per trade, in R
Enet
the expected value per trade after costs, in R
n
the number of trades
Worked example

The morning's signal: p = 0.5, W = 1.2R, L = 1.1R, c = 0.08R. Before costs, 0.5 × 1.2R − 0.5 × 1.1R = +0.05R. Enet = +0.05R − 0.08R = −0.03R. Over n = 400 trades, n × Enet = −12R, where the lower line ended. It would pay only with costs below 0.05R a trade.

Holds when
  • p, W and L come from enough trades to trust (the Sample size lesson);
  • c is what trading really costs (the Costs lesson);
  • the rule was not picked as the best of many tries on the same data (the best of many is often just the luckiest).
Breaks when

A short or hand-picked test can show Enet above zero by luck alone (the Best of many lesson). A number above zero earns a rule more testing, not a verdict that it works.

The situationA different made-up rule wins 40% of its trades. Its average win is 2R, its average loss 1R, and each trade costs 0.1R.

What is its expected value per trade after costs, in R?

Hint: p × W − (1 − p) × L − c, with p = 0.4 and 1 − p = 0.6.

0.4 × 2R − 0.6 × 1R − 0.1R = 0.8R − 0.6R − 0.1R = +0.1R a trade. Before costs it was +0.2R, so costs take half of it.
0.4 × 2R − 0.6 × 1R − 0.1R = 0.8R − 0.6R − 0.1R = +0.1R a trade. Before costs it was +0.2R (0.2 is the answer without the cost), so costs take half of it.
Practice 1 of 3

A pension firm's team

The situationA made-up firm invests the savings of two million people for their pensions. One of its teams checks whether patterns in share prices still pay after costs.

Which side is the firm on, and what kind of work does that team do?

It invests savings for clients, so it is an asset manager: the buy side. And testing whether a pattern pays after costs is research, not pricing a contract.
It invests savings, so it is on the buy side. The team asks whether a pattern is worth acting on, which is research and trading, not risk.
The buy side is right: it invests savings for clients. But the team tests patterns, which is research and trading; development builds the systems.
It invests savings for clients, so it is an asset manager, on the buy side. Checking whether a pattern pays after costs is research and trading.
Practice 2 of 3

A colleague's backtest

The situationA colleague's made-up backtest: 1,000 trades, a win rate of 45%, an average win of 1.5R, an average loss of 1.1R, and costs of 0.05R a trade.

About how much does it make over the 1,000 trades after costs, in R?

Hint: first Enet = p × W − (1 − p) × L − c, with 1 − p = 0.55. Then multiply by n = 1,000.

0.45 × 1.5R = 0.675R from the wins, 0.55 × 1.1R = 0.605R to the losses: +0.07R before costs, and +0.07R − 0.05R = +0.02R after. Over 1,000 trades: +20R. Costs took 50R of the 70R the rule made before them.
0.45 × 1.5R = 0.675R from the wins, 0.55 × 1.1R = 0.605R to the losses: +0.07R a trade before costs, +0.02R after. Over 1,000 trades: 1,000 × 0.02R = +20R (70R would leave out the costs).
Practice 3 of 3

Three Fridays

The situationOn Monday a friend notices that a share rose on each of the last three Fridays. From that week on, they buy it every Friday.

Which stage of the loop did they skip?

They had a question, in effect: do Fridays rise? What they never did was check it on more than three Fridays.
Buying every Friday is a decision. It was taken straight after the question, with no test on data in between.
They went from a question straight to a decision. A test would ask how often Fridays rose over many years, by how much, and whether that beats costs.
Three Fridays is a pattern a coin draws easily: each one has about an even chance of rising. Without a test on many more, there is nothing to decide on.
✓

Lesson done

A quant uses numbers, statistics and code to make decisions about prices and risk. The work comes in four kinds, pricing, research and trading, risk and development, done at banks on the sell side, at investors on the buy side and at firms that trade their own money. Much of it runs one loop: question, data, test, decision. For a trading rule, the test often comes down to its expected value per trade after costs, which is only as good as the trades it was measured on.

Later parts of this course, and later courses (some still being written), build the tools for each kind of work; the course list shows them.

This is a free course, not a qualification. It teaches ideas that quant interviews and jobs use, but it is not accredited, it is not a substitute for a degree, and it won't get anyone a job by itself. Firms hire on their own criteria, which can include degrees, interviews and experience, and those criteria differ between firms and change. Neither this course nor QuantWright has any connection with any employer.

Key ideas

Quant
short for quantitative analyst: someone who uses numbers, statistics and code to make decisions about prices and risk
Pricing
working out what a contract, such as an option, is worth
Research and trading
finding patterns in data and testing whether they are worth acting on after costs
Risk
measuring how much a firm's holdings could lose, and setting limits on it
Development
building the systems: data, backtests and the programs that send orders
Sell side / buy side
firms that make, sell and trade financial products for clients (mostly banks) / firms that invest money (asset managers, hedge funds)
Proprietary trading firm
a firm that trades only its own money, with no outside clients; not the retail “prop firm” evaluations
The research loop
question, data, test, decision; the decision raises the next question
Expected value after costs
the average result per trade once the cost of every trade is taken off

Enet = p × W − (1 − p) × L − c

total ≈ n × Enet

Lesson notes

A quant uses numbers, statistics and code to make decisions about prices and risk. The work comes in four kinds (pricing, research and trading, risk, development), and much of it runs one loop: question, data, test, decision. For a trading rule, the test often comes down to the expected value per trade after costs, which is only as good as the trades it was measured on.

What “quant” means

Quant is short for quantitative analyst. Two people look at a share that has risen five days in a row. One says it will keep going. The other asks: over the last 20 years, after five up days, how often did it rise the next day, by how much on average, and was that more than it costs to trade? The second is working like a quant: the hunch has become a question past prices can answer, with statistics (methods for summing up data and judging what it shows) and code. A quant doesn't need to know what happens tomorrow; the job is to measure what past data shows, say how sure that is, and decide on it.

Four kinds of work

Pricing asks what a contract is worth. Banks sell contracts whose value depends on a price, such as an option: the right, but not the duty, to buy or sell something at a set price by a set date. A pricing quant works out a fair price from a model, a set of equations for how prices move. Research and trading asks whether a pattern is worth acting on: it looks for a pattern in past prices and tests whether it holds after costs (what it costs to trade: fees and the gap between buying and selling prices) and could not just be luck. Risk asks how much the firm could lose: it measures how much everything the firm holds could lose on a bad day, sets limits and checks them. Development builds the systems: price data, backtests (a trading rule run over past prices to see what it would have done) and the programs that send orders. They connect: research finds a rule, development builds the system that runs it, risk sets how much it may lose, and pricing values the contracts it trades. Real jobs mix them.

Who does it

The sell side makes, sells and trades financial products for clients, mostly banks, on their trading desks (the teams that trade). The buy side invests money, its own or its clients': asset managers (firms that invest savings for clients, including pension money) and hedge funds (private investment funds for large investors, free to trade in many ways). When a bank's desk sells a pension fund a contract, the bank is the sell side and the pension fund the buy side. A proprietary trading firm (“proprietary” means “its own”) trades only its own money, with no outside clients; some are market makers, firms that stand ready to buy and to sell all day, quoting a price for each, and earn the small gap between the two. Exchanges and software companies serve all of them. A proprietary trading firm is not the same as the “prop firm” evaluations sold for a fee to individual traders (the Rules as risk limits lesson).

One loop

Most quant work runs four stages: a question, the data that can answer it, a test on that data, and a decision, which raises the next question. In the Expectancy lesson the question was whether a strategy that wins 9 trades in 10 makes money; the test showed that a strategy is judged by its average result per trade, not by how often it wins. In the Random walks lesson, coin flips added up drew the same trends as price charts, so a trend on a chart is not evidence on its own.

One made-up morning

Question: does a trading signal (a pattern that says when to trade) still pay after costs? Results are counted in R, a fixed amount of money, the same on every trade (like €10), so trades can be added up and compared. The made-up backtest has 400 trades: 200 wins of +1.2R and 200 losses of −1.1R, and each trade costs 0.08R (the broker's fee plus the gap between the price wanted and the price got). The expectancy, the average result per trade, is the win rate (the share of trades that win) × the average win − the loss rate (the share that lose) × the average loss: 0.5 × 1.2R − 0.5 × 1.1R = +0.05R before costs, and −0.03R after the 0.08R cost. Over 400 trades that is +20R before costs and −12R after; the costs come to 400 × 0.08R = 32R. Decision: as it stands, the signal doesn't pay. A real backtest only estimates its average, and 400 trades leave room for luck (the Sample size lesson).

Formula: expected value after costs

The rule pays on average only if its expected value per trade after transaction costs (everything paid to trade) is above zero, which happens exactly when the cost per trade is smaller than the expected value before costs. Over n trades the total is about n times it (≈ because real results vary around the average).

Enet = p × W − (1 − p) × L − c
total ≈ n × Enet
p
the win rate, as a share (0.5 for 50%); 1 − p is the loss rate
W
the average win: the average over the winning trades only, in R
L
the average loss: the average over the losing trades only, in R, as a positive size
c
the cost per trade, in R
Enet
the expected value per trade after costs, in R
n
the number of trades
Worked example

The morning's signal: p = 0.5, W = 1.2R, L = 1.1R, c = 0.08R. Before costs, 0.5 × 1.2R − 0.5 × 1.1R = +0.05R. Enet = +0.05R − 0.08R = −0.03R. Over n = 400 trades, n × Enet = −12R. It would pay only with costs below 0.05R a trade.

Holds whenBreaks when

A short or hand-picked test can show Enet above zero by luck alone (the Best of many lesson). A number above zero earns a rule more testing, not a verdict that it works.

One more worked example

New made-up numbers

A rule wins 35% of its trades, with an average win of 2.5R and an average loss of 1R. Each trade costs 0.1R, and it takes 500 trades.

Before costs: 0.35 × 2.5R − 0.65 × 1R = 0.875R − 0.65R = +0.225R a trade.

After costs: Enet = 0.225R − 0.1R = +0.125R a trade.

Total: n × Enet = 500 × 0.125R = +62.5R, on these made-up numbers. Costs could rise to 0.225R a trade before the rule stopped paying on average.

Common mistakes

Check yourself

  1. Which kind of work is “estimate how much the firm could lose on its worst day in 100”?
    Answer

    Risk: it asks how much could be lost on a bad day.

  2. A rule wins 60% of its trades, with wins of 1R and losses of 1R, and costs 0.25R a trade. What is its expected value per trade after costs?
    Answer

    0.6 × 1R − 0.4 × 1R − 0.25R = 0.2R − 0.25R = −0.05R a trade: it loses on average, though it wins 6 trades in 10.

  3. A rule wins 30% of its trades, with wins of 3R and losses of 1R. Above what cost per trade does it stop paying on average?
    Answer

    Before costs, 0.3 × 3R − 0.7 × 1R = 0.9R − 0.7R = 0.2R. It pays on average only while the cost per trade is below 0.2R.

  4. A firm trades only its own money and has no outside clients. What is it called, and is it the same as a retail “prop firm” evaluation?
    Answer

    A proprietary trading firm. No: the “prop firm” evaluations sold for a fee to individual traders are a different thing (the Rules as risk limits lesson).

Try it yourself

Run the script. Every number in this lesson comes from one short Python script (below). Change the costs or the sizes of the wins and losses and see where the after-costs total crosses zero.

Work it out by hand. Take any backtest report with a win rate, an average win and an average loss. Work out the expectancy before costs, take off a cost per trade, and multiply by the number of trades. Then ask what cost would bring it to zero.

The code behind every number (Python, seed 20261111)
Loading…

Honest notes

Where this comes from