fOptions American options Implied Volatility
On 17 May 2011, at 11:36, msalese wrote:
Hi guys,
working with RMetrics/fOptions library I see there isn't a function to
compute iv on American Options so I've build this function to do the job:
library(fOptions)
impVolAmCall<-function(pmkPrice,Und,Strike,expTime,rInt,pb){
auxAmCall<-function(pVol,pmkPrice,pUnd,pStrike,pexpTime,prInt){
at<-CRRBinomialTreeOption(TypeFlag = "ca", S = pUnd, X=pStrike,Time
=pexpTime, r = prInt, b = pb, sigma = pVol, n = 15)
return(pmkPrice-at at price)
}
limpVol<-uniroot(f=auxAmCall,lower=0.05,upper=2,tol=0.001,pmkPrice=pmkPrice,pUnd=Und,pStrike=Strike,pexpTime=expTime,prInt=rInt)
return(limpVol$root)
}
After that I downloaded options price from Italian IDEM on G.MI (Generali
Assurance) and loaded all in the obsPrice3 data.frame:
str(obsPrice3)
'data.frame': 12 obs. of 6 variables:
$ expDays : num 59 59 59 59 59 59 59 59 59 59 ...
$ YExpDays: num 0.234 0.234 0.234 0.234 0.234 ...
$ Bid : num 2.219 1.726 1.249 0.845 0.544 ...
$ Ask : num 2.266 1.769 1.293 0.883 0.579 ...
$ Strike : num 13.5 14 14.5 15 15.5 16 16.5 17 17.5 18 ...
$ MidPrice: num 2.242 1.747 1.271 0.864 0.561 ...
expDays YExpDays Bid Ask Strike MidPrice
1 59 0.234127 2.2190 2.2660 13.5 2.24250
2 59 0.234127 1.7255 1.7690 14.0 1.74725
3 59 0.234127 1.2490 1.2930 14.5 1.27100
4 59 0.234127 0.8450 0.8830 15.0 0.86400
5 59 0.234127 0.5445 0.5785 15.5 0.56150
6 59 0.234127 0.3325 0.3670 16.0 0.34975
7 59 0.234127 0.1895 0.2180 16.5 0.20375
8 59 0.234127 0.1010 0.1280 17.0 0.11450
9 59 0.234127 0.0485 0.0760 17.5 0.06225
10 59 0.234127 0.0115 0.0445 18.0 0.02800
11 59 0.234127 0.0005 0.0830 18.5 0.04175
12 59 0.234127 0.0005 0.0775 19.0 0.03900
Now I'd like to compute the iv for all the chain so I've used mapply:
mapply(FUN=impVolAmCall,obsPrice3$MidPrice,obsPrice3$Strike,Und=15.75,expTime=59/252,rInt=0.01,pb=0.01)
but R replay with:
Error in uniroot(f = auxAmCall, lower = 0.05, upper = 2, tol = 0.001, :
f() values at end points not of opposite sign
this means that f() never crosses zero, either always negative or always positive. This happens a bunch of times when you try to estimate IV from, say, a "wrong" model or if market prices are way too off the theoretical (up to the wrong model for these data) price. no real clue, just some experience stefano
The point is that for otm options I'm not able to find zero in auxAmCall (auxiliary function) coded inside impVolAmCall function. I'm new to R so I think that something is wrong in my code, can someone help me ? Thanks Massimo http://r.789695.n4.nabble.com/file/n3528629/obsPrice3.rda obsPrice3.rda -- View this message in context: http://r.789695.n4.nabble.com/fOptions-American-options-Implied-Volatility-tp3528629p3528629.html Sent from the Rmetrics mailing list archive at Nabble.com.
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
----------------------------------- Stefano M. Iacus Department of Economics, Business and Statistics University of Milan Via Conservatorio, 7 I-20123 Milan - Italy Ph.: +39 02 50321 461 Fax: +39 02 50321 505 http://www.economia.unimi.it/iacus ------------------------------------------------------------------------------------ Please don't send me Word or PowerPoint attachments if not absolutely necessary. See: http://www.gnu.org/philosophy/no-word-attachments.html