Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

As I was studying volatility derivatives I made some charts that represent some key features of replication. Say variance swap has a payoff function $$f=(\sigma – K_{VOL})$$, which means that $$K_{VOL}$$ will most likely be the forward volatility close to implied. To replicate this theory goes deep into maths and log-contracts that are not even traded on the market, however the idea is simple, buy a portfolio of options with equally distributed strike prices and weight them by reciprocal of squared strikes, i.e.$$1 \big/ K^2$$. Go for liquid ones, i.e. out of the money puts and out of the money calls. Then volatility or in this case variance is dependent on VEGA sensitivity of portfolio. The following graph gives an idea of how it is done. The code is included below: X-Y – spot/time to maturity, Z – Vega $$\left(\frac{\partial C}{\partial \sigma}\right)$$.

Code:

vega <- function(S0=100, K=100, r=0.05, d=0.05, tau=1, vol=0.1){
d_1  <- (log(S0/K)+((r-d)+vol^2/2)*tau)/(vol*sqrt(tau));
S0*sqrt(tau)*(1/sqrt(2*pi)*exp(-d_1^2/2))*exp(-d*tau)}

vegaK <- function(K, t){
sapply(t, function(x){vega(S0=50:200, K=K, tau=x)/K^2}) }

my3d_plot <- function(mat, x, y, col, bgcol="slatergray", material="lines", add=FALSE, ...){
require(rgl);
if( missing(x) ){ x <- 1:nrow(mat) }; if( missing(y) ){ y <- 1:ncol(mat) }
if( missing(col) ){ col <- rev(rep(heat.colors(ncol(mat),alpha=0),each=nrow(mat))) }
if( !add ){ open3d(); material3d(color=bgcol) }
mat$sum <- Reduce("+", mat) my3d_plot(mat$sum, bgcol="white", col="grey", aspect=c(4, 3, 2))