IV is the volatility parameter making Black-Scholes match market prices. Higher IV means higher expected price swings—often before events.
BS_Price(σ) = Market Price
Solve for σ using Newton-Raphson
// Bisection method to find implied volatility
function impliedVolatility(S, K, T, marketPrice, r) {
let lo = 0.01; // 1% IV
let hi = 2.0; // 200% IV
for (let i = 0; i < 50; i++) {
const mid = (lo + hi) / 2;
const price = blackScholesCall(S, K, T, mid, r);
if (price > marketPrice) {
hi = mid; // Price too high, lower IV
} else {
lo = mid; // Price too low, raise IV
}
}
return (lo + hi) / 2;
}
// Black-Scholes call price
function blackScholesCall(S, K, T, sigma, r) {
const d1 = (Math.log(S/K) + (r + sigma*sigma/2)*T) / (sigma*Math.sqrt(T));
const d2 = d1 - sigma*Math.sqrt(T);
return S*normalCDF(d1) - K*Math.exp(-r*T)*normalCDF(d2);
}