C++

Discrete Hedging

Posted on

/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! Discrete Hedging */ /* This example computes profit and loss of a discrete interval hedging strategy and compares with the results of Derman & Kamal’s (Goldman Sachs Equity Derivatives Research) Research Note: “When You Cannot Hedge Continuously: The Corrections to Black-Scholes” http://www.ederman.com/emanuelderman/GSQSpapers/when_you_cannot_hedge.pdf […]

R Studio

Option Surfaces

Posted on

## (European) Option Surfaces OptionSurface <- function(EOres, label, fov=60) { axis.col <- “black” text.col <- axis.col ylab <- label xlab <- “Underlying” zlab <- “Volatility” y <- EOres ## clear scene: clear3d() clear3d(type=”bbox”) clear3d(type=”lights”) ## setup env: ## bg3d(color=”#887777″) bg3d(color=”#DDDDDD”) light3d() rgl.viewpoint(fov=fov) ##rgl.bg(col=”white”, fogtype=”exp2″) ##rgl.bg(col=”black”, fogtype=”exp2″) ##rgl.bg(col=”black”, fogtype=”exp”) ##rgl.bg(col=”white”, fogtype=”exp”) x <- (1:nrow(y)) z <- […]

R Studio

Option Pricing Functions

Posted on

## Option pricing Functions EuropeanOption <- function(type, underlying, strike, dividendYield, riskFreeRate, maturity, volatility) { UseMethod(“EuropeanOption”) } EuropeanOption.default <- function(type, underlying, strike, dividendYield, riskFreeRate, maturity, volatility) { type <- match.arg(type, c(“call”, “put”)) val <- europeanOptionEngine(type, underlying, strike, dividendYield, riskFreeRate, maturity, volatility) class(val) <- c(“EuropeanOption”, “Option”) val } AmericanOption <- function(type, underlying, strike, dividendYield, riskFreeRate, maturity, volatility, […]

R Studio

Monte Carlo Simulation Step by Step Approach

Posted on

## How to perform a Monte Carlo Simulation? ## First Step: # Write a function to generate the option’s innovations. # Use scrambled normal Sobol numbers: sobolInnovations = function(mcSteps, pathLength, init, …) { # Create Normal Sobol Innovations: innovations = rnorm.sobol(mcSteps, pathLength, init, …) # Return Value: innovations } ## Second Step: # Write a […]

R Studio

MCS_Simulation

Posted on

# Monte Carlo Simulation / Simulation.r # basic parameters unit_cost <- 1.50 # per unit variable cost unit_price <- 4.00 # unit price per item unit_disp <- 0.20 # cost for the disposal of unsold inventories # simulate 3000 profits for 20K, 40K & 60K units each profit <- rep(NA, 3000) set.seed(1) for (i in […]

R Studio

MCS for single and multi assets

Posted on

# MCS for single and multi assets asset.paths <- function(s0, mu, sigma, nsims = 10000, periods = c(0, 1) # time periods at which to simulate prices ) { s0 = as.vector(s0) nsteps = len(periods) dt = c(periods[1], diff(periods)) if( len(s0) == 1 ) { drift = mu – 0.5 * sigma^2 if( nsteps == […]

Python

Calibration of Stoch Vol Jump Model via Numerical Integration

Posted on

# Calibration of Jump-Diffusion Part of BCC97 #Calibration of Stoch Vol Jump Model to EURO STOXX Option Quotes via Numerical Integration # Bakshi, Cao and Chen (1997) #Data Source: www.eurexchange.com # import sys sys.path.append(’09_gmm’) import math import numpy as np np.set_printoptions(suppress=True, formatter={‘all’: lambda x: ‘%5.3f’ % x}) import pandas as pd from scipy.optimize import brute, […]

Python

Calibration of Stoch Vol Jump Model via Numerical Integration Comp Model

Posted on

# Calibration of Complete Model of BCC97 # Calibration of Stoch Vol Jump Model to EURO STOXX Option Quotes via Numerical Integration # Data Source: www.eurexchange.com # Bakshi, Cao and Chen (1997) # import sys sys.path.append(’09_gmm’) import math import numpy as np np.set_printoptions(suppress=True, formatter={‘all’: lambda x: ‘%5.3f’ % x}) import pandas as pd from scipy.optimize […]