Here is where the programmer’s edge really shows. The pricing of an option — which looks like deep finance — is about ten lines of Python. And understanding one output of it, implied volatility, is what separates people who gamble on options from people who actually understand what they are paying for.
Black-Scholes: five inputs, one price
The Black-Scholes model gives the fair price of a European option from five inputs:
| Input | Meaning | Known? |
|---|---|---|
| S | Spot price of the underlying | yes |
| K | Strike price | yes |
| T | Time to expiry (in years) | yes |
| r | Risk-free interest rate | yes (~7% in India) |
| σ | Volatility of the underlying | this is the question |
Four of the five are known. The whole art is in the fifth — volatility. Here is the model in runnable Python:
from math import log, sqrt, exp, erf
def N(x): return 0.5 * (1 + erf(x / sqrt(2))) # standard normal CDF
def black_scholes(S, K, T, r, sigma, call=True):
d1 = (log(S/K) + (r + sigma**2/2)*T) / (sigma*sqrt(T))
d2 = d1 - sigma*sqrt(T)
if call:
return S*N(d1) - K*exp(-r*T)*N(d2)
else:
return K*exp(-r*T)*N(-d2) - S*N(-d1)
# ATM Nifty 24000 weekly, IV 12%
print(round(black_scholes(24000, 24000, 7/365, 0.07, 0.12), 1)) # -> 175.6That 175.6 is a real number — the fair value of the ATM weekly call at 12% volatility. Change nothing but the volatility and watch the price move:
IV 10% -> 149 pts IV 15% -> 215 pts
IV 12% -> 176 pts IV 20% -> 281 ptsThe spot did not move at all — only the expected movement (volatility) changed, and the price changed a lot. This is the key insight: an option’s price is mostly a price on volatility.
Implied volatility: the number that actually matters
In real life you do not know σ — but you do see the option’s market price on your screen. So you flip the question around:
Given the price the market is charging, what volatility does that price imply?
That answer is implied volatility (IV) — the market’s own forecast of how much the underlying will move, backed out of the option’s price. It is the single most important number in practical options trading, because:
- High IV = expensive options. The market expects big moves (before results, budgets, elections). Great for sellers (collect fat premium), dangerous for buyers (you overpay, and IV can collapse).
- Low IV = cheap options. The market is calm. Good for buyers (cheap bets), poor for sellers (thin premium).
Black-Scholes cannot be algebraically inverted for σ, so we solve for it numerically — which, again, is our home turf:
def implied_vol(market_price, S, K, T, r, call=True, lo=1e-4, hi=5.0):
# bisection: find sigma such that BS price == market price
for _ in range(100):
mid = (lo + hi) / 2
price = black_scholes(S, K, T, r, mid, call)
if abs(price - market_price) < 1e-4:
return mid
if price > market_price: hi = mid
else: lo = mid
return mid
iv = implied_vol(176, 24000, 24000, 7/365, 0.07) # -> ~0.12 (12%)
print(round(iv * 100, 1), "%")Now you can take any option price off the screen and compute the IV the market is pricing in. Scan the whole chain and you can see where options are cheap or expensive in volatility terms — something a manual trader simply cannot do by eye.
The mental shift
Beginners think of options as a bet on direction (“will Nifty go up?”). Experienced traders think of them as a bet on direction and volatility. You can be right on direction and still lose because you bought when IV was high and it then collapsed (this is “IV crush”, famous after results announcements). Before you ever buy or sell an option, ask: is IV high or low right now? That question, which IV answers, is half the trade.
Pitfalls
- Buying options when IV is high. You overpay, and if IV reverts to normal you lose even when direction is right (IV crush).
- Selling options when IV is low. Thin premium for real risk — a bad trade.
- Ignoring that BS assumes constant volatility. Real markets don’t — hence the volatility smile/skew (Lesson 6). BS is a model, not reality; use it as a lens, not gospel.
Recap
Black-Scholes prices an option from five inputs, four known and one — volatility — being the whole game. In practice we invert it to get implied volatility from the market price: the market’s forecast of movement. High IV = expensive, low IV = cheap. Trading options well means trading volatility, not just direction.
Next: Lesson 6 — Volatility, where we go deeper into historical vs implied vol, IV rank, the volatility smile, and India VIX.