Implied Volatility
A call option on a stock is worth S * N(d1) - K * exp(-r * T) * N(d2), where N is the standard normal cdf, d1 = (log(S / K) + (r + v**2 / 2) * T) / (v * sqrt(T)) and d2 = d1 - v * sqrt(T). Here S is the stock price, K the strike, T the years left, r the interest rate and v the volatility.
Given the market price of the option, return the volatility v between 0.01 and 5 at which the formula gives that price. Answers within 0.0001 of the right one are accepted.
Example 1
price 10.4506
S 100.0
K 100.0
T 1.0
r 0.05
returns 0.2
At a volatility of 0.2 the formula gives 10.4506.
Constraints
0.7 <= K / S <= 1.30.1 <= T <= 2- A volatility between 0.01 and 5 exists
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More SciPy problems
- Most Profit PlanHard
- Safest MixHard
- Smallest Total MissHard
- Volume Over a TriangleHard
- Area Under the PointsBeginner
- Chance of at MostBeginner
- City Block DistanceBeginner
- Percent at or BelowBeginner