Home Research Data & Code

💻 Code & 📦 Data

This page contains some (hopefully) useful Python code and data used in our research. An acknowledgement and citation of doi.org/10.17605/OSF.IO/Z2486 in your paper would be much appreciated.

💻 Code

Option-Implied Moments (Python)

qmoms 0.1.3 is live on GitHub and PyPI (105 tests passed).

Feed it an implied-volatility surface (moneyness × maturity) and get a full set of research-grade option-implied moments in one call — model-free variance, skewness/kurtosis, downside risk, tail steepness, jump risk, corridor VIX, and (with returns) generalized lower bounds on expected returns. Same measures that appear in RFS / JF / QJE / MS papers, without re-implementing the integrations.

✨ Why it is useful — what you get
Output What it captures
mfiv_bkm, mfiv_bjn, smfiv Model-free implied variance (log & simple contracts)
mfis, mfik Risk-neutral skewness and kurtosis
smfivd, mfivd_* Downside semivariance (crash risk priced in options)
slopedn, slopeup Left/right smile steepness — how expensive tails are vs ATM
rix, tlm_* Tail jump and tail-loss measures
cvix_* Corridor VIX (variance inside a strike band)
GLB_* Option-implied lower bounds on expected excess returns
Bundled example data (surface, rates, returns) ships with the package, so you can reproduce outputs immediately after pip install.
🚀 Quick start
from qmoms import load_data, default_params, filter_options
from qmoms import get_rate_for_maturity, qmoms_compute

df_surf, df_rate, _ = load_data()          # rates already annual decimals
df_surf = filter_options(df_surf, default_params['filter'])

ids, g = next(iter(df_surf.groupby(['id', 'date', 'days'])))
rate = get_rate_for_maturity(df_rate, date=ids[1], days=ids[2])

qout = qmoms_compute(
    mnes=g.mnes, vol=g.impl_volatility,
    days=ids[2], rate=rate, params=default_params,
)
print(qout)

Sample output for one surface slice (id=12490, 2023-01-03, 30 days):

nopt         17.000     # options used
smfiv         0.094     # simple MFIV ≈ 9.4% variance
mfiv_bkm      0.097     # BKM log MFIV
mfis         -0.531     # risk-neutral skew (left-skewed)
mfik          3.566     # risk-neutral kurtosis
rix           0.003     # left-tail jump measure
slopedn       0.172     # put-wing steepness
slopeup      -0.053     # call-wing steepness
Over the bundled panel (3,750 id/date/maturity groups): mean mfis ≈ −0.64 (typical equity left skew), mean slopedn ≈ 0.26 — left tails systematically more expensive than right. Full scripts: qmoms_test.py, qmoms_glb_test.py.
📁 Computed Moments & Characteristics

qmoms uses out-the-money (OTM) implied volatilities interpolated as a function of moneyness (Strike/Underlying or Strike/Forward) within the available range. Outside the available range, boundary values are extended. OTM Definition: moneyness ≥ 1 for calls and < 1 for puts.

📦 Data

Data hosted in OSF Data Repository

Direct Downloads

  • From Carbon Tail Risk (2021 RFS)
    📊 Excel Data (2020-05-20)

  • From Measuring Equity Risk with Option-implied Correlations (2012 RFS)
    📁 Zipped mat Data (1996–2009)

    Contents

    Contains 5 MATLAB .mat files:

    • market_betas_1996_2009.mat:
      Structure betas with 6 different beta methodologies, aligned to a common timeline in time vector dt. Also includes permno ID vector. In the paper we used:

      • implied: impl_daily_251d_mfiv, impl_monthly_60m_mfiv
      • historical: hist_daily_251d, hist_monthly_60m
    • id_dt.mat:
      Time vector dt, and vector of IDs (PERMNO from CRSP). The first PERMNO = 999999 is the market itself (S&P 500).

    • weights.mat:
      Synthetic weights w of stocks in the S&P 500. The first column is NaN because it refers to the market itself.

    • dailyret.mat:
      Daily returns (ret and retx for ex-div returns) for the S&P 500 and its components.

    • mnthly_ret.mat:
      Monthly returns retm for the S&P 500 and its components. Includes time vector dtm.