Pricing Methods

QuantLib.jl has various methods for asset pricing and calculation.

Finite Differences

Finite Differences framework for option pricing

General Finite Differences types

FDM Solver Description:

Finite Difference Step Conditions

abstract StepCondition

FDM Composite Step Condition

type FdmStepConditionComposite{C <: StepCondition} <: StepCondition
  stoppingTimes::Vector{Float64}
  conditions::Vector{C}
end
vanilla_FdmStepConditionComposite(cashFlow::DividendSchedule, exercise::Exercise, mesher::FdmMesher, calculator::FdmInnerValueCalculator, refDate::Date, dc::DayCount)

Builds and returns an FDM Step Condition composite for vanilla options

Finite Difference meshers

Brief mesher for an FDM grid

abstract FdmMesher
abstract Fdm1DMesher

Composite FDM Mesher type

type FdmMesherComposite <: FdmMesher
  layout::FdmLinearOpLayout
  meshers::Vector{Fdm1DMesher} # this could change
end
FdmMesherComposite(mesh::Fdm1DMesher)

Constructor for FDM Mesher composite type, with one mesher

FdmMesherComposite{F1D <: Fdm1DMesher}(xmesher::F1D, ymesher::F1D)

Constructor for FDM Mesher composite type with two meshers of the same type

1D FDM Mesher using a stochastic process:

type FdmSimpleProcess1dMesher <: Fdm1DMesher
  size::Int
  process::StochasticProcess1D
  maturity::Float64
  tAvgSteps::Int
  epsilon::Float64
  mandatoryPoint::Float64
  locations::Vector{Float64}
  dplus::Vector{Float64}
  dminus::Vector{Float64}
end
FdmSimpleProcess1dMesher(sz::Int, process::StochasticProcess1D, maturity::Float64, tAvgSteps::Int, _eps::Float64, mandatoryPoint::Float64 = -1.0)

Constructor for the FDM Simple Process (stochastic process) 1D mesher

Finite Difference operators

Linear operators to model a multi-dimensional PDE system

abstract FdmLinearOpComposite

FDM G2 operator - linear operator for the FDM G2 solver

type FdmG2Op <: FdmLinearOpComposite
  direction1::Int
  direction2::Int
  x::Vector{Float64}
  y::Vector{Float64}
  dxMap::TripleBandLinearOp
  dyMap::TripleBandLinearOp
  corrMap::SecondOrderMixedDerivativeOp
  mapX::TripleBandLinearOp
  mapY::TripleBandLinearOp
  model::G2
end
FdmG2Op(mesher::FdmMesher, model::G2, direction1::Int, direction2::Int)

Constructor for the FDM G2 operator

Finite Difference 2D Solver

2D Finite Differences solver

type Fdm2DimSolver <: LazyObject
  lazyMixin::LazyMixin
  solverDesc::FdmSolverDesc
  schemeDesc::FdmSchemeDesc
  op::FdmLinearOpComposite
  thetaCondition::FdmSnapshotCondition
  conditions::FdmStepConditionComposite
  initialValues::Vector{Float64}
  resultValues::Matrix{Float64}
  x::Vector{Float64}
  y::Vector{Float64}
  interpolation::BicubicSpline
end
Fdm2DimSolver(solverDesc::FdmSolverDesc, schemeDesc::FdmSchemeDesc, op::FdmLinearOpComposite)

Constructor for the FDM 2D solver

Finite Difference G2 Solver

Finite differences solver with a G2 short rate model

type FdmG2Solver <: LazyObject
  lazyMixin::LazyMixin
  model::G2
  solverDesc::FdmSolverDesc
  schemeDesc::FdmSchemeDesc
  solver::Fdm2DimSolver
end
FdmG2Solver(model::G2, solverDesc::FdmSolverDesc, schemeDesc::FdmSchemeDesc)

Constructor for the FDM G2 Solver

Finite Difference Hull White Solver

type FdmHullWhiteSolver <: LazyObject
  lazyMixin::LazyMixin
  model::HullWhite
  solverDesc::FdmSolverDesc
  schemeDesc::FdmSchemeDesc
  solver::Fdm1DimSolver
end
FdmHullWhiteSolver(model::HullWhite, solverDesc::FdmSolverDesc, schemeDesc::FdmSchemeDesc)

Constructor for the FDM Hull White solver

Monte Carlo Simulation

QuantLib.jl’s Monte Carlo simulation tools include path generation and path pricer types

Monte Carlo Model

This is the general monte carlo model that is used for the simulation

abstract AbstractMonteCarloModel

type MonteCarloModel <: AbstractMonteCarloModel
  pathGenerator::PathGenerator
  pathPricer::AbstractPathPricer
  sampleAccumulator::RiskStatistics
  isAntitheticVariate::Bool
end
add_samples!(mcmodel::MonteCarloModel, samples::Int, idx::Int=1)

Adds samples generated by the simulation

Path Generator

type PathGenerator
  brownianBridge::Bool
  generator::AbstractRandomSequenceGenerator
  dimension::Int
  timeGrid::TimeGrid
  process::StochasticProcess1D
  nextSample::Sample
  temp::Vector{Float64}
  bb::BrownianBridge
end
PathGenerator(process::StochasticProcess, tg::TimeGrid, generator::AbstractRandomSequenceGenerator, brownianBridge::Bool)

Constructor for the path generator, given a process, time grid, RSG, and brownian bridge flag

PathGenerator(process::StochasticProcess, len::Float64, timeSteps::Int, generator::AbstractRandomSequenceGenerator, brownianBridge::Bool)

Constructor for the path generator, given a process, two variables to build a time grid, a RSG, and brownian bridge flag

Path and Node

Path: Basic path data structure

type Path
  tg::TimeGrid
  values::Vector{Float64}
end
Path(tg::TimeGrid)

Constructor for a Path given a time grid

Node: Node data structure

type NodeData
  exerciseValue::Float64
  cumulatedCashFlows::Float64
  values::Vector{Float64}
  controlValue::Float64
  isValid::Bool
end
NodeData()

Constructor for an empty NodeData object

Misc Methods and Types

generic_longstaff_schwartz_regression!(simulationData::Vector{Vector{NodeData}}, basisCoefficients::Vector{Vector{Float64}})

Returns the biased estimate obtained while regressing n exercises, n+1 elements in simulationData simulationData[1][j] -> cashflows up to first exercise, j-th path simulationData[i+1][j] -> i-th exercise, j-th path length(basisCoefficients) = n

Lattices and Trees

Trinomial Tree

This type defines a recombining trinomial tree approximating a 1D stochastic process.

type TrinomialTree <: AbstractTree
  process::StochasticProcess
  timeGrid::TimeGrid
  dx::Vector{Float64}
  branchings::Vector{Branching}
  isPositive::Bool
end
TrinomialTree(process::StochasticProcess, timeGrid::TimeGrid, isPositive::Bool = false)

Constructor for a trinomial tree given a stochastic process

Tree Lattice 1D

One-dimensional tree-based lattice

type TreeLattice1D <: TreeLattice
  tg::TimeGrid
  impl::TreeLattice
  statePrices::Vector{Vector{Float64}}
  n::Int
  statePricesLimit::Int
end
TreeLattice1D(tg::TimeGrid, n::Int, impl::TreeLattice)

Constructor of a 1D Tree lattice