σμ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
  • 日本語
  • 中文
statsmodels skill›Module 2 · Models for time series›Topic 2.7·~55 minAdvanced

A local level model for noisy volatility

Skill positionModule 2 of 3 · Topic 7 of 9
2.7 A local level model for noisy volatility
—Lab score— / 100Total XP—Streak—

A hidden level behind noisy measurements

A state space model has a hidden state that evolves in time and noisy observations of it. The simplest, the local level model, is yₜ=μₜ+eₜ with eₜ (variance σ²ₑ), and μₜ=μₜ₋₁+hₜ with hₜ (variance σ²ₕ): the level μₜ is a random walk and each measurement adds independent noise. UnobservedComponents(y, level='llevel').fit(disp=False) estimates σ²ₑ (named sigma2.irregular) and σ²ₕ (sigma2.level) by maximum likelihood. The ratio q=σ²ₕ/σ²ₑ is the signal-to-noise ratio: a small q means a slow level and a lot of noise to average out. For the monthly log volatility of SPY over 258 months, σ̂²ₑ=0.089 and σ̂²ₕ=0.045, so q=0.50.

The Kalman filter estimates the level in two steps each month: predict μ̂_(t|t-1)=μ̂_(t-1|t-1), then correct it with the surprise, μ̂_(t|t)=μ̂_(t|t-1)+Kₜ (yₜ-μ̂_(t|t-1)). After a start-up the gain settles at K=P/(P+1) with P=1/2(q+√(q²+4q)), and the filter is then exactly an exponentially weighted moving average with weight K: K=0.502 here, and pd.Series(y).ewm(alpha=K, adjust=False).mean() matches the filtered level to 7×10⁻¹⁰. The same model is an ARIMA(0,1,1) with moving-average coefficient -(1-K)=-0.498: both have an AIC of 290.526. The filtered level res.filtered_state[0] uses data up to t only. The smoothed level res.smoothed_state[0] uses the whole sample: cut the data at month 200 with the same parameters and the filtered level does not change at all, while the smoothed level moves by 0.116. A smoother is a tool for looking back, never a signal. The forecast of the level is flat at -2.09 and its 95% interval widens from ±0.83 to ±1.61.

  • Noise plus level: the signal-to-noise ratio q sets how much each new observation moves the estimate.
  • The filter is an EWMA and the local level model is an ARIMA(0,1,1): three names for one idea.
  • Filtered uses the past, smoothed uses the future: never trade on a smoothed series.

Lab · what's graded

  • The local level fit10 pts
  • The two variances10 pts
  • Filtered and smoothed levels5 pts
  • The steady-state gain15 pts
  • The filter as an EWMA15 pts
  • Does it look ahead?20 pts
  • An ARIMA in disguise10 pts
  • The volatility study15 pts
Explorer · lab-sx-18
▾ lab-sx-18
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-sx-18$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-sx-18 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