Skip to Content

BLACK_SCHOLES

Overview

The BLACK_SCHOLES function calculates the theoretical price of a European call or put option using the Black-Scholes formula. This function is widely used in financial engineering for pricing European-style options, risk management, and portfolio valuation. The Black-Scholes model assumes the underlying asset price follows a geometric Brownian motion with constant drift and volatility.

The Black-Scholes formulas are:

C=SN(d1)KerTN(d2)C = S N(d_1) - K e^{-rT} N(d_2) P=KerTN(d2)SN(d1)P = K e^{-rT} N(-d_2) - S N(-d_1)

where:

  • SS: Current price of the underlying asset
  • KK: Strike price
  • TT: Time to expiration in years
  • rr: Annual risk-free interest rate (decimal)
  • σ\sigma: Volatility of the underlying asset (decimal)
  • N()N(\cdot): Cumulative distribution function of the standard normal distribution
  • d1=ln(S/K)+(r+0.5σ2)TσTd_1 = \frac{\ln(S/K) + (r + 0.5 \sigma^2) T}{\sigma \sqrt{T}}
  • d2=d1σTd_2 = d_1 - \sigma \sqrt{T}

Assumptions:

This example function is provided as-is without any representation of accuracy.

Usage

To use in Excel:

=BLACK_SCHOLES(S, K, T, r, sigma, [option_type])
  • S (float, required): Current stock price.
  • K (float, required): Strike price of the option.
  • T (float, required): Time to expiration in years.
  • r (float, required): Risk-free interest rate (decimal).
  • sigma (float, required): Volatility of the stock (decimal).
  • option_type (string, optional, default=“call”): Type of option (“call” or “put”).

The function returns the Black-Scholes option price as a float, or an error message as a string if the input is invalid.

Examples

Example 1: European Call Option

In Excel:

=BLACK_SCHOLES(100, 105, 0.5, 0.03, 0.2, "call")

Expected output:

Option Price
4.18

Example 2: European Put Option

In Excel:

=BLACK_SCHOLES(50, 45, 1, 0.02, 0.25, "put")

Expected output:

Option Price
2.31

This means the function returns the theoretical price of the specified European option.

Python Code

import math from scipy.stats import norm def black_scholes(S, K, T, r, sigma, option_type="call"): """Calculate the Black-Scholes price for a European call or put option. Args: S: Current price of the underlying asset (float). K: Strike price (float). T: Time to expiration in years (float). r: Annual risk-free interest rate (decimal, float). sigma: Volatility of the underlying asset (decimal, float). option_type: 'call' or 'put' (string, optional, default="call"). Returns: float: Theoretical price of the option, or str: Error message if calculation fails. This example function is provided as-is without any representation of accuracy. """ try: S = float(S) K = float(K) T = float(T) r = float(r) sigma = float(sigma) except (ValueError, TypeError): return "Error: S, K, T, r, and sigma must be numeric." if not (S > 0): return "Error: S must be positive." if not (K > 0): return "Error: K must be positive." if not (T > 0): return "Error: T must be positive." if not (r >= 0): return "Error: r must be non-negative." if not (sigma > 0): return "Error: sigma must be positive." if option_type not in ("call", "put"): return "Error: option_type must be 'call' or 'put'." d1 = (math.log(S / K) + (r + 0.5 * sigma ** 2) * T) / (sigma * math.sqrt(T)) d2 = d1 - sigma * math.sqrt(T) if option_type == "call": price = S * norm.cdf(d1) - K * math.exp(-r * T) * norm.cdf(d2) else: price = K * math.exp(-r * T) * norm.cdf(-d2) - S * norm.cdf(-d1) return float(price)

Live Notebook

Edit this function in a live notebook.

Live Demo

Last updated on