Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Comparison between Normal and Laplace models for option pricing
K<-c(7000,7500,8000,8500,9000,9250,9500,9750,10000,10250,10500,10750,11000,11500,12000) P<-c(2364.10,1881.80,1411.59,949.73,540.84,375.43,225.80,171.91,115.22,71.55,50.18,42.75,34.42,20.47,14.89) S<-9292 T<-3.75 SL <- function(x,v) { (x<=0)*((1+v)*exp((1-v)*x)/2)+(x>0)*(1-(1-v)*exp(-(1+v)*x)/2) } call <- function(S,vol,K,T,P) { d1 <- (log(S/K)+vol^2*T/2)/(vol*sqrt(T)) d2 <- (log(S/K)-vol^2*T/2)/(vol*sqrt(T)) S*pnorm(d1)-K*pnorm(d2)-P } call2 <- function(S,vol,K,T,P) { b <- vol/sqrt(2) d <- (log(S/K)+log(1-b^2*T))/(b*sqrt(T)) S*SL(d,b*sqrt(T))-K*SL(d,0)-P } vol <- c() vol2 <- c() for (ell in 1:length(K)){ res<-uniroot(call,c(0,5),S=S,K=K[ell],P=P[ell],T=T) vol<-c(vol,res$root) res<-uniroot(call2,c(0.001,sqrt(1.99/T)),S=S,K=K[ell],P=P[ell],T=T) vol2<-c(vol2,res$root) } matplot(K,cbind(vol*sqrt(365),sqrt(365)*vol2),type='l',col=c('blue','red'),main='Implied Volatility Surface',ylab='Volatility',xlab='Strike') #vol<-sqrt(2/T)*ppoints(200) #for (ell in 1:length(K)) { #plot(vol,call2(S,vol,K[ell],T),type='l') #abline(P[ell],0) # }
run
|
edit
|
history
|
help
0
Research Methods I Final
LDA
Example for barplot
14-09-2020GRamLD
Erro padrão
hello world
26-08-2020AjusteCurvaLinearizab
Are the items of a vector in a given data frame? (Filtering basics)
17-08-2020Ex2.1.1
ExDecaiEulerMin28-01-21