The Greeks and Option Risk Management › Greeks Calculator
Quantitative FinanceAll chapters The Greeks and Option Risk Management › Greeks CalculatorOne section · Sections in this chapter11 / 14 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Let's bring everything together in a complete implementation that calculates all Greeks and visualizes the risk profile of an option position. We encapsulate the logic in a class to manage the parameters and calculations cleanly, and gives methods for each Greek and a summary report:
import numpy as np
from scipy.stats import norm
class BlackScholesGreeks:
"""Complete Black-Scholes Greeks calculator."""
def __init__(self, S, K, T, r, sigma, option_type="call"):
self.S = S
self.K = K
self.T = max(T, 1e-10) # Avoid division by zero
self.r = r
self.sigma = sigma
self.option_type = option_type
# Calculate d1 and d2
sqrt_T = np.sqrt(self.T)
self.d1 = (np.log(S / K) + (r + 0.5 * sigma**2) * self.T) / (
sigma * sqrt_T
)
self.d2 = self.d1 - sigma * sqrt_T
def price(self):
"""Calculate option price."""
if self.option_type == "call":
return self.S * norm.cdf(self.d1) - self.K * np.exp(
-self.r * self.T
) * norm.cdf(self.d2)
else:
return self.K * np.exp(-self.r * self.T) * norm.cdf(
-self.d2
) - self.S * norm.cdf(-self.d1)
def delta(self):
"""Calculate delta."""
if self.option_type == "call":
return norm.cdf(self.d1)
else:
return norm.cdf(self.d1) - 1
def gamma(self):
"""Calculate gamma."""
return norm.pdf(self.d1) / (self.S * self.sigma * np.sqrt(self.T))
def theta(self):
"""Calculate theta (per year)."""
term1 = -self.S * norm.pdf(self.d1) * self.sigma / (2 * np.sqrt(self.T))
if self.option_type == "call":
term2 = (
-self.r * self.K * np.exp(-self.r * self.T) * norm.cdf(self.d2)
)
else:
term2 = (
self.r * self.K * np.exp(-self.r * self.T) * norm.cdf(-self.d2)
)
return term1 + term2
def vega(self):
"""Calculate vega."""
return self.S * np.sqrt(self.T) * norm.pdf(self.d1)
def rho(self):
"""Calculate rho."""
if self.option_type == "call":
return (
self.K * self.T * np.exp(-self.r * self.T) * norm.cdf(self.d2)
)
else:
return (
-self.K * self.T * np.exp(-self.r * self.T) * norm.cdf(-self.d2)
)
def all_greeks(self):
"""Return all Greeks as a dictionary."""
return {
"Price": self.price(),
"Delta": self.delta(),
"Gamma": self.gamma(),
"Theta (daily)": self.theta() / 365,
"Vega (per 1%)": self.vega() / 100,
"Rho (per 1%)": self.rho() / 100,
}# Parameters
S, K, T, r, sigma = 100, 100, 0.25, 0.05, 0.20
# Example usage
call_option = BlackScholesGreeks(S, K, T, r, sigma, option_type="call")
put_option = BlackScholesGreeks(S, K, T, r, sigma, option_type="put")ATM Options (S=100, K=100, T=3 months, r=5%, σ=20%) ============================================================ Metric Call Put ------------------------------------------------------------ Price 4.6150 3.3728 Delta 0.5695 -0.4305 Gamma 0.0393 0.0393 Theta (daily) -0.0287 -0.0152 Vega (per 1%) 0.1964 0.1964 Rho (per 1%) 0.1308 -0.1161
The table demonstrates the fundamental parity relationships. Gamma and vega are identical for calls and puts with the same parameters, showing that curvature and volatility risks are independent of direction. Delta values diverge, which reflects the opposing directional views, while theta remains negative for both long positions.
# Create comprehensive Greeks visualization
S_range = np.linspace(70, 130, 200)
K, T, r, sigma = 100, 0.25, 0.05, 0.20
greeks_data = {"delta": [], "gamma": [], "theta": [], "vega": []}
for S in S_range:
opt = BlackScholesGreeks(S, K, T, r, sigma, "call")
greeks_data["delta"].append(opt.delta())
greeks_data["gamma"].append(opt.gamma())
greeks_data["theta"].append(opt.theta() / 365)
greeks_data["vega"].append(opt.vega() / 100)



The profile shows how each Greek behaves as the stock price changes. Delta rises from 0 to 1 as the option goes from OTM to ITM. Gamma peaks where delta changes fastest (ATM). Theta is most negative ATM where time value is highest. Vega also peaks ATM, showing that volatility sensitivity is concentrated near the strike.