ProbCurve, and querying the resulting risk-neutral probability distribution. By the end you will have a working script you can adapt to any ticker.
Install
Install the library from PyPI. The standard install includes the built-in yfinance data connection used in this guide.
Fetch data
Import the modules you need, then use
sources.list_expiry_dates to see every available expiry for your ticker. Pass one of those dates to sources.fetch_chain to download the options chain and a market snapshot at the moment of download.chain contains the full options chain (calls and puts, strikes, bid/ask, open interest). snapshot captures the underlying price and the timestamp of the download — both of which you need in the next step.MarketInputs
MarketInputs bundles the three pieces of market context that OIPD needs to fit the model: the valuation date, the underlying price, and the risk-free rate. Pull the first two directly from the snapshot you just downloaded.Fit
Pass The returned
chain and market to ProbCurve.from_chain. This single call fits the SVI implied volatility smile and derives the risk-neutral probability distribution in one step.prob object is fully fitted and immediately queryable. No separate .fit() call is needed when using the from_chain factory.Query
Use the query methods on the fitted
ProbCurve to extract the statistics you care about.| Method | What it returns |
|---|---|
prob_below(k) | Cumulative probability that the price is below strike k |
prob_above(k) | Probability that the price is at or above strike k |
quantile(q) | The price level at the q-th quantile of the distribution |
skew() | Skewness of the fitted risk-neutral distribution |
Plot
Call To save the chart instead:Example output:
prob.plot() to render the probability distribution as a chart. It returns a Matplotlib Figure, so you can save it or customise it with standard Matplotlib calls.
This example uses live option data, so your chart will differ as prices, expiries, and spreads update.
Complete script
Here is the full example in one block, ready to copy and run:Next steps
Probability surface
Fetch a multi-expiry chain with
sources.fetch_chain(..., horizon="12m"), then pass it to ProbSurface.from_chain.Volatility smile
Work directly with
VolCurve and VolSurface to evaluate implied vols, price options, and compute Greeks.Data sources
Load data from a CSV or Pandas DataFrame instead of yfinance for corporate or internal data environments.
Warnings
Understand how OIPD surfaces data quality and model risk issues through structured diagnostics on every fitted object.