Skip to content

vivek-v-rao/NonNormalOptionLab

Repository files navigation

Non-Normal Option Pricing Playground

xnonnormal_option_prices.py is a self-contained comparison harness that computes European option prices (call/put/straddle), Black–Scholes implied volatilities, and distribution moments when the terminal log-price or price follows many different parametric families rather than the usual normal law. xfit_distributions.py plus fit_distributions.py simulate data from a configurable Gaussian mixture and fit several of the same families via SciPy or bespoke MLE routines, saving fit diagnostics to CSV/PNG.

Highlights

Requirements

  • Python 3.11+
  • numpy, pandas, scipy, matplotlib (for plotting)

Install dependencies with:

python -m pip install -r requirements.txt

(Create requirements.txt if needed; current scripts only rely on NumPy, Pandas, SciPy, and Matplotlib.)

Running the option-comparison script

python xnonnormal_option_prices.py

Key settings (all at the top of the file, no CLI flags yet):

  • s0, r, q, t, sigma: market inputs.
  • option_type: "c", "p", or "straddle" (default is "straddle").
  • requested: list of distribution families to study (e.g. ["normal", "hypsecant", "vg"]); set max_dist to truncate the list.
  • Distribution-specific parameter grids such as vg_thetas, gh_shapes, sgsh_shapes, etc.
  • strike_min/max/step and strike_table_stride (set stride to 0 to hide strike-by-strike tables and just emit summary statistics).
  • log_price_mode toggles log-return vs. direct price densities.
  • PLOT_* and CSV constants control whether prices/vols are printed, plotted, or saved (option_prices.csv, implied_vols.csv, density.png, vol.png).
  • print_iv_stats optionally summarizes implied-vol curvature stats by distribution.

Each run prints:

  1. Optional price and implied-volatility tables (depending on strike_table_stride).
  2. Log-return or terminal-price moment tables (matching log_price_mode).
  3. A "Terminal price moments" block (always shown).
  4. Diagnostics for any distributions that failed calibration/integration.

If PLOT_* filenames are set, density/volatility curves are saved instead of shown. CSV files use the same labels as the console tables for easy filtering. An example implied-vol plot generated by the script is shown below:

Implied volatility comparison

Running the fitting workflow

python xfit_distributions.py

Workflow (matching the current script defaults):

  1. Simulates nobs = 1000 draws from a two-component Gaussian mixture [(0.1, -0.3, 3.0), (0.9, 0.3, 1.0)].
  2. Prints descriptive statistics for the sample.
  3. Fits each distribution listed in candidates (["normal", "skew_normal", "gsh", "sgsh", "t", "nct"] by default) via fit_distribution.
  4. Logs per-fit metrics (log-likelihood, KS statistic/p-value, parameter count, timing, and parameter estimates).
  5. Saves fit_summary.csv with standardized columns (distribution, scipy_name, loglike, mean_density, …, params, param_names) plus fit_densities.png comparing the empirical histogram, ground-truth mixture, and each fitted pdf.

Tweak nobs, components, candidates, or DENSITY_PLOT_FILE to explore other scenarios. Custom fitters registered in fit_distributions.py’s CUSTOM_FITTERS dictionary (CGMY, GSH, SGSH, NEF–GHS, VG, etc.) can be added to the candidates list as needed.

Custom distributions and extensions

  • Custom MLE routines in fit_distributions.py are registered via the CUSTOM_FITTERS dictionary; add new entries there to extend xfit_distributions.py.
  • New option-pricing densities require:
    1. Implementing pdf/MGF/tail helpers inside distributions.py.
    2. Adding their pricing logic to option_pricing.py.
    3. Registering them in xnonnormal_option_prices.py’s requested builder.

Status

This is an exploratory research tool rather than production code. Numerical integration tolerances, parameter grids, and plotting defaults are tuned for robustness but can be slow for very heavy-tailed densities—feel free to adjust quad_limit, strike grids, or distribution lists as needed.

Contributions and suggestions for additional distributions or calibration methods are welcome.

About

Option pricing with non-normal price or log price distributions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages