Returns & Volatility — a minimal research note

quant
finance
basics
Published

January 11, 2026

This note computes log returns, annualized volatility, and visualizes the distribution for a liquid asset.

1 Definitions

Given a price series \(P_t\), the log return is:

\[ r_t = \ln\left(\frac{P_t}{P_{t-1}}\right) \]

Annualized volatility (assuming 252 trading days):

\[ \sigma_{\text{ann}} = \sqrt{252} \cdot \text{std}(r_t) \]

2 Compute (Python)

Code
import numpy as np
import pandas as pd
import yfinance as yf
import plotly.express as px

ticker = "SPY"
period = "2y"

df = yf.download(ticker, period=period, auto_adjust=True, progress=False)
df.columns = df.columns.droplevel(1)  # flatten MultiIndex columns
df = df[["Close"]].dropna()
df["r"] = np.log(df["Close"] / df["Close"].shift(1))
df = df.dropna()

sigma_daily = df["r"].std()
sigma_ann = np.sqrt(252) * sigma_daily
mu_daily = df["r"].mean()
mu_ann = 252 * mu_daily

summary = pd.DataFrame({
    "ticker": [ticker],
    "period": [period],
    "mu_daily": [mu_daily],
    "mu_ann": [mu_ann],
    "sigma_daily": [sigma_daily],
    "sigma_ann": [sigma_ann],
    "n_obs": [len(df)]
})

summary
ticker period mu_daily mu_ann sigma_daily sigma_ann n_obs
0 SPY 2y 0.000799 0.201399 0.010242 0.162592 501

3 Distribution

Code
fig = px.histogram(
    df,
    x="r",
    nbins=80,
    title=f"{ticker} log return distribution ({period})",
    marginal="box"
)
fig.update_layout(xaxis_title="log return", yaxis_title="count")
fig.show()