Algorithmic & Quant Trading
Level: 4 (Application — novel problems, no hints) Time Limit: 60 minutes Total Marks: 60
Answer all questions. Show all working. Calculators permitted. Round to 4 decimal places unless stated.
Question 1 — Pairs Trading & Cointegration (14 marks)
You are researching a pairs trade on two stocks A and B. A regression of price on price gives the hedge relationship:
The residual (spread) series has historical mean and standard deviation . You enter positions when the spread's z-score exceeds and exit at .
(a) Today and . Compute the current spread and its z-score. State whether a trade is triggered and, if so, which leg you go long and which you go short. (5)
(b) You hold a market-neutral position. For every 1 share of A traded, how many shares of B must you trade to be hedged? Explain what "market neutral" means here in terms of the spread. (3)
(c) An augmented Dickey–Fuller test on returns a test statistic of with a 5% critical value of . State the null hypothesis and the conclusion, and explain why this result is a prerequisite for the strategy to be valid. (4)
(d) A colleague suggests trading the pair even though the ADF test statistic is . Explain the danger. (2)
Question 2 — Mean Reversion Signal Design (12 marks)
A quant builds a mean-reversion signal using a Bollinger-style rule on a single asset. The 20-day moving average is and the 20-day standard deviation is . The current price is .
(a) Compute the number of standard deviations the price sits below the mean, and state whether a long or short mean-reversion signal fires under a rule. (4)
(b) Define a continuous position-sizing rule of the form (where is the z-score) capped at . Using , compute the target position weight for the current price and state whether the cap binds. (4)
(c) Mean-reversion strategies typically have a high win rate but occasional large losses. Explain the mechanism that produces this asymmetry and one risk-management rule to mitigate it. (4)
Question 3 — Momentum Strategy Construction (12 marks)
You run a cross-sectional momentum strategy on 6 stocks. The 12-month returns are:
| Stock | R (%) |
|---|---|
| U | +34 |
| V | +12 |
| W | −5 |
| X | +45 |
| Y | +8 |
| Z | −18 |
You go long the top one-third and short the bottom one-third (equal-weight within each leg).
(a) Identify the long and short baskets and state the weight on each stock. (4)
(b) Assume in the following month the realized returns are: U +2%, X −1%, W +3%, Z −4%. Compute the strategy's monthly return (long leg minus short leg contributions). (5)
(c) Momentum strategies are exposed to "momentum crashes." Describe in one to two sentences what a momentum crash is and one market condition that triggers it. (3)
Question 4 — Overfitting & Walk-Forward Analysis (12 marks)
A researcher optimizes a strategy over 8 parameters and reports an in-sample Sharpe ratio of 3.1. On a held-out test set the Sharpe drops to 0.4.
(a) Name this phenomenon and give two concrete signs from the numbers above that it has occurred. (4)
(b) Describe the walk-forward analysis procedure. Explain precisely how it produces a more honest performance estimate than a single in-sample optimization. (5)
(c) The researcher backtested 500 parameter combinations and picked the best. Explain why the best backtest Sharpe overstates true performance even before any live trading, and name one statistical adjustment used to correct for this. (3)
Question 5 — Trading System Components & ML Caution (10 marks)
(a) A complete algorithmic trading system contains an alpha/signal module, a portfolio construction/sizing module, an execution module, and a risk module. For each, state in one line its core responsibility. (4)
(b) A team feeds 400 features into a deep neural network to predict next-day returns and gets 62% directional accuracy in a backtest. Give three distinct reasons to be sceptical that this will survive live trading. (3)
(c) Explain the difference between look-ahead bias and overfitting, and give one example of each. (3)
Answer keyMark scheme & solutions
Question 1
(a) Spread . (2) Z-score . (2) Since , no trade is triggered. (1) (If it were triggered at : spread too high → short A, long B. At : long A, short B.)
(b) Trade shares of B for every 1 share of A. (1) Market neutral: the dollar exposure to broad market moves cancels because the position bets only on the spread reverting to its mean, not on the direction of either stock's price. (2)
(c) Null hypothesis : the spread series has a unit root (is non-stationary / not cointegrated). (1) Since test stat (critical value), reject (1) → the spread is stationary/mean-reverting. (1) This is a prerequisite because pairs trading profits only if the spread reliably returns to its mean; without cointegration the spread can drift indefinitely and diverge, causing unbounded losses. (1)
(d) With ADF , we fail to reject the unit root → the spread is likely non-stationary. (1) Trading it risks the spread drifting away permanently ("divergence"), so mean-reversion entries never revert and losses accumulate. (1)
Question 2
(a) . (2) Price is 2.25σ below the mean; so a long mean-reversion signal fires (buy the dip expecting reversion up). (2)
(b) . (2) Since , the cap binds → target weight (fully long). (2)
(c) High win rate: reversions occur frequently, so most trades close for small gains near the mean. (1) The asymmetry: occasionally the mean-reversion assumption breaks (regime change, trend, or structural break) and the position is held while the price keeps moving against it, producing a rare large loss that dwarfs many small wins. (2) Mitigation: a stop-loss (e.g. exit if exceeds a wider threshold like 4), or a time-based exit / position cap. (1)
Question 3
(a) Rank descending: X(+45), U(+34), V(+12), Y(+8), W(−5), Z(−18). Top third (2 names) = long X, U; bottom third (2 names) = short Z, W. (2) Equal weight within each leg: +0.5 on X, +0.5 on U; −0.5 on Z, −0.5 on W. (2)
(b) Long leg return = . (2) Short leg: we are short, so profit = −(realized return). Short basket realized = ; short contribution = . (2) Total strategy return . (1)
(c) A momentum crash is a sharp reversal in which prior losers rally hard and prior winners fall, so the long-winner/short-loser book suffers heavy losses. (2) Trigger: a rebound/recovery following a severe market decline (high-volatility panic bottoms), when beaten-down losers snap back fastest. (1)
Question 4
(a) Phenomenon: overfitting / curve fitting. (2) Signs: (i) implausibly high in-sample Sharpe (3.1) relative to realistic markets; (ii) large in-sample vs out-of-sample degradation (3.1 → 0.4), the classic generalization gap; also 8 tunable parameters gives high model flexibility to fit noise. (2, any two)
(b) Walk-forward: split data into sequential windows. Optimize parameters on an in-sample window, then apply the fixed parameters to the immediately following out-of-sample window and record performance; roll both windows forward and repeat, stitching the OOS segments into one continuous track record. (3) It is more honest because every reported return comes from data not used to choose the parameters, so it simulates real deployment where you must fix parameters before seeing the future — capturing parameter instability across regimes. (2)
(c) Testing 500 combinations and keeping the maximum is a multiple-comparisons / selection bias: even random strategies produce some high Sharpe by chance, so the best is inflated by luck. (2) Adjustment: the Deflated Sharpe Ratio (or Bonferroni correction / adjust for number of trials). (1)
Question 5
(a) (1 each)
- Alpha/signal: generate predictive forecasts / entry–exit signals.
- Portfolio construction/sizing: convert signals into position sizes respecting diversification and capital.
- Execution: route and fill orders minimizing slippage and market impact.
- Risk: monitor and cap exposures, drawdown, leverage; enforce limits/kill-switch.
(b) (1 each, any three) 62% may be from overfitting 400 features to noise; no accounting for transaction costs/slippage that erode a small edge; possible look-ahead/data leakage in features; non-stationarity — market regime may change; directional accuracy ≠ profitability (misses trade sizing and asymmetric payoffs).
(c) Look-ahead bias: using information not available at decision time (e.g. using the day's close to trade at the open, or restated fundamentals). (1.5) Overfitting: fitting model parameters to random noise in the sample so it fails out-of-sample (e.g. tuning a moving-average length to the exact value that maximized past backtest profit). (1.5)
[
{"claim":"Q1a spread and z-score", "code":"PA=152; PB=82; beta=Rational(18,10); s=PA-beta*PB; z=(s-0)/Rational(25,10); result = (s==Rational(44,10)) and (float(z)==1.76)"},
{"claim":"Q2a z-score = -2.25", "code":"z=(91-100)/4; result = (z==-2.25)"},
{"claim":"Q2b uncapped weight 1.125 then capped to 1", "code":"z=Rational(-225,100); w=-Rational(1,2)*z; capped=1 if abs(w)>1 else w; result = (w==Rational(1125,1000)) and (capped==1)"},
{"claim":"Q3b strategy monthly return = 1.0%", "code":"long=Rational(1,2)*2 + Rational(1,2)*(-1); short_basket=Rational(1,2)*3 + Rational(1,2)*(-4); short_contrib=-short_basket; total=long+short_contrib; result = (total==1)"}
]