σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Statistics skill›Module 4 · Validation and overfitting›Topic 4.3·~1 hr 40 minAdvanced

Capstone: is this anomaly real?

Skill positionModule 4 of 4 · Topic 3 of 3
4.3 Capstone: is this anomaly real?
—Lab score— / 100Total XP—Streak—

Testing a discovery honestly

This capstone puts the whole skill into one question: a trend rule that goes long when the last L days summed positive and short otherwise, tried for 24 lookbacks on twenty years of SPY. Its best version has a Sharpe ratio near 0.31. Is that an edge? First estimate the Sharpe ratio, then measure its uncertainty with the bootstrap, then correct for the fact that you looked at 24 versions and reported the best.

SR=r̄/s√252, z≈SR/(√252)√m, p_adj=min(1, N p)

The first formula annualises the daily mean over the sample standard deviation. The second turns it into a z-score for the null of zero mean: the daily Sharpe ratio times the square root of the m strategy days. The third is the Bonferroni correction for N trials. Two details make the rule honest. The position on day t may use only returns up to day t-1, because a signal that peeks at the day it trades earns the absolute return every day. And the p-value of the best of N rules is not the p-value of one rule chosen in advance.

What the real data saysOn SPY from 2006 (5,190 days) buy and hold has a Sharpe ratio of 0.62. The 24 lookbacks from 5 to 120 days give the best trend rule at 60 days, with a Sharpe ratio of 0.31 over 5,130 days. Its z-score is 1.41, a one-sided p-value of 0.080, which looks nearly interesting. Multiply by the 24 trials and the adjusted p-value is 24×0.080>1, so it is 1. The best trend rule is worse than just holding the index, and the evidence for an edge disappears once you count how many rules you looked at.
  • Sharpe ratio: annualised mean over standard deviation, with the sample (n - 1) standard deviation.
  • Bootstrap: resample days with replacement and read the 2.5th and 97.5th percentiles of the statistic.
  • No look-ahead: a position on day t can use only returns up to day t - 1.
  • Multiple testing: the p-value of the best of N tries is N times larger than it looks.
A discovery is a claim about a searchReport how many things you tried along with the best one. The same Sharpe ratio is weak evidence after 24 tries and strong evidence after one pre-registered try. Neighbouring lookbacks are strongly correlated, so Bonferroni is conservative here and the honest number lies somewhere between the raw and the adjusted p-value. It still does not rescue a 0.31 Sharpe ratio that trails buy and hold.

Lab · what's graded

  • The Sharpe ratio15 pts
  • A trend rule with no look-ahead25 pts
  • A bootstrap interval25 pts
  • Searching and correcting35 pts
Explorer · lab-st-10
▾ lab-st-10
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-st-10$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-st-10 goes back to the starter files and the terminal is cleared. Your current solution will be lost — this can't be undone.

Will be reset
  • main.py → starter code
  • Terminal history and test output
  • Unsubmitted changes
Will be kept
  • Best lab score
  • Your XP and streak
  • Lecture progress and notes

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub