-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This sets everything up as built doc examples, splits tutorials from examples, adds more informative titles, and sets up buildkite
- Loading branch information
1 parent
3f1df12
commit cd6225a
Showing
7 changed files
with
97 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
steps: | ||
- label: "Julia 1" | ||
plugins: | ||
- JuliaCI/julia#v1: | ||
version: "1" | ||
- JuliaCI/julia-test#v1: | ||
coverage: false # 1000x slowdown | ||
agents: | ||
queue: "juliagpu" | ||
cuda: "*" | ||
env: | ||
GROUP: 'GPU' | ||
timeout_in_minutes: 60 | ||
# Don't run Buildkite if the commit message includes the text [skip tests] | ||
if: build.message !~ /\[skip tests\]/ | ||
|
||
env: | ||
JULIA_PKG_SERVER: "" # it often struggles with our large artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
pages = [ | ||
"Home" => "index.md", | ||
"Getting started" => "getting_started.md", | ||
"Solver Algorithms" => ["MLP.md", | ||
"DeepSplitting.md", | ||
"DeepBSDE.md"], | ||
"Tutorials" => [ | ||
"tutorials/deepsplitting.md", | ||
"tutorials/deepbsde.md", | ||
"tutorials/mlp.md", | ||
], | ||
"Extended Examples" => [ | ||
"examples/blackscholes", | ||
], | ||
"Solver Algorithms" => | ||
["MLP.md", | ||
"DeepSplitting.md", | ||
"DeepBSDE.md"], | ||
"Feynman Kac formula" => "Feynman_Kac.md", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Solving the 100-dimensional Black-Scholes-Barenblatt Equation | ||
|
||
Black Scholes equation is a model for stock option price. | ||
In 1973, Black and Scholes transformed their formula on option pricing and corporate liabilities into a PDE model, which is widely used in financing engineering for computing the option price over time. [1.] | ||
In this example, we will solve a Black-Scholes-Barenblatt equation of 100 dimensions. | ||
The Black-Scholes-Barenblatt equation is a nonlinear extension to the Black-Scholes | ||
equation, which models uncertain volatility and interest rates derived from the | ||
Black-Scholes equation. This model results in a nonlinear PDE whose dimension | ||
is the number of assets in the portfolio. | ||
|
||
To solve it using the `PIDEProblem`, we write: | ||
|
||
```julia | ||
d = 100 # number of dimensions | ||
X0 = repeat([1.0f0, 0.5f0], div(d,2)) # initial value of stochastic state | ||
tspan = (0.0f0,1.0f0) | ||
r = 0.05f0 | ||
sigma = 0.4f0 | ||
f(X,u,σᵀ∇u,p,t) = r * (u - sum(X.*σᵀ∇u)) | ||
g(X) = sum(X.^2) | ||
μ_f(X,p,t) = zero(X) #Vector d x 1 | ||
σ_f(X,p,t) = Diagonal(sigma*X) #Matrix d x d | ||
prob = PIDEProblem(g, f, μ_f, σ_f, X0, tspan) | ||
``` | ||
|
||
As described in the API docs, we now need to define our `NNPDENS` algorithm | ||
by giving it the Flux.jl chains we want it to use for the neural networks. | ||
`u0` needs to be a `d`-dimensional -> 1-dimensional chain, while `σᵀ∇u` | ||
needs to be `d+1`-dimensional to `d` dimensions. Thus we define the following: | ||
|
||
```julia | ||
hls = 10 + d #hide layer size | ||
opt = Flux.Optimise.Adam(0.001) | ||
u0 = Flux.Chain(Dense(d,hls,relu), | ||
Dense(hls,hls,relu), | ||
Dense(hls,1)) | ||
σᵀ∇u = Flux.Chain(Dense(d+1,hls,relu), | ||
Dense(hls,hls,relu), | ||
Dense(hls,hls,relu), | ||
Dense(hls,d)) | ||
pdealg = NNPDENS(u0, σᵀ∇u, opt=opt) | ||
``` | ||
|
||
And now we solve the PDE. Here, we say we want to solve the underlying neural | ||
SDE using the Euler-Maruyama SDE solver with our chosen `dt=0.2`, do at most | ||
150 iterations of the optimizer, 100 SDE solves per loss evaluation (for averaging), | ||
and stop if the loss ever goes below `1f-6`. | ||
|
||
```julia | ||
ans = solve(prob, pdealg, verbose=true, maxiters=150, trajectories=100, | ||
alg=EM(), dt=0.2, pabstol = 1f-6) | ||
``` | ||
|
||
## References | ||
|
||
1. Shinde, A. S., and K. C. Takale. "Study of Black-Scholes model and its applications." Procedia Engineering 38 (2012): 270-279. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters