Skip to content

Personal project exploring options pricing and implied volatility using the Black-Scholes model. It fetches real market data, computes IVs, compares them with market values, and visualizes 2D/3D volatility surfaces — showcasing skills in Python, quantitative finance, data analysis, and financial modeling.

License

Notifications You must be signed in to change notification settings

ShresthaAbhishek/IV-Surface-Analysis

Repository files navigation

Implied Volatility Analysis for Options Pricing

Hi, I'm Abhishek. This project explores options pricing by computing and analyzing implied volatility (IV) for SPY ETF options using the Black-Scholes model. It fetches real-time option chain data, calculates IV with a bisection solver, compares it to market IV, and visualizes results with 2D and 3D plots to reveal volatility surface patterns. The stock ticker can be changed as desired.


Purpose of the Project

The main goal of this project is to bridge theoretical option pricing models with real market data. Specifically, it aims to:

  • Calculate theoretical option prices using the Black-Scholes model
  • Compute implied volatility from market-traded options
  • Compare model outputs with market-reported IVs
  • Visualize the volatility surface across strikes and expiration dates

This helps traders, quants, and researchers understand the dynamics of option prices, uncover pricing discrepancies, and evaluate the behavior of implied volatility across moneyness and time to expiry.


Black-Scholes Model: Idea & Formulas

The Black-Scholes model is a foundational model for European option pricing. It assumes:

  • The underlying stock follows a log-normal stochastic process
  • Constant risk-free interest rate and volatility
  • No arbitrage opportunities

It provides a closed-form formula for option prices:

Call Option:

$$ C = S e^{-qT} \Phi(d_1) - K e^{-rT} \Phi(d_2) $$

Put Option:

$$ P = K e^{-rT} \Phi(-d_2) - S e^{-qT} \Phi(-d_1) $$

Where:

$$ d_1 = \frac{\ln(S/K) + (r-q+0.5\sigma^2)T}{\sigma \sqrt{T}}, \quad d_2 = d_1 - \sigma \sqrt{T} $$

Parameters:

  • $S$ = current stock price
  • $K$ = strike price
  • $T$ = time to expiration (in years)
  • $r$ = risk-free rate
  • $q$ = dividend yield
  • $\sigma$ = volatility
  • $\Phi$ = cumulative distribution function of the standard normal

Intuition:

  • $d_1$ captures how far “in-the-money” an option is, adjusted for expected growth and volatility
  • $d_2$ accounts for the remaining uncertainty until expiration
  • The formula calculates the expected discounted payoff under risk-neutral probabilities, giving the fair theoretical price of the option

This theoretical framework forms the basis for computing implied volatility, which is the volatility value that equates the Black-Scholes price to the observed market price.


Key Ideas Used

This project combines several fundamental quantitative finance and computational concepts:

  • Black-Scholes Model: Pricing European options with closed-form formulas
  • Implied Volatility (IV): IV is inferred from market prices using a numerical bisection solver
  • Data Handling: Real-time option chain data is fetched using yfinance
  • Visualization: 2D and 3D plots illustrate the volatility surface and ATM ±15% range
  • Numerical Methods: Bisection root-finding, grid interpolation, and Gaussian smoothing are applied for accurate and smooth IV surfaces

Why This Matters

Understanding implied volatility is critical in options trading and risk management:

  • Provides a practical workflow for assessing option prices against theoretical models
  • Highlights differences between model predictions and market behavior
  • Visualizes risk and uncertainty in the options market through volatility surfaces
  • Develops familiarity with numerical techniques and data visualization used in quantitative finance

Skills Demonstrated

  • Option pricing with the Black-Scholes model
  • Implied volatility computation using numerical root-finding
  • Real-world data handling with Python, pandas, and yfinance
  • Visualization using Matplotlib and Plotly
  • Evaluating model accuracy and identifying ATM and near-the-money option patterns
  • Working with numerical interpolation and smoothing for visualization

Example Outputs

1. 2D Implied Volatility Comparison

Comparison of computed IVs from the Black-Scholes model against market IVs across various strikes.

2D IV Comparison


2. 3D Implied Volatility Surface

3D visualization of the implied volatility surface plotted against moneyness (strike/spot ratio) and time to expiry.

3D IV Surface


3. ATM ±15% IV Surface Focus

Zoomed-in IV surface for ATM ±15% strikes, where most trading activity occurs.

ATM Surface



High-Level Workflow

  1. Fetch real-time option chain data using yfinance.
  2. Calculate theoretical option prices with the Black-Scholes formula.
  3. Solve for implied volatility (IV) numerically via a bisection solver.
  4. Compare computed IV to market IVs and generate accuracy metrics.
  5. Visualize IVs across strikes and expirations using 2D scatter plots and 3D surfaces.
  6. Focus on ATM ±15% strikes for detailed insights into high-liquidity options.

Resources & References


About

Personal project exploring options pricing and implied volatility using the Black-Scholes model. It fetches real market data, computes IVs, compares them with market values, and visualizes 2D/3D volatility surfaces — showcasing skills in Python, quantitative finance, data analysis, and financial modeling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published