FinMath.ImpliedVolatility (Double, Double, Double, Double, Double, EOptionType, EPutCall, EOptionPrice, Int32, Double) Method

Implied volatility
public static double ImpliedVolatility( 
double S
double X
double t
double r
double P
EOptionType OptionType
EPutCall PutCall
EOptionPrice Method
int n
double Eps 
)
This language is not supported or no code example is available.
public:  
static double ImpliedVolatility( 
double S
double X
double t
double r
double P
EOptionType OptionType
EPutCall PutCall
EOptionPrice Method
int n
double Eps 
)
This language is not supported or no code example is available.
public static function ImpliedVolatility( 
S : double
X : double
t : double
r : double
P : double
OptionType : EOptionType
PutCall : EPutCall
Method : EOptionPrice
n : int
Eps : double 
) : double;
This language is not supported or no code example is available.

Parameters

S
double

spot price of underlying asset

X
double

option exercise (strike) price

t
double

time till exercise (fraction of year, f.ex. 0.5 for six months)

r
double

risk-free interst rate (continuous, decimal, f.ex. 0.1 for 10%)

P
double

option price (premium)

OptionType
EOptionType

Option type

PutCall
EPutCall

Put or call

Method
EOptionPrice

n
int

number of binomial periods or number of Monte Carlo price trajectories

Eps
double

error tolerance

Return Value

double
Remarks
 
Bisectional
Example
 
 double S = 35.0; // spot price
 double X = 35.0; // strike price
 double t = 1.0; // time to expiration (one year)
 double s = 0.2; // volatility (annualized standard deviation of asset log returns) (20%)
 double r = 0.1; // risk-free interest rate (10%)
 
 double P = TFinMath.BS(S,X,t,s,r, EOptionType.kCall);
 
 double BSV = TFinMath.ImpliedVolatility(S,X,t,r,P,EOptionType.kCall,EOptionPrice.kBlackScholes);
 double BMV = TFinMath.ImpliedVolatility(S,X,t,r,P,EOptionType.kCall,EOptionPrice.kBinomial);
 double MCV = TFinMath.ImpliedVolatility(S,X,t,r,P,EOptionType.kCall,EOptionPrice.kMonteCarlo);
 
 Console.WriteLine();
 
 Console.WriteLine("Spot price         = {0:F2}", S);
 Console.WriteLine("Strike price       = {0:F2}", X);
 Console.WriteLine("Time to expiration = {0:F2}", t);
 Console.WriteLine("Volatility         = {0:F2}", s);
 Console.WriteLine("Interest rate      = {0:F2}", r);
 
 Console.WriteLine();
 
 Console.WriteLine("Implied BS = {0:F2}", BSV);
 Console.WriteLine("Implied BM = {0:F2}", BMV);
 Console.WriteLine("Implied MC = {0:F2}", MCV);
 
 Console.WriteLine();
 
 Console.WriteLine("Black-Scholes = {0:F2}", P);
 Console.WriteLine("Binomial      = {0:F2}", TFinMath.BM(S,X,t,s,r,EOptionType.kCall,100));
 Console.WriteLine("Monte Carlo   = {0:F2}", TFinMath.MC(S,X,t,s,r,EOptionType.kCall));
 
 Console.WriteLine();
 
 Console.WriteLine("Delta = {0:F2}", TFinMath.Delta(S,X,t,s,r,EOptionType.kCall));
 Console.WriteLine("Gamma = {0:F2}", TFinMath.Gamma(S,X,t,s,r));
 Console.WriteLine("Theta = {0:F2}", TFinMath.Theta(S,X,t,s,r,EOptionType.kCall));
 Console.WriteLine("Vega  = {0:F2}", TFinMath.Vega (S,X,t,s,r));
 Console.WriteLine("Rho   = {0:F2}", TFinMath.Rho (S,X,t,s,r,EOptionType.kCall));
 					

In this article

Definition