Serving the Quantitative Finance Community

 
User avatar
barora
Topic Author
Posts: 0
Joined: September 30th, 2007, 9:26 pm

solving for impl vol

August 25th, 2011, 5:27 pm

hi,I've used the Newton Raphson method(programming in C++) for solving for the implied volatility in my options calculator (simple BS for european options) but I am getting an error to the order of 1%. Even tried the bisection method and Brent's method, but am off by about the same.Can someone suggest the best method to use to solve for IV....would appreciate it.thx!
 
User avatar
Hansi
Posts: 41
Joined: January 25th, 2010, 11:47 am

solving for impl vol

August 25th, 2011, 5:29 pm

1% againts what? Dummy data that should fit the model? Which model?
 
User avatar
barora
Topic Author
Posts: 0
Joined: September 30th, 2007, 9:26 pm

solving for impl vol

August 25th, 2011, 7:17 pm

I am working with the plain vanilla BlackScholes for European option.yes indeed, dummy data that should fit the model, so if an ATM 1-yr, 100 strike option was priced at $11 implying vol of .255, the NR method gives an impl. vol of .253, i.e. price of $10.90....
 
User avatar
acastaldo
Posts: 14
Joined: October 11th, 2002, 11:24 pm

solving for impl vol

August 25th, 2011, 8:12 pm

Sounds like a bug. What is the exit condition for the Newton-Raphson iteration? Possibly you are exiting too soon.
 
User avatar
RentMe
Posts: 0
Joined: August 21st, 2011, 2:35 am

solving for impl vol

August 25th, 2011, 8:24 pm

In this case the algorithm should converge. Check the following things:- Did you recomputed the vega correctly?- Maybe you have a too small limit on the number of iterations- Maybe the admissible error is too high
 
User avatar
Fermion
Posts: 2
Joined: November 14th, 2002, 8:50 pm

solving for impl vol

August 25th, 2011, 8:29 pm

Iterative numerical techniques like those you have used are typically designed to exit with a value when either a certain accuracy (often called the "tolerance")is reached or a certain number of iterations (usually called something like "max iterations") has been performed. Whatever tool you have access to should have these as user-determined quantities. So if you are getting a 1% error it is probably because you are asking for an accuracy of 1% or insufficient iterations. If, on the other hand, you don't have access to these quantities then they are pre-programmed into the tool and you need a better tool if it does not serve your needs.
 
User avatar
barora
Topic Author
Posts: 0
Joined: September 30th, 2007, 9:26 pm

solving for impl vol

August 25th, 2011, 8:38 pm

here's the code I am using:double IV(double S, double X, double r, double div, double k, double T){ double a=0.25; const double epsilon=0.00000001; double error=0.0; double vol=0.0; double mktprc=11;//option's market price do { double price=BSprice(100,100,0.02,0.0,a,1); double vega=Vega(100,100,0.02,0.0,a,1); vol=a-(price-mktprc)/(vega); std::cout<<"vol is: "<<vol<<std::endl; error=vol-a; a=vol; } while (abs(error)>epsilon); return a;} any suggestions on improvement.
Last edited by barora on August 24th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
RentMe
Posts: 0
Joined: August 21st, 2011, 2:35 am

solving for impl vol

August 25th, 2011, 9:00 pm

I see no error in your code,code of Vega function ?
 
User avatar
barora
Topic Author
Posts: 0
Joined: September 30th, 2007, 9:26 pm

solving for impl vol

August 25th, 2011, 9:04 pm

here we go:double Vega(double S, double X, double r, double div, double k, double T) {double d1, vega, N; d1=(log(S/X)+(r-div+(0.5*k*k))*T)/(k*sqrt(T)); const double pi=4*atan(1); N=exp(-0.5*d1*d1)/sqrt(2*pi); vega=N*S*sqrt(T); return vega;}
 
User avatar
RentMe
Posts: 0
Joined: August 21st, 2011, 2:35 am

solving for impl vol

August 25th, 2011, 10:27 pm

In three iterations, it converge to the price, I send you the code in a private message
 
User avatar
Fermion
Posts: 2
Joined: November 14th, 2002, 8:50 pm

solving for impl vol

August 25th, 2011, 10:29 pm

QuoteOriginally posted by: baroraI am working with the plain vanilla BlackScholes for European option.yes indeed, dummy data that should fit the model, so if an ATM 1-yr, 100 strike option was priced at $11 implying vol of .255, the NR method gives an impl. vol of .253, i.e. price of $10.90....Where does your .255 come from? What makes you think that is correct and .253 is wrong?If you are trying to verify your NR algorithm, you'd do better to start with the vol you want, calculate the price and then use NR to find the implied vol and then compare to the vol you started with. What you have done is to assume (without evidence) that the $11 implies .255 (did someone else tell you that?) and then actually calculated the implied vol to be .253!!!!!Just as a side note, your algorithm seeks to find the first vol for which the difference between two iterations is less than epsilon. This is not the same as getting an accuracy of epsilon, though in this case it's probably close. The usual task is to find the vol that minimizes the difference between target price and price calculated from implied vol -- giving you an accuracy in money terms.
 
User avatar
barora
Topic Author
Posts: 0
Joined: September 30th, 2007, 9:26 pm

solving for impl vol

August 25th, 2011, 10:37 pm

@RentMe, got it!and sent you a PM
Last edited by barora on August 25th, 2011, 10:00 pm, edited 1 time in total.
 
User avatar
RentMe
Posts: 0
Joined: August 21st, 2011, 2:35 am

solving for impl vol

August 25th, 2011, 10:48 pm

@Fermion : just replaceerror=-(price-mktprc)/vega;byerror=-(price-mktprc);No comment with Epsilon=1E-8