The NNStopping
algorithm
Problems Supported:
HighDimPDE.NNStopping
— TypeNNStopping(models, opt)
Deep Optimal Stopping, S Becker, P Cheridito, A Jentzen3, and T Welti.
Arguments
models::Vector{Flux.Chain}
: A vector of Flux.Chain where each model corresponds to a specific timestep from the timespan (tspan). The overall length of the vector should belength(timesteps) - 1
.opt
: the optimization algorithm to be used to optimize the neural networks. Defaults toADAM(0.1)
.
Example
d = 3 # Number of assets in the stock r = 0.05 # interest rate beta = 0.2 # volatility T = 3 # maturity u0 = fill(90.0, d) # initial stock value delta = 0.1 # delta f(du, u, p, t) = du .= (r - delta) * u # drift sigma(du, u, p, t) = du .= beta * u # diffusion tspan = (0.0, T) N = 9 # discretization parameter dt = T / (N) K = 100.00 # strike price
payoff function
function g(x, t) return exp(-r * t) * (max(maximum(x) - K, 0)) end
prob = PIDEProblem(f, sigma, u0, tspan; payoff = g) models = [Chain(Dense(d + 1, 32, tanh), BatchNorm(32, tanh), Dense(32, 1, sigmoid)) for i in 1:N]
opt = Flux.Optimisers.Adam(0.01) alg = NNStopping(models, opt)
sol = solve(prob, alg, SRIW1(); dt = dt, trajectories = 1000, maxiters = 1000, verbose = true) ```
CommonSolve.solve
— Methodsolve(
prob::ParabolicPDEProblem,
pdealg::NNStopping,
sdealg;
verbose,
maxiters,
trajectories,
dt,
ensemblealg,
kwargs...
) -> NamedTuple{(:payoff, :stopping_time), <:Tuple{Any, Any}}
Returns a NamedTuple with payoff
and stopping_time
Arguments:
sdealg
: a SDE solver from DifferentialEquations.jl. If not provided, the plain vanilla DeepBSDE method will be applied. If provided, the SDE associated with the PDE problem will be solved relying on methods from DifferentialEquations.jl, using Ensemble solves viasdealg
. Check the availablesdealg
on the DifferentialEquations.jl doc.maxiters
: The number of training epochs. Defaults to300
trajectories
: The number of trajectories simulated for training. Defaults to100
- Extra keyword arguments passed to
solve
will be further passed to the SDE solver.
The general idea 💡
Similar to DeepSplitting and DeepBSDE, NNStopping evaluates the PDE as a Stochastic Differential Equation. Consider an Obstacle PDE of the form:
\[ max\lbrace\partial_t u(t,x) + \mu(t, x) \nabla_x u(t,x) + \frac{1}{2} \sigma^2(t, x) \Delta_x u(t,x) , g(t,x) - u(t,x)\rbrace\]
Such PDEs are commonly used as representations for the dynamics of stock prices that can be exercised before maturity, such as American Options.
Using the Feynman-Kac formula, the underlying SDE will be:
\[dX_{t}=\mu(X,t)dt + \sigma(X,t)\ dW_{t}^{Q}\]
The payoff of the option would then be:
\[sup\lbrace\mathbb{E}[g(X_\tau, \tau)]\rbrace\]
Where τ is the stopping (exercising) time. The goal is to retrieve both the optimal exercising strategy (τ) and the payoff.
We approximate each stopping decision with a neural network architecture, inorder to maximise the expected payoff.