calcBSImpVol(cp,P,S​,K,T,r,q)

Calculates Black-Scholes Implied Volatility for Full Surface at High Speed
2.3K Downloads
Updated 11 Feb 2018

View License

Calculates Black-Scholes Implied Volatility Surface for an Option Price Matrix.
Uses Li's Rational Function Approximator for the Initial Estimate, followed by
3rd-Order Householder's Root Finder (i.e. using vega,vomma & ultima) for greater
convergence rate and wider domain-of-convergence relative to Newton-Raphson. Both
Li's Approximator and the Root Finder are calculated matrix-wise (i.e.
fully vectorized) for increased efficiency.

Cite As

Mark Whirdy (2024). calcBSImpVol(cp,P,S,K,T,r,q) (https://www.mathworks.com/matlabcentral/fileexchange/41473-calcbsimpvol-cp-p-s-k-t-r-q), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Financial Toolbox in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.13.0.0

removed the linear regression code which estimates the initial vol for points lying outside Li's domain of approximation. this regression code required in-domain values to be passed-in by the user to work. Out-of-domain vols are now 0.8

1.12.0.0

Amended to facilitate input variables "cp", "q" & "r" as matrices
cp Call[+1],Put[-1] [m x n],[1 x 1]
r Continuous Risk-Free Rate [m x n],[1 x 1]
q Continuous Div Yield [m x n],[1 x 1]

1.11.0.0

Amended Code allowing matrix inputs for "cp", "r" and "q"

cp Call[+1],Put[-1] [m x n],[1 x 1]
r Continuous Risk-Free Rate [m x n],[1 x 1]
q Continuous Div Yield [m x n],[1 x 1]

1.9.0.0

Changed comment
"S Underlying Price [m x n]"
to
"S Underlying Price [1 x 1]"
.. as was misleading
This version of the file handles S as a scalar only.

1.7.0.0

Re-factoring of anonymous functions in Householder root solver to re-calculate derivatives & for only those points which have not converged. This increases speed by 20-50% (depending on particular surface).

1.6.0.0

Added Comments

1.1.0.0

Fixed bug in Put-Call Parity line

P = P + S.*exp(-q.*T) - K.*exp(-r.*T); % Convert Put to Call by Parity Relation

1.0.0.0