Hard · Derivatives Pricing & Greeks · Coding · ~20 min · #31
Implied Volatility by Bisection
Implement implied_vol(price, S, K, T, r) that returns the Black–Scholes implied volatility of a European call (no dividends) given its market price.
Use a robust root-finding method. The Black–Scholes call price is strictly increasing in , so bisection on always converges when a solution exists. Return a float accurate to within .
A helper bs_call is provided in the starter code.
Examples
Input: implied_vol(10.450583572185565, 100, 100, 1, 0.05)
Output: 0.2
Input: implied_vol(6.263001431193985, 100, 110, 0.5, 0.01)
Output: 0.35
Constraints
- •
0 < T ≤ 5, 0 ≤ r ≤ 0.1
- •
Input prices are consistent with some σ in (0, 5).
- •
Use only the Python standard library.
Hints · 0 of 3 shown
Worked solution
Give the problem an honest attempt first, then reveal the full explanation.