Skip to main content

Generate probability distributions on the future price of publicly traded securities using options data

Project description

OIPD: options-implied probability distribution

Python versions Open in Colab Discord Downloads

Overview

OIPD computes the probabilities of an asset's future price as implied by the options market.

It does this by taking listed options data, fitting an arbitrage-free implied volatility surface, and then transforming that fitted object into a probability distribution over future asset prices. In practice, that provides two core capabilities in one library:

  • Volatility modeling: fit single-expiry smiles and multi-expiry volatility surfaces, and compute greeks.
  • Probability extraction: compute market-implied probability distributions, and distribution statistics.

Read the docs · Use the web interface

Quick install

The standard install includes the built-in yfinance data connection.

pip install oipd

One quick example

Fetch GameStop options across the next twelve months, fit a VolSurface, derive a ProbSurface, and plot the fan chart.

import matplotlib.pyplot as plt

from oipd import MarketInputs, VolSurface, sources

ticker = "GME"
chain, snapshot = sources.fetch_chain(
    ticker,
    horizon="12m",  # fetch all listed expiries inside the next 12 months
)

market = MarketInputs(
    valuation_date=snapshot.asof,
    underlying_price=snapshot.underlying_price,
    risk_free_rate=0.04,
)

vol_surface = VolSurface().fit(chain, market)
surface = vol_surface.implied_distribution()

fig = surface.plot_fan()
plt.show()

GME ProbSurface fan plot generated by OIPD

surface.plot_fan() visualizes the market-implied price distribution across fitted option expiries.

You can also take one expiry from the surface and query it as a ProbCurve.

curve = surface.slice(surface.expiries[-1])  # take the last expiry

print(curve.prob_below(25))  # P(GME price < 25) at that expiry
print(curve.quantile(0.50))  # median implied price at that expiry

fig = curve.plot()
fig.axes[0].set_xlim(0, 100)
plt.show()

GME ProbCurve slice generated from a ProbSurface

A surface slice returns a ProbCurve, so you can inspect one expiry as a standalone probability distribution.

Example Notebooks

See more examples for demos.

Community

Pull requests welcome! Reach out on GitHub issues to discuss design choices.

Join the Discord community to share ideas, discuss strategies, and get support. Message me with your feature requests, and let me know how you use this.

Contributors

Thanks to everyone who has contributed code:

Contributors

And special thanks for support on theory, implementation, or advisory:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oipd-2.0.4.tar.gz (282.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oipd-2.0.4-py3-none-any.whl (221.1 kB view details)

Uploaded Python 3

File details

Details for the file oipd-2.0.4.tar.gz.

File metadata

  • Download URL: oipd-2.0.4.tar.gz
  • Upload date:
  • Size: 282.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for oipd-2.0.4.tar.gz
Algorithm Hash digest
SHA256 0c822dd3a613bf5f4f03f4810367ca2084999b8c66d1bc0cdcf27dc7ba005b7d
MD5 dd1a521139f24f70aea1d5fdeca788d0
BLAKE2b-256 9c26ab027756be1200bdcc0548d625dec551f9646f07f98ffed7f33ee7a67373

See more details on using hashes here.

File details

Details for the file oipd-2.0.4-py3-none-any.whl.

File metadata

  • Download URL: oipd-2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 221.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for oipd-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a344afd3da0f76d31ae66b8b34310386f7380638de36bbc0bc5e422105768caa
MD5 086cbde4ed8c0fc4e1c883f3a72bb752
BLAKE2b-256 857281549fb9fa47f031732a7719fcdbdb30d552f50fe6041f22f9ff3c5eb317

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page