Example 1
This example performs the optimization described in the paper to obtain the physical distribution P and the martingale distributions Q, where:
nis the number of states consideredalphais a parameter limiting the second moment of the pricing kernellambdais a parameter for the Tikhonov-type regularizationomega_lincludes the disjunct state space partitions of interestsprepresents the spot prices in 4 different states of the worldstrikerepresents the strike prices of different optionsbidrepresents the bid prices of different optionsaskrepresents the ask prices of different optionspflagindicates whether an option si a call or a put optionresultincludes two elements: the P distribution and the Q distribution
import dbbpy
import numpy as np
n = 4
alpha = 1.3
lambda_ = 1.1
omega_l = np.array([0, 3])
sp = np.array([1200, 1250, 1300, 1350])
strike = np.array([1290, 1295, 1295, 1300])
bid = np.array([27.7, 27.4, 29.4, 25.0])
ask = np.array([29.3, 29.7, 31.4, 26.9])
pFlag = np.array([1,0,1,0])
result = dbbpy.performOptimization(n, alpha, lambda_, omega_l, sp, strike, bid, ask, pFlag)
p = result[0]
q = result[1]
print(p)
print(q)library(rdbb)
n <- 4
alpha <- 1.3
lambda <- 1.1
omega_l <- c(0, 3) # zero-indexed
sp <- c(1200, 1250, 1300, 1350)
strike <- c(1290, 1295, 1295, 1300)
bid <- c(27.7, 27.4, 29.4, 25.0)
ask <- c(29.3, 29.7, 31.4, 26.9)
pFlag <- c(TRUE, FALSE, TRUE, FALSE)
result <- performOptimization(n, alpha, lambda, omega_l, sp, strike, bid, ask, pFlag)
p <- result[[1]]
q <- result[[2]]
print(p)
print(q)
Last updated