Add Black-Scholes example with documentation#2056
Add Black-Scholes example with documentation#2056litchki wants to merge 9 commits intolululxvi:masterfrom
Conversation
Added black_scholes_call.py to Time-dependent PDEs section.
Updated the Black-Scholes equation explanation and implementation details, including problem setup, boundary conditions, and training strategy.
|
|
||
| .. code-block:: python | ||
|
|
||
| def pde(x, y): |
There was a problem hiding this comment.
In this area, it is probably helpful to denote that x[:, 0] is stock prices, x[:, 1] are taus, y is stock prices.
Furthermore, it is likely best to write dV instead of dy.
There was a problem hiding this comment.
Thank you for the suggestion! I have updated the notation for clarity and consistency.
To clarify: in this example, y represents the option price V(S, tau),
not the stock price — I believe that was a small typo in the review comment.
The variables are now annotated as follows:
x[:, 0]: asset priceSx[:, 1]: time to maturitytauy: option priceV(S, tau)(network output)
I also renamed dy_* to dV_* in both the Python example and the
corresponding .rst documentation.
| S_max = 150.0 # Maximum stock price | ||
|
|
||
|
|
||
| def pde(x, y): |
There was a problem hiding this comment.
If you are on board with the comment on R67 (same place in docs), change for consistency
There was a problem hiding this comment.
Done, updated consistently with the changes in the .rst documentation.
|
@litchki still working on this? |
Updated the PDE residual explanation and variable descriptions in the black_scholes.rst file.
Removed extra newline before boundary conditions section.
|
| ) | ||
|
|
||
| **Sampling Strategy**: | ||
| To improve domain coverage and training stability, we use the **Sobol sequence** for sampling points. We select sample sizes as powers of 2 to avoid Sobol sequence warnings (2048 domain points, 64 boundary points, 128 initial points): |
There was a problem hiding this comment.
The user might not know what sobol sequence is and hence have no idea what you're talking about when you say powers of two for sobol sequence warnings. Linking to a source or directly explaining would help.
There was a problem hiding this comment.
Thanks for the suggestion — I've updated the Sampling Strategy section to briefly
explain what Sobol sequences are (low-discrepancy quasi-random sequences providing
more uniform domain coverage than pseudorandom sampling), and added references to
both the original Sobol paper and the SciPy documentation for the power-of-two
requirement.
Please let me know if you'd prefer a more explicit explanation for first-time readers.
Expanded explanation of Sobol sequences and their properties. Clarified validation results and hyperparameter tuning.
|
Checked documentation on docs build, ran code. All good. |
Description
This PR adds a new example demonstrating Physics-Informed Neural Networks (PINNs) for pricing European call options under the Black-Scholes model. This complements the existing physics/engineering examples with a fundamental application in computational finance.
Problem Overview
The example solves the Black-Scholes PDE in time-to-maturity form ($\tau = T - t$ ):
with appropriate boundary and initial conditions for a European call option.
Changes
Source Code (
examples/pinn_forward/black_scholes_call.py):Documentation (
docs/demos/pinn_forward/black_scholes.rst):Index Update (
docs/demos/pinn_forward.rst):Performance & Validation
Testing Checklist
heat.py).Reference
Tanios, R. (2021). "Physics Informed Neural Networks in Computational Finance: High Dimensional Forward & Inverse Option Pricing". ETH Zurich Master's Thesis. https://doi.org/10.3929/ethz-b-000491555