# Untitled

user_0311771714
plain_text
2 years ago
15 kB
1
Indexable
Never
```export SchobelZhuParams, evaluateCharFunc, evaluateLogCharFunc, computeCumulants

struct SchobelZhuParams{T}
v0::T
κ::T
θ::T
ρ::T
σ::T
end

#CC the Nemo arbField or Complex type. z: Nemo complex number or Complex number.
function evaluateCharFunc(CC, p::SchobelZhuParams, z::CT, τ::T) where {T,CT}
return exp(evaluateLogCharFunc(CC, p, z, τ))
end

function evaluateLogCharFunc(CC, p::SchobelZhuParams, z::CT, τ::T) where {T,CT}
#Lord and Kahl formulation
v0 = p.v0
κ = p.κ
θ = p.θ
ρ = p.ρ
σ = p.σ
cc1 = CC(0, 1)
α = -(z * (z + cc1)) / 2
β = 2 * (κ - cc1 * σ * ρ * z)
γ = 2 * σ^2
D = sqrt(β^2 - 4 * α * γ)
G = (β - D) / (β + D)
eDT = exp(-D * τ)
l = log((1 - G * eDT) / (1 - G))
sqrteDT = sqrt(eDT)
As =
(β - D) * κ^2 * θ^2 / (2 * D^3 * σ^2) * (
β * (D * τ - 4) +
D * (D * τ - 2) +
4 * sqrteDT * ((D^2 - 2 * β^2) / (β + D) * sqrteDT + 2 * β) / (1 - G * eDT)
)
A = As + (β - D) * τ / 4 - l / 2
Bs = 2 * κ * θ * (β - D) * (1 - sqrteDT)^2 / (D * γ * (1 - G * eDT))
Bv = (1 - eDT) / (1 - G * eDT) * (β - D) / (2 * γ)
return A + Bs * v0 + Bv * v0^2
end

function evaluateLogCharFuncSZ(CC, p::SchobelZhuParams, z::CT, τ::T) where {T,CT}
#Zhu formulation
v0 = p.v0
κ = p.κ
θ = p.θ
ρ = p.ρ
σ = p.σ
cc1 = CC(0, 1)
iu = complex(0, 1) * z
s12 = -iu / 2 * (iu * (1 - ρ^2) - 1 + 2 * ρ * κ / σ)
s22 = ρ * κ * θ / σ * iu
s32 = ρ / (2 * σ) * iu
γ1 = sqrt(2 * σ^2 * s12 + κ^2)
γ3 = κ^2 * θ - s22 * σ^2
γ2 = (κ - 2 * σ^2 * s32) / γ1
ch1 = cosh(γ1 * τ)
sh1 = sinh(γ1 * τ)
γ4 = ch1 + γ2 * sh1
H3 = (κ - γ1 * (sh1 + γ2 * ch1) / γ4) / σ^2
H4 = ((κ * θ * γ1 - γ2 * γ3) + γ3 * (sh1 + γ2 * ch1)) / (γ4 * γ1 * σ^2) - κ * θ / σ^2
H5 =
-log(γ4) / 2 +
sh1 / (2 * γ1^3 * γ4 * σ^2) * ((κ * θ * γ1 - γ2 * γ3)^2 - γ3^2 * (1 - γ2^2))
H5 +=
γ3 / (γ1^3 * γ4 * σ^2) * (κ * θ * γ1 - γ2 * γ3) * (γ4 - 1) +
τ / (2 * γ1^2 * σ^2) * (κ * γ1^2 * (σ^2 - κ * θ^2) + γ3^2)
return -s32 * v0^2 - iu * ρ * σ * τ / 2 + H3 / 2 * v0^2 + H4 * v0 + H5
end

function computeCumulants(p::SchobelZhuParams{T}, τ::T) where {T}
κ = p.κ
θ = p.θ
v0 = p.v0
σ = p.σ
ρ = p.ρ

shk = sinh(κ * τ)
chk = cosh(κ * τ)
c1H3 = (chk * (chk - shk) * σ + ρ * κ - σ) / (σ * κ)
c1H4 = (chk - 1) * θ * (shk - chk) / κ
c1H5 =
(
(2 * κ * θ^2 - σ^2) * chk^2 +
((-2 * κ * θ^2 + σ^2) * shk - 4 * κ * θ^2) * chk +
4 * shk * κ * θ^2 +
2 * τ * (ρ * σ - θ^2) * κ^2 +
(-σ^2 * τ + 2 * θ^2) * κ +
σ^2
) / (4 * κ^2)
c1 = -ρ / (2 * σ) * v0^2 - ρ * σ * τ / 2 + c1H3 / 2 * v0^2 + c1H4 * v0 + c1H5
c2H3 =
(
(-2 * κ * ρ * σ + 2 * κ^2) * chk^2 -
2 * (κ * ρ * σ - 1 / 2 * σ^2 - κ^2) * shk * chk +
(2 * ρ * σ * τ - 2) * κ^2 +
(-σ^2 * τ + 2 * ρ * σ) * κ
) / (κ^3 * (2 * chk * shk + 2 * chk^2 - 1))
c2H4 =
2 *
(
(-2 * κ * ρ * σ + κ^2 + σ^2) * chk^2 +
(
(-2 * κ * ρ * σ + 1 / 2 * σ^2 + κ^2) * shk +
(ρ * σ * τ - 1) * κ^2 +
(-1 / 2 * σ^2 * τ + 2 * ρ * σ) * κ - σ^2
) * chk +
((ρ * σ * τ - 1) * κ^2 + (-1 / 2 * σ^2 * τ + 2 * ρ * σ) * κ - σ^2 / 2) * shk -
κ * σ * (ρ * κ - σ / 2) * τ
) *
θ / (κ^3 * (2 * chk * shk + 2 * chk^2 - 1))
c2H5 =
(
(-8 * κ * σ^2 * θ^2 + 2 * σ^4) * chk^4 -
2 * σ^2 * ((-4 * κ * θ^2 + σ^2) * shk - 8 * κ * θ^2) * chk^3 -
8 *
κ *
(
2 * σ^2 * θ^2 * shk +
(-2 * ρ * σ * τ * θ^2 + θ^2) * κ^2 +
σ * (ρ * τ * σ^2 + (τ * θ^2 - 1 / 2) * σ - 3 * ρ * θ^2) * κ +
σ^2 * (-1 / 2 * σ^2 * τ + ρ * σ + 2 * θ^2)
) *
chk^2 +
(
(
(-16 * ρ * σ * τ * θ^2 + 8 * θ^2) * κ^3 +
(8 * ρ * τ * σ^3 + (8 * τ * θ^2 - 4) * σ^2 - 24 * ρ * σ * θ^2) * κ^2 +
(-4 * σ^4 * τ + 8 * ρ * σ^3 + 20 * σ^2 * θ^2) * κ - σ^4
) * shk -
16 *
((ρ * σ * τ - 1) * κ^2 + (-1 / 2 * σ^2 * τ + 3 * ρ * σ) * κ - σ^2) *
κ *
θ^2
) * chk +
16 *
κ *
θ^2 *
((ρ * σ * τ - 1) * κ^2 + (-1 / 2 * σ^2 * τ + 3 * ρ * σ) * κ - (3 * σ^2) / 2) *
shk +
8 * κ^4 * τ * θ^2 +
(-24 * ρ * σ * τ * θ^2 + 4 * σ^2 * τ - 8 * θ^2) * κ^3 +
((12 * τ * θ^2 - 4) * σ^2 + 24 * ρ * σ * θ^2) * κ^2 +
(-σ^4 * τ + 8 * ρ * σ^3 - 8 * σ^2 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