Log Returns and Volatility (σ) TODO
Concept
Log return is defined as the natural logarithm of the ratio of consecutive prices, ln(P_t/P_{t-1}). Unlike simple returns, log returns add up over consecutive periods, which makes multi-period aggregation easy, treats gains and losses symmetrically, and is nearly identical to the simple return when the value itself is small. Volatility σ is the standard deviation of these returns; under the assumption that returns are independent and identically distributed, it scales with the square root of the time period, so short-interval volatility is converted to a longer horizon by multiplying by the square root of the number of periods. Real financial time series don't fully satisfy that assumption — they show fat tails and volatility clustering — which is why realized volatility computed from historical data differs from the implied volatility backed out of option prices. The choice of sample window length and observation frequency has a large effect on the estimate.
Risk limits, margin, and pricing models all rest on volatility figures, but mechanically applying square-root-of-time scaling systematically underestimates tail risk. Knowing which assumptions a given number rests on is the whole point.
Code & Formula
# Day 36 — 로그수익률·변동성(σ)
# 짧은 가격 시계열에서 로그수익률을 계산하고 표준편차(변동성)를 구한 뒤, 기간 환산을 보여준다.
import math
prices = [100.0, 101.5, 99.8, 102.3, 103.0, 101.0, 104.5, 103.8, 106.0, 105.2]
log_returns = [math.log(prices[i] / prices[i - 1]) for i in range(1, len(prices))]
n = len(log_returns)
mean_r = sum(log_returns) / n
variance = sum((r - mean_r) ** 2 for r in log_returns) / (n - 1) # 표본분산 (n-1)
daily_vol = math.sqrt(variance)
print("가격:", prices)
print("\n일별 로그수익률:")
for i, r in enumerate(log_returns, start=1):
print(f" day {i}: {r:+.5f}")
print(f"\n평균 로그수익률 = {mean_r:.5f}")
print(f"일간 변동성(σ_daily) = {daily_vol:.5f}")
# 연환산: iid 가정 아래 변동성은 기간 수의 제곱근에 비례
trading_days = 252
annual_vol = daily_vol * math.sqrt(trading_days)
print(f"연환산 변동성(σ_annual, sqrt(252) 법칙) = {annual_vol:.5f} ({annual_vol*100:.2f}%)")
Exercise
Take a daily closing-price series for any asset, compute log returns, derive the standard deviation and its square-root-time-scaled value, then compare the frequency of extreme moves the normal-distribution assumption predicts against what actually occurred.
Practical Connection
Prediction-market prices are probabilities bounded between 0 and 1, so log returns don't apply directly, but converting to log-odds aligns with the way LMSR prices respond linearly to holdings — giving volatility analysis a natural coordinate system.
Where it lands in Jayverse
- Verex: track LMSR/CLOB market-maker volatility in log-odds space, and size the market maker's risk parameter (b) from it. Not from raw price volatility, and not arbitrarily.
- Number: publish realized vs LMSR-consistent volatility for active Verex markets as a reading. Flag when square-root-of-time scaling would understate tail risk on a fat-tailed market.
- Verex: pick and document sample window and observation frequency explicitly for any volatility-based margin or risk limit. The exercise shows the estimate is sensitive to both, so an undocumented choice is an unstated risk decision.
Key expressions
| Expression | 뜻 · 쓰이는 자리 |
|---|---|
| add up over | (여러 기간에 걸쳐) 누적 합산되다 · 로그수익률은 여러 구간을 더해도 그대로 맞아떨어진다는 성질 · "log returns add up over consecutive periods" |
| scales with the square root of | ~의 제곱근에 비례해 커지다 · 변동성을 기간별로 환산할 때 쓰는 법칙 · "it scales with the square root of the time period" |
| fat tails | 팻테일, 두꺼운 꼬리분포 · 극단적인 값이 정규분포 예측보다 자주 나타나는 현상 · "they show fat tails and volatility clustering" |
| volatility clustering | 변동성 군집현상 · 변동성이 큰 시기 뒤에 또 변동성이 큰 시기가 이어지는 경향 · "and volatility clustering, which is why" |
| backed out of | (가격 등에서 역산하여) 도출하다 · 옵션 가격에서 내재변동성을 거꾸로 계산해낸다는 뜻 · "the implied volatility backed out of option prices" |
| underestimates | 과소평가하다 · 특정 가정이 실제 위험을 실제보다 낮게 잡는다는 뜻 · "systematically underestimates tail risk" |
| rest on | ~에 근거하다, ~을 전제로 하다 · 어떤 수치가 어떤 가정 위에 서 있는지를 물을 때 · "which assumptions a given number rests on" |
| LMSR | 로그시장점수규칙(Logarithmic Market Scoring Rule) · 예측시장 가격이 보유량에 선형으로 반응하도록 설계된 자동화 가격결정 메커니즘. "the way LMSR prices respond linearly to holdings" |
If you study this on a given day, add a note link and a ✅ to this line in the source curriculum (docs/knowledge/math-50-curriculum.md) and this spot will lead straight to the note body. You can also write directly on this page — but regenerating overwrites it, so it's safer to keep anything you want to save as markdown under docs/algorithms/.