You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Name of QuantLet : SFEvegaPublished in : Statistics of Financial MarketsDescription : 'Plots the Vega of a call option as a function of the time to maturity and the assetprice.'Keywords : 'asset, black-scholes, call, european-option, financial, graphical representation,greeks, option, option-price, plot'See also : 'SFEvanna, SFEvolga, SFEdelta, SFEgamma, SFEtheta, SFEspeed, SFEcharmcall, SFEcolor,SFEultima, SFEvomma, SFEzomma, SFEdvegadtime'Author : Ying Chen, Christian M. HafnerSubmitted : Tue, July 01 2014 by Petra BurdejovaExample : 'For given [lower, upper] bound of Asset price S like [50,150] and [lower, upper] boundof time to maturity tau like [0.01, 1] a plot of the Vega of a call option is produced.'
R Code:
# clear variables and close windows
rm(list= ls(all=TRUE))
graphics.off()
# install and load packageslibraries= c("lattice")
lapply(libraries, function(x) if (!(x%in% installed.packages())) {
install.packages(x)
})
lapply(libraries, library, quietly=TRUE, character.only=TRUE)
# parameter settingsS_min=50# lower bound of Asset PriceS_max=150# upper bound of Asset Price tau_min=0.01# lower bound of Time to Maturitytau_max=1# upper bound of Time to MaturityK=100# exercise price r=0# interest ratesig=0.25# volatilityd=0# dividend rateb=r-d# cost of carrysteps=60# stepsmeshgrid=function(a, b) {
list(x= outer(b*0, a, FUN="+"), y= outer(b, a*0, FUN="+"))
}
first= meshgrid(seq(tau_min, tau_max, (tau_max-tau_min)/(steps-1)), seq(tau_min,
tau_max, (tau_max-tau_min)/(steps-1)))
tau=first$xdump=first$ysecond= meshgrid(seq(S_max, S_min, -(S_max-S_min)/(steps-1)), seq(S_max, S_min,
-(S_max-S_min)/(steps-1)))
dump2=second$xS=second$yd1= (log(S/K) + (r-d-sig^2/2) *tau)/(sig* sqrt(tau))
Vega=S* exp(-d*tau) * dnorm(d1) * sqrt(tau)
# Plottitle= bquote(expression(paste("Strike price is ", .(K), ", interest rate is ",
.(r), ", dividend rate is ", .(d), ", annual volatility is ", .(sig))))
wireframe(Vega~tau*S, drape=T, ticktype="detailed", main= expression(paste("Vega as function of the time to maturity ",
tau, " and the asset price S")), sub=title, scales=list(arrows=FALSE,
col="black", distance=1, tick.number=8, cex=0.7, x=list(labels= round(seq(tau_min,
tau_max, length=11), 1)), y=list(labels= round(seq(S_min, S_max, length=11),
1))), xlab=list(expression(paste("Time to Maturity ", tau)), rot=30,
cex=1.2), ylab=list("Asset Price S", rot=-40, cex=1.2), zlab=list("Vega",
cex=1.1))