I am in Canada. I just finished a project for Equity option analysis and management system.
I send you my algorithm to you for free.
Good luck!
Daxin
Here is a C++ algorithm to calculate implied volatility by bisection method.
To realize the algorithm, first, you need a pricing model for options such as European BS, Binomial tree, trinomial tree models. In my algorithm, I use American style trinomial tree pricing model( I did not give you this algorithm). The easest way is using European BS model. Suppose that you already have a European BS pricing model. Now you can use my following algorithm to calculate implied volatility(you can change the function names if you like):
double impliedVolContDivTrinomial (double pricing_value, double price, double strike, double rate, double div, double T, int N, int optionType) {
//Input
//pricing_value: usually represent the market value for the option
//price: current stock price
// strike: strike price
//rate: interest rate
//div: continuous dividend rate. if it is zero, you can not consider this parameter in you algorithm
// T: the time from today to expire date in year
//N: step for time, you do not need this parameter if you use BS pricing model
// optionType: if it is 0, that means call option, if it is 1, that means put option. //output: implied volatility
double desired_accuracy=0.0001; // error limit for calculating implied volatility double low_vol=0.001; // lower volatility bound, can be adjusted double high_vol=1.0; //high volatility bound, can be adjusted
全部评论 22