---
title: "Vectorised Backtests"
book: "Research Craft: Predictors, Backtests, Measurement, Portfolios"
subject: quant
language: en
chapter: 16
exercises: 8
source: https://one-course.com/books/quant/7/en/chapter/16-vectorised-backtests
---

# Chapter 16 — Vectorised Backtests

A one-line [backtest](#def-rs-vectorised-backtests-backtest) of the one-day reversal on the synthetic market (buy yesterday’s losers, sell its winners, every day) shows a Sharpe ratio of 7.2 over ten years. Written one line differently, multiplying the book built from today’s close by today’s return, it shows $-65$. Neither is a result. The first trades at the closing price it used to compute the signal, ignores trading costs on a book that turns over three quarters of itself every day, and would lose money in any of the ways this chapter lists; the second is a look-ahead so blatant that it inverts the signal. The [vectorised backtest](#def-rs-vectorised-backtests-backtest), a few array operations on a panel of weights and returns, is the fastest research tool the firm has, and most of the time the right one; this chapter builds it (`firm.vecbt`), says when it is right, and takes its lies apart one at a time.

## 16.1 The vectorised backtest

**Definition 16.1 (Backtest, vectorised backtest).**

A *backtest* is the simulation of a trading rule on historical data, producing the positions, trades, costs and returns the rule would have had. A *vectorised backtest* computes them as whole-array operations on panels (periods by names): target weights, returns, and costs as functions of the weight traded, without simulating orders.

**Definition 16.2 (Decision time, execution lag, rebalance frequency).**

The *decision time* of a book is the moment at which the information used to build it was complete. The *execution lag* is the number of periods between the decision time and the first return the book earns. The *rebalance frequency* is how often the target book is recomputed and traded to.

In `firm.vecbt` a book decided at the close of day $t$ with lag $L$ is held over day $t + L$: lag 0 multiplies it by the return that produced it, lag 1 assumes it was traded at the very close it was computed from, lag 2 trades it at the next close. The book drifts with returns between rebalances, so the weight traded at a rebalance is the target minus the drifted book, not minus the previous target; names outside the [tradable universe](https://one-course.com/books/quant/7/en/chapter/4-universe-symbology-and-corporate-actions#def-rs-universe-symbology-and-corporate-actions-universe) at the [decision time](#def-rs-vectorised-backtests-timing) are not held; a name that stops listing earns its [delisting return](https://one-course.com/books/quant/7/en/chapter/4-universe-symbology-and-corporate-actions#def-rs-universe-symbology-and-corporate-actions-delisting) and nothing after. The result is a `BacktestResult` (weights, trades, gross returns, costs by type, net returns, capital), the type every backtester of the firm returns and that the performance module of chapter 22 reads.

**Definition 16.3 (Portfolio turnover, linear cost model).**

The *portfolio turnover* of a period is half the sum of the absolute weights traded, the fraction of the book replaced. A *linear cost model* charges each trade a fixed cost per unit of weight traded (a half-spread plus commissions), independent of its size.

## 16.2 Four fidelity levels

**Definition 16.4 (Fidelity level).**

The *fidelity level* of a [backtest](#def-rs-vectorised-backtests-backtest) is how much of the trading process it simulates. This book uses four: level 1, the [vectorised backtest](#def-rs-vectorised-backtests-backtest) on [bar](https://one-course.com/books/quant/7/en/chapter/2-market-data-for-research#def-rs-market-data-for-research-bar) returns with costs as functions of turnover; level 2, the event-driven [backtest](#def-rs-vectorised-backtests-backtest) on [bars](https://one-course.com/books/quant/7/en/chapter/2-market-data-for-research#def-rs-market-data-for-research-bar), with orders, fills and a simulated clock (chapter 17); level 3, the replay of order-book messages with queue positions and latency (chapter 18); level 4, live trading at small size or paper trading on live data (chapters 19 and 21).

![The four fidelity levels of the firm’s backtests. A research idea moves right only if it survives on the left.](https://one-course.com/images/onecourse/chapters/quant-7/rs-vectorised-backtests/fig-ca6fa9dac218.svg)

***Figure 16.1.** The four [fidelity levels](#def-rs-vectorised-backtests-fidelity) of the firm’s [backtests](#def-rs-vectorised-backtests-backtest). A research idea moves right only if it survives on the left.*

The levels are not rivals: a thousand ideas are screened at level 1 in the time one is run at level 3, and a level-1 result that is negative after costs does not need level 3 to be rejected. The question for each strategy is the lowest level whose answer the higher levels would not change.

## 16.3 Where the vectorised backtest is right

It is right when trading does not change the answer: slow signals (holding periods of days to months), liquid names, books small relative to the names’ volume, and costs well approximated by a spread and a commission per unit traded. Monthly 12-1 momentum on the 500 most liquid synthetic names trades 1.9% of its book a day; its Sharpe ratio moves from 0.32 before costs to 0.21 after 10 basis points per unit traded, 0.19 after borrow and 0.17 when traded at the next close ([Figure 16.2](#fig-rs-vectorised-backtests-waterfall)). None of those steps depends on how the trades are executed, and a level-2 or level-3 [backtest](#def-rs-vectorised-backtests-backtest) would add little. It is wrong, in the sense of missing the answer, when fills depend on the order book (passive orders, chapter 17), when the strategy’s own trades move prices (chapter 27), when timing within the day matters, and when events such as halts, auctions or corporate actions intervene between the decision and the trade.

## 16.4 The lies it tells

**Proposition 16.5 (Costs against turnover).**

A book with mean gross return $g$ per period and turnover $\tau$ per period (half the weight traded) breaks even at a linear cost of $g/(2\tau)$ per unit of weight traded.

**Proof.** The weight traded per period is $2\tau$, and at a cost $c$ per unit the cost per period is $2\tau c$; set it equal to $g$. ∎

The one-day reversal on the synthetic market, rebuilt daily as a dollar-neutral book of gross exposure 1, corrected one lie at a time (`rs_vecbt.waterfall`; each step keeps the corrections before it):

| step | Sharpe ratio | mean return a year | turnover a day |
| --- | --- | --- | --- |
| naive (survivors, trade at the signal’s close) | 7.17 | 27.0% | 74% |
| names listed at each decision | 7.22 | 27.4% | 74% |
| the 500 most liquid names | 6.95 | 27.4% | 75% |
| 10 bp per unit traded | $-2.58$ | $-10.2\%$ | 75% |
| borrow at 50 bp a year | $-2.64$ | $-10.4\%$ | 75% |
| trade at the next close | $-9.45$ | $-37.7\%$ | 75% |

**The universe.** The naive universe is the list of names alive at the end of the sample, the one a researcher downloads today. For the reversal it changes little (7.17 against 7.22 on the point-in-time list), for momentum a great deal, and in the direction a textbook does not predict: 0.21 against 0.44 ([Figure 16.2](#fig-rs-vectorised-backtests-waterfall)). The names that later delisted were momentum’s losers, and the short side profited from their final falls; [survivorship bias](https://one-course.com/books/quant/7/en/chapter/3-point-in-time-data-and-the-biases#def-rs-point-in-time-data-and-the-biases-survivorship) removes that profit. Its sign depends on the strategy; its size can only be measured.

**Costs.** The reversal’s gross return is large and its turnover larger: 74% of the book a day. At 10 basis points per unit of weight traded the cost is $2 \times 0.75 \times 0.001 \times 252 = 38\%$ a year against a gross 27%, and the Sharpe ratio goes from 6.95 to $-2.58$. By [Proposition 16.5](#prop-rs-vectorised-backtests-breakeven) the book breaks even at 7.3 basis points. Novy-Marx and Velikov (2016) found the same on real anomalies: most strategies with less than 50% monthly turnover still earned significant spreads after costs when designed to limit them, and few with higher turnover did.

**Borrow.** Short positions pay a fee to the lender of the stock (Book 1, chapter 6), 50 basis points a year on general collateral and far more on hard-to-borrow names; here it costs 0.25% a year and little Sharpe ratio. It matters more for strategies whose shorts concentrate in small, crowded names, which the reversal’s do not.

**Timing.** A book computed from a closing price cannot be traded at that price: the closing auction’s orders are due before the close is known (Book 1, chapter 13). Traded at the next close instead, the reversal has no alpha left (its information lasts a day, chapter 13) and keeps its costs: $-9.45$. The honest level-1 answer would use a signal computed from prices known before the close and a cost model of the closing auction; the [vectorised backtest](#def-rs-vectorised-backtests-backtest) can hold that assumption, but only if someone writes it down.

**Compounding.** Summing daily returns instead of compounding them is harmless for small returns and not for large ones. The costed reversal’s capital, compounded, falls to 0.35 of its start over ten years; summed, it reaches $-0.04$, a capital no book can have.

**Look-ahead.** Multiplying today’s book by today’s return makes the reversal lose 694% a year ($-65$ Sharpe ratio): its signal is minus that return. Look-ahead does not always flatter; it always lies.

![Sharpe ratio of two strategies on firm.synthmkt as the backtest’s lies are corrected one at a time: survivors’ universe (naive), point-in-time universe (PIT), 500 most liquid names, 10 bp per unit traded, borrow at 50 bp a year, trading at the next close. Note the two scales.](https://one-course.com/images/onecourse/chapters/quant-7/rs-vectorised-backtests/fig-f017b1775689.svg)

***Figure 16.2.** Sharpe ratio of two strategies on `firm.synthmkt` as the [backtest](#def-rs-vectorised-backtests-backtest)’s lies are corrected one at a time: survivors’ universe (naive), point-in-time universe (PIT), 500 most liquid names, 10 bp per unit traded, borrow at 50 bp a year, trading at the next close. Note the two scales.*

![Compounded capital of the reversal on the 500 most liquid synthetic names before costs, after costs and borrow, and traded at the next close, with monthly momentum after all corrections. Data: rs_vecbt on firm.synthmkt.](https://one-course.com/images/onecourse/chapters/quant-7/rs-vectorised-backtests/fig-30711e0bd83a.svg)

***Figure 16.3.** Compounded capital of the reversal on the 500 most liquid synthetic names before costs, after costs and borrow, and traded at the next close, with monthly momentum after all corrections. Data: `rs_vecbt` on `firm.synthmkt`.*

## 16.5 A checklist

Every level-1 [backtest](#def-rs-vectorised-backtests-backtest) the firm runs states, and `firm.vecbt` enforces where it can:

1. the [decision time](#def-rs-vectorised-backtests-timing) of every input, and the [execution lag](#def-rs-vectorised-backtests-timing) from it to the trade (never 0; 1 only with a stated reason);
2. the [tradable universe](https://one-course.com/books/quant/7/en/chapter/4-universe-symbology-and-corporate-actions#def-rs-universe-symbology-and-corporate-actions-universe) at each decision, point-in-time, with [delisting returns](https://one-course.com/books/quant/7/en/chapter/4-universe-symbology-and-corporate-actions#def-rs-universe-symbology-and-corporate-actions-delisting) ;
3. the cost per unit traded, by name if liquidity differs, and the break-even cost ( [Proposition 16.5](#prop-rs-vectorised-backtests-breakeven) );
4. borrow fees and availability for the shorts, and the financing of any leverage and the interest on cash;
5. the [rebalance frequency](#def-rs-vectorised-backtests-timing) and the drift of the book between rebalances;
6. compounding, and capital that cannot go below zero;
7. the gross exposure, and position caps against liquidity;
8. the number of variants tried before this one (chapter 20), and the level at which the result must be confirmed.

Arnott, Harvey and Markowitz (2019) set out such a protocol for research with machine learning, stressing that its methods need far more data than finance has.

## 16.6 Tutorial: Sharpe 7.2 on Monday

**Goal.** [Backtest](#def-rs-vectorised-backtests-backtest) the one-day reversal and monthly momentum on `firm.synthmkt` in one vectorised pass each, correct the lies one at a time, and compute the reversal’s break-even cost. **End state:** Figures [16.2](#fig-rs-vectorised-backtests-waterfall) and [16.3](#fig-rs-vectorised-backtests-capital); the table.

1. **The core loop**: the lagged book, the trade from the drifted book, costs, borrow, financing. `for t in range (T): trades[t] = held[t] - drift tcost[t] = float (np.abs(trades[t]) @ c[t]) gross[t] = float (held[t] @ r[t]) bcost[t] = borrow / periods * float (-held[t][held[t] < 0 ].sum()) cash = 1.0 - held[t].sum() fin[t] = -(cash_rate / periods) * cash if cash >= 0 else -(cash_rate + borrow_spread) / periods * cash grown = held[t] * (1.0 + r[t]) total = 1.0 + gross[t] drift = grown / total if total > 0 else np.zeros(N) net = gross - tcost - bcost - fin capital = np.cumprod(1.0 + net) if compound else 1.0 + np.cumsum(net)` **Listing 16.1.** The level-1 backtest’s period loop. code/firm/vecbt/firm_vecbt.py
2. **The [tradable universe](https://one-course.com/books/quant/7/en/chapter/4-universe-symbology-and-corporate-actions#def-rs-universe-symbology-and-corporate-actions-universe)**: the most liquid names by trailing dollar volume, as known at each close. `def liquid (P, top: int = TOP, window: int = 21 ) -> np.ndarray: """The `top` names by mean dollar volume over the last `window` days, as known at each close.""" dv = np.where(P.listed, P.price * P.volume, 0.0 ) c = np.cumsum(dv, axis=0 ) avg = (c - np.vstack([np.zeros((window, dv.shape[1 ])), c[:-window]])) / window rank = np.argsort(np.argsort(-avg, axis=1 ), axis=1 ) return (rank < top) & P.listed` **Listing 16.2.** A point-in-time liquid universe. code/research/16-vectorised-backtests/python/rs_vecbt.py
3. **Run** `waterfall()` for both signals, `lookahead()` , `breakeven_cost()` , `compounding()` and `fig_vecbt.py` .

**What to change next.** Smooth the reversal signal over three days and watch turnover and the break-even cost; charge costs by name in proportion to each name’s volatility.

## 16.7 Build: the level-1 backtester

**Purpose.** The firm’s screening backtester: seconds per run, honest by construction on timing, universe, costs and financing, and the source of the `BacktestResult` type every later backtester returns.

**Interface.** `BacktestResult(dates, names, weights, trades, gross, costs, net, capital, meta)` with `turnover`, `gross_exposure`, `net_exposure`; `signal_to_weights(signal, universe, gross, neutral)`; `backtest(weights, returns, lag, universe, cost, borrow, cash_rate, borrow_spread, cap, compound, periods)`.

**Rules.** The lag is an argument, not an assumption; the universe is applied at the [decision time](#def-rs-vectorised-backtests-timing); trades are measured from the drifted book; costs are charged on every trade; capital compounds by default.

**Acceptance tests.** `code/firm/vecbt/tests/`: lags 0, 1 and 2 on a hand series; compounding against summing; the trade from a drifted book; costs and turnover of an alternating book; borrow, cash interest and leverage financing; universe masks and caps; dollar-neutral weights of a given gross.

**Stretch.** Costs from a square-root impact model (chapter 27); borrow availability by name; multi-currency cash.

Sources and further reading

- R. Novy-Marx and M. Velikov, “A taxonomy of anomalies and their trading costs”, *Review of Financial Studies* 29(1), 2016.
- R. Arnott, C. R. Harvey and H. Markowitz, “A backtesting protocol in the era of machine learning”, *Journal of Financial Data Science* 1(1), 2019.

## 16.8 Exercises

**Exercise 16.1 ★.**

A book earns 12% a year gross and turns over 20% of itself a day (252 days). At what cost per unit traded does it break even?

**Solution of Exercise 16.1.**

The gross return is $12\%/252 = 0.0476\%$ a day; by [Proposition 16.5](#prop-rs-vectorised-backtests-breakeven) the break-even cost is $0.0476\%/(2 \times 0.2) = 0.119\%$, 11.9 basis points per unit traded.

**Exercise 16.2 ★.**

A book holds 60% in A and 40% in B. A returns 10% and B 0% over the period. What are the drifted weights, and what must be traded to return to 60/40?

**Solution of Exercise 16.2.**

After the period A is worth $0.66$ and B $0.40$ of a capital of 1.06: weights 62.3% and 37.7%. To return to 60/40, sell 2.3% of capital of A and buy 2.3% of B.

**Exercise 16.3 ★.**

Daily returns of $+50\%$ and $-40\%$ alternate for ten days. What is the capital after ten days compounded, and what does summing the returns suggest?

**Solution of Exercise 16.3.**

Compounded: $(1.5 \times 0.6)^5 = 0.9^5 = 0.59$, a loss of 41%. Summed: $5 \times 50\% - 5 \times 40\% = +50\%$, a gain that never happened.

**Exercise 16.4 ★★.**

Why does the look-ahead [backtest](#def-rs-vectorised-backtests-backtest) of the reversal lose money while that of a momentum signal including today’s return would make it?

**Solution of Exercise 16.4.**

The reversal’s signal is minus the day’s return, so multiplying it by that return gives minus the return squared: a certain loss. A momentum signal that includes today’s return gives plus a positive multiple of it squared: a certain gain. Look-ahead adds the signal’s correlation with the return it was built from, whatever its sign.

**Exercise 16.5 ★★.**

Why can [survivorship bias](https://one-course.com/books/quant/7/en/chapter/3-point-in-time-data-and-the-biases#def-rs-point-in-time-data-and-the-biases-survivorship) raise one strategy’s [backtest](#def-rs-vectorised-backtests-backtest) and lower another’s? Give the mechanism for momentum in the synthetic market.

**Solution of Exercise 16.5.**

A survivors’ universe removes the names that later delisted, and with them their returns before and at delisting. A strategy that would have held those names long loses the losses (its [backtest](#def-rs-vectorised-backtests-backtest) rises); one that would have held them short loses the gains (its [backtest](#def-rs-vectorised-backtests-backtest) falls). In the synthetic market the delisted names were momentum’s past losers, held short, and their falls to delisting were profits for the short side.

**Exercise 16.6 ★★.**

A dollar-neutral book of gross exposure 2 posts its capital as collateral earning 3% a year and pays 50 basis points a year to borrow its shorts. What does financing add or cost per year, per unit of capital?

**Solution of Exercise 16.6.**

A dollar-neutral book has net exposure 0, so its cash is its capital: $+3\%$ a year of interest. Its shorts are 1 (half of gross 2) and cost $0.5\% \times 1
= 0.5\%$. Net: $+2.5\%$ a year. (The Sharpe ratio is computed on the return in excess of the cash rate.)

**Exercise 16.7 ★★★.**

*Coding.* Rebuild the reversal from the average of the last three days’ returns instead of the last one. How do turnover, the gross Sharpe ratio and the break-even cost change?

**Solution of Exercise 16.7.**

`rs_vecbt.smoothed(3)`: turnover falls from 75% to 42% of the book a day and the gross Sharpe ratio from 6.95 to 4.13, while the break-even cost barely moves (7.4 basis points against 7.3): the smoothing removes alpha along with trading, because the reversal’s information is one day old. It helps only a signal whose information outlasts its noise.

**Exercise 16.8 ★★★.**

*Find the flaw.* “Our strategy trades at the close using the closing price, which is fine because we use market-on-close orders.”

**Solution of Exercise 16.8.**

Market-on-close orders are submitted before the close, typically minutes before, when the closing price is not known; a signal computed from that price is not available when the order must be sent. Either compute the signal from prices known before the submission cutoff, or trade at the next close; and model the auction’s own costs.

## 16.9 Problem: Sharpe 7.2 on Monday, $-2.6$ on Friday

**Problem 16.1.**

Weekend problem — a backtest, lie by lie

The one-day reversal and monthly 12-1 momentum on `firm.synthmkt`, dollar neutral, gross exposure 1.

**Part I — The naive [backtest](#def-rs-vectorised-backtests-backtest).**

1. What Sharpe ratio and mean return does the naive reversal [backtest](#def-rs-vectorised-backtests-backtest) show, and what does it assume?
2. What does the lag-0 version show, and why is its sign negative?
3. What turnover does the reversal have?
4. Which inputs of the naive [backtest](#def-rs-vectorised-backtests-backtest) could a researcher have known at the [decision time](#def-rs-vectorised-backtests-timing) ?

**Part II — The universe.**

5. What do the point-in-time and liquid universes do to each strategy?
6. Why does [survivorship bias](https://one-course.com/books/quant/7/en/chapter/3-point-in-time-data-and-the-biases#def-rs-point-in-time-data-and-the-biases-survivorship) lower momentum here?
7. What would it do to a strategy that buys cheap, distressed stocks?

**Part III — Costs and timing.**

8. What do 10 basis points per unit traded do to the reversal and to momentum?
9. What is the reversal’s break-even cost?
10. What does borrow cost?
11. What happens when the reversal is traded at the next close, and why?
12. What does compounding change for the costed reversal?

**Part IV — The verdict.**

13. State the *named result* : the Sharpe waterfall from the naive to the honest level-1 [backtest](#def-rs-vectorised-backtests-backtest) , lie by lie, for both strategies.
14. Which strategy is a level-1 result, and which needs a higher [fidelity level](#def-rs-vectorised-backtests-fidelity) before anyone believes it?
15. What would a closing-auction cost model and a signal from 15:50 prices change?
16. How would you cut the reversal’s turnover without losing its alpha?
17. Which line of the checklist did the naive [backtest](#def-rs-vectorised-backtests-backtest) violate first?
18. What would Novy-Marx and Velikov’s evidence lead you to expect for a real daily reversal?
19. What should the [research log](https://one-course.com/books/quant/7/en/chapter/1-the-research-process#def-rs-the-research-process-log) record about this [backtest](#def-rs-vectorised-backtests-backtest) ?
20. In one sentence: what is a [vectorised backtest](#def-rs-vectorised-backtests-backtest) good for?

**Solution of Problem 16.1.**

1. Sharpe ratio 7.17, 27.0% a year, assuming it trades at the close it computed its signal from, in today’s survivors, without costs.
2. $-65$ , with $-694\%$ a year: the signal is minus the day’s return, multiplied by that return.
3. 74% of the book a day.
4. The returns up to the close, but not the ability to trade at that close, nor the list of survivors.
5. Reversal: 7.22 on the point-in-time universe, 6.95 on the 500 most liquid. Momentum: 0.44, then 0.32.
6. The names that delisted were momentum’s losers, held short; dropping them drops the short side’s profits (0.21 against 0.44).
7. Raise it: distressed stocks that failed would be missing from the [backtest](#def-rs-vectorised-backtests-backtest) ’s longs.
8. Reversal: 6.95 to $-2.58$ . Momentum: 0.32 to 0.21.
9. 7.3 basis points per unit traded.
10. About 0.25% a year for the reversal: $-2.58$ to $-2.64$ .
11. $-9.45$ : the reversal’s information lasts one day, so a book traded a day late earns no alpha and still pays its costs.
12. Compounded, capital falls to 0.35 of its start; summed, it reaches $-0.04$ .
13. **Named result.** Reversal: 7.17 (naive), 7.22 (point-in-time universe), 6.95 (liquid), $-2.58$ (costs), $-2.64$ (borrow), $-9.45$ (next close). Momentum: 0.21, 0.44, 0.32, 0.21, 0.19, 0.17. The reversal dies at the costs and again at the timing; momentum loses 60% of its best number but keeps a positive, small Sharpe ratio through every correction.
14. Momentum is a level-1 result: slow, liquid, insensitive to execution. The reversal needs the closing auction modelled (level 2 with an auction fill model, or level 3), and its level-1 answer is already negative.
15. It would give the reversal a legitimate way to trade at the close; whether any alpha is left depends on how much of the day’s move happens after 15:50, and the auction’s cost replaces the generic 10 basis points.
16. Trade only names whose signal crosses a threshold, keep positions until the signal reverses (a buy/hold spread, as Novy-Marx and Velikov recommend), or combine the signal with slower ones; each cuts turnover more than alpha only if the alpha is not all in the first day.
17. The first two lines: the [execution lag](#def-rs-vectorised-backtests-timing) and the point-in-time universe.
18. That a daily reversal, with turnover far above 50% a month, does not survive costs unless its costs are exceptionally low.
19. Every variant tried, with its settings (universe, lag, costs), the level-1 waterfall, and the decision taken (chapter 1).
20. Screening ideas quickly and honestly when execution does not change the answer.

## 16.10 Interview questions

**Interview question 16.1 ★ researcher.**

Name five ways a [backtest](#def-rs-vectorised-backtests-backtest) can overstate performance.

**Solution of Interview question 16.1.**

Look-ahead (inputs not known at the [decision time](#def-rs-vectorised-backtests-timing), or trading at the price the signal used), survivorship (today’s universe), no or low costs, no borrow or financing, and data snooping (many variants, one reported); also arithmetic cumulation of large returns, and ignoring capacity.

**Interview question 16.2 ★★ researcher, developer.**

Write, in words, the steps of a [vectorised backtest](#def-rs-vectorised-backtests-backtest) of a daily long-short strategy, and where each bias enters.

**Solution of Interview question 16.2.**

Build the signal panel with each input as of its [knowledge time](https://one-course.com/books/quant/7/en/chapter/3-point-in-time-data-and-the-biases#def-rs-point-in-time-data-and-the-biases-bitemporal); mask to the point-in-time [tradable universe](https://one-course.com/books/quant/7/en/chapter/4-universe-symbology-and-corporate-actions#def-rs-universe-symbology-and-corporate-actions-universe); convert to target weights; lag them to the first period they can be held; compute the drifted book and the trades to the new target; charge costs on trades, borrow on shorts, financing on cash and leverage; compound. Biases enter at each step: timing (lag), universe (survivors), costs, financing, compounding.

**Interview question 16.3 ★★ researcher, trader.**

A strategy’s gross Sharpe ratio is 7. Why might you still not trade it?

**Solution of Interview question 16.3.**

Its turnover may make costs exceed its gross return (the break-even cost may be below realistic costs); it may depend on trading at a price it could not get; it may not scale (capacity); it may be one of many variants tried. On the synthetic reversal, 7 became $-2.6$ at 10 basis points of cost.

**Interview question 16.4 ★★ researcher.**

When is a [vectorised backtest](#def-rs-vectorised-backtests-backtest) good enough, and when do you need an event-driven one?

**Solution of Interview question 16.4.**

Good enough for slow, liquid strategies whose trades are small against volume and costs are a spread per unit traded. An event-driven (or replay) [backtest](#def-rs-vectorised-backtests-backtest) is needed when fills depend on the order book (passive or limit orders), when timing within the day or auctions matter, when the strategy’s own impact matters, or when events intervene between decision and trade.

**Interview question 16.5 ★★ researcher, risk.**

How do you account for borrow and financing in a long-short [backtest](#def-rs-vectorised-backtests-backtest)?

**Solution of Interview question 16.5.**

Charge borrow fees by name on the short positions held each period (with availability limits), credit interest on cash and short proceeds as the prime broker pays it, charge the financing spread on borrowed cash for leverage, and compute the Sharpe ratio on the return in excess of the cash rate.

**Interview question 16.6 ★★★ researcher.**

Derive the break-even cost of a strategy from its gross return and turnover, and use it to compare a daily reversal with monthly momentum.

**Solution of Interview question 16.6.**

Per period the book trades $2\tau$ of weight and pays $2\tau c$; the net return is $g - 2\tau c$, zero at $c = g/(2\tau)$. The synthetic reversal: $g$ about 0.109% a day and $\tau = 0.75$, so 7.3 basis points; monthly momentum: $g$ about 0.011% a day and $\tau$ about 0.019, so about 30 basis points: four times the reversal’s tolerance for cost, with a tenth of its gross return.
