σμ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
  • 日本語
  • 中文
Particle filtering and non-stationary time series skill›Module 3 · A market that keeps changing›Topic 3.2·~50 minAdvanced

Rolling exponential and online estimators

Skill positionModule 3 of 3 · Topic 2 of 3
3.2 Rolling exponential and online estimators
—Lab score— / 100Total XP—Streak—

How much memory should an estimate have?

When the market keeps changing, an estimate needs a memory that fades. A rolling window gives equal weight to the last WWW observations and none to older ones, so the estimate jumps when a big day enters and again when it leaves WWW days later. An exponentially weighted estimate gives the observation kkk days ago the weight (1−λ)λk(1-\lambda)\lambda^{k}(1−λ)λk, so the past fades smoothly. Its variance estimate needs only yesterday's value: st2=λst−12+(1−λ)rt2s_t^{2}=\lambda s_{t-1}^{2}+(1-\lambda)r_t^{2}st2​=λst−12​+(1−λ)rt2​. A fully online estimate updates with the new observation only and forgets it afterwards, for example a running mean mn=mn−1+(xn−mn−1)/nm_n=m_{n-1}+(x_n-m_{n-1})/nmn​=mn−1​+(xn​−mn−1​)/n.

st2=λ st−12+(1−λ) rt2,wk=(1−λ)λk,t1/2=ln⁡(1/2)ln⁡λ,We=1+λ1−λs_t^{2}=\lambda\,s_{t-1}^{2}+(1-\lambda)\,r_t^{2},\qquad w_k=(1-\lambda)\lambda^{k},\qquad t_{1/2}=\frac{\ln(1/2)}{\ln\lambda},\qquad W_{e}=\frac{1+\lambda}{1-\lambda}st2​=λst−12​+(1−λ)rt2​,wk​=(1−λ)λk,t1/2​=lnλln(1/2)​,We​=1−λ1+λ​(1)

The same idea runs through all three: new estimate = old estimate + gain ×\times× surprise. A constant gain g=1−λg=1-\lambdag=1−λ gives the exponential estimator. A gain of 1/n1/n1/n gives the plain average of all data. The Kalman filter chooses the gain by itself from the noise levels, so it is the principled version. Memory is a trade-off: a short memory follows changes quickly but is noisy, a long memory is smooth but slow. The half-life ln⁡(1/2)/ln⁡λ\ln(1/2)/\ln\lambdaln(1/2)/lnλ tells how many days it takes for an observation to lose half its weight, and the effective window (1+λ)/(1−λ)(1+\lambda)/(1-\lambda)(1+λ)/(1−λ) is the equal-weight window with similar noise. The common daily choice λ=0.94\lambda=0.94λ=0.94 has a half-life of 11.211.211.2 days and an effective window of 32.332.332.3 days.

Hand numbers and real SPYWith λ=0.94\lambda=0.94λ=0.94, yesterday's variance 0.00010.00010.0001 (a 1%1\%1% daily volatility) and a return of −3%-3\%−3%, the new variance is 0.94×0.0001+0.06×0.0009=0.0001480.94\times0.0001+0.06\times0.0009=0.0001480.94×0.0001+0.06×0.0009=0.000148, a volatility of 1.217%1.217\%1.217%. An observation 101010 days old keeps the weight 0.06×0.9410=0.03230.06\times0.94^{10}=0.03230.06×0.9410=0.0323. A running mean of 0.020.020.02 after 444 values, meeting x=0.07x=0.07x=0.07, becomes 0.02+(0.07−0.02)/5=0.030.02+(0.07-0.02)/5=0.030.02+(0.07−0.02)/5=0.03. On SPY the 0.940.940.94 estimator peaks at 84.7%84.7\%84.7% annual volatility on 28 October 2008, while a 60-day rolling window peaks at 75.5%75.5\%75.5% on 8 December, six weeks later. On 16 March 2020 it reads 80.8%80.8\%80.8% against 47.4%47.4\%47.4% for the rolling window.
  • Same recipe: new = old + gain ×\times× surprise; the gain sets the memory.
  • Rolling is abrupt, exponential is smooth: a rolling window drops old data all at once, and an exponential one fades it.
  • Memory is a trade-off: short memory is fast and noisy, long memory is slow and smooth.

Lab · what's graded

  • An exponentially weighted update15 pts
  • The half-life10 pts
  • The effective window10 pts
  • An old observation10 pts
  • An online mean10 pts
  • Which one forgets abruptly10 pts
  • An online update10 pts
  • Match the vocabulary10 pts
  • Why exponential reacts faster15 pts
0/ 9 answered
Tasks
1Numeric answer15 ptsNot answered

With λ=0.94\lambda=0.94λ=0.94, yesterday's variance 0.00010.00010.0001 and today's return −3%-3\%−3%, the new variance is 0.0001480.0001480.000148. What is the new daily volatility in percent? Give three decimals.

v=v =v=accepted: ± 0.005
2Numeric answer10 ptsNot answered

With λ=0.94\lambda=0.94λ=0.94, how many days does it take for an observation to lose half its weight, ln⁡(1/2)/ln⁡λ\ln(1/2)/\ln\lambdaln(1/2)/lnλ? Give one decimal.

t=t =t=accepted: ± 0.1
3Numeric answer10 ptsNot answered

With λ=0.94\lambda=0.94λ=0.94, what is the effective window (1+λ)/(1−λ)(1+\lambda)/(1-\lambda)(1+λ)/(1−λ) in days? Give one decimal.

w=w =w=accepted: ± 0.2
4Numeric answer10 ptsNot answered

With λ=0.94\lambda=0.94λ=0.94, what weight (1−λ)λk(1-\lambda)\lambda^{k}(1−λ)λk does an observation k=10k=10k=10 days old have? Give four decimals.

w=w =w=accepted: ± 0.0003
5Numeric answer10 ptsNot answered

The running mean is 0.020.020.02 after 444 values. A fifth value x=0.07x=0.07x=0.07 arrives. What is the new mean m5=m4+(x−m4)/5m_5=m_4+(x-m_4)/5m5​=m4​+(x−m4​)/5? Give three decimals.

m=m =m=accepted: ± 0.0005
6Choice10 ptsNot answered

Which estimator treats an observation at full weight until a certain day and then drops it completely?

7Order the steps10 ptsNot answered

Put the steps of an online update in order.

Drag to reorder, or focus an item, press Space to lift it, the arrow keys to move it and Space to drop it.

  1. 1Add the scaled surprise to the old estimate
  2. 2Receive the new observation
  3. 3Keep only the new estimate and discard the observation
  4. 4Multiply the surprise by the gain
  5. 5Compute the surprise: observation minus old estimate
8Match10 ptsNot answered

Match each term with its meaning.

Pick the partner of each item on the left.

Rolling window
Exponential weights
Half-life
Gain
9Explain in words15 ptsNot answered

At the start of the March 2020 crash, the 0.940.940.94 estimator read 80.8%80.8\%80.8% volatility and the 60-day rolling window read 47.4%47.4\%47.4%. In one or two sentences, explain why.

Math modeKeyboard or LaTeX inputTask 1 of 9 · Ctrl ⏎ to check

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