Skip to main content

Python package for Finance

Project description

SDev.Python

Python repository for various tools and projects in Machine Learning for Quantitative Finance. In the current release, we focus on stochastic volatility surfaces and their calibration through Machine Learning methods. See other work on our main website SDev-Finance.

Stochastic volatility calibration

In this project we use Neural Networks to improve the calibration speed for stochastic volatility models. For now we consider only the direct map, i.e. the calculation from model parameters to implied volatilities.

We first generate datasets of parameters (inputs) and vanilla option prices (outputs) and then train the network to replicate the prices. In this manner, the learning model is used as a pricing function to replace costly closed-forms or PDE/MC price calculations.

Our models can be saved to files for later usage, and can be re-trained from a saved state. We cover (Hagan) SABR, No-Arbitrage SABR (i.e. the actual SABR dynamic), Free-Boundary SABR, ZABR and Heston models.

Jupyter notebooks are available for demo under ./notebooks.

Trained models are saved under ./models/stovol. Sample training data is provided under ./datasets/stovol. However, these are only small sets for demo (50k samples). The larger sets we used for training (500k-2m) can be downloaded from our Kaggle account.

The notebook ./notebooks/StoVol Dataset Generation.ipynb can be used to generate samples (beware of setting up output paths to your local drive). The notebook ./notebooks/StoVol Training.ipynb can be used to train models (pre-trained or not) on the samples. The .py scripts corresponding to these notebooks are under sdevpy/projects/stovol.

AAD Monte-Carlo

In script ./projects/aad/aad_mc.py, we show how to calculate 1st and 2nd order Greeks on a Monte-Carlo simulation of Black-Scholes model (1 asset) using AAD. We compare the results with standard Monte-Carlo Greeks by Finite Differences and the closed-form. We make use of payoff smoothers for both AAD and Standard MC.

In ./projects/aad/aad_mc_nd.py, we compare AAD to standard MC and Closed-Form on a product with generic dimension. We can then benchmark the performance of AAD compared to MC bump-based sensitivities varying dimension and number of simulations.

Other Tools

The package contains various other tools including Black-Scholes/Bachelier formulas, Monte-Carlo simulation of vanilla prices and other utilities. It also features a wrapper class above Keras for easier management of trained models with their scalers, as well as custom callbacks and learning schedules.

Jupyter notebooks of previous work are also available (PINNs, AAD Monte-Carlo) but are not yet integrated in the framework.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdevpy-1.0.7.tar.gz (200.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdevpy-1.0.7-py3-none-any.whl (303.9 kB view details)

Uploaded Python 3

File details

Details for the file sdevpy-1.0.7.tar.gz.

File metadata

  • Download URL: sdevpy-1.0.7.tar.gz
  • Upload date:
  • Size: 200.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sdevpy-1.0.7.tar.gz
Algorithm Hash digest
SHA256 c2463594bcdff3a0a7f0860192bf9f17e308f85690966cba376d553bc8950da7
MD5 16485346c236a3a80d546611c1521ce5
BLAKE2b-256 0e1a4be4e3d60a5352001b4e5a2de738a5092380c8cf0a2cc87bdda732b9c228

See more details on using hashes here.

File details

Details for the file sdevpy-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: sdevpy-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 303.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for sdevpy-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7317b925616bea219c344399989a984cd4a6775db0d62c34a2b02e7735d947a1
MD5 5f6c1f3cec6cd70c5482cb9fdf8d8b81
BLAKE2b-256 2d6ef2759e76204c22b130b88b3f8105ba68529c55119fabfab2f1b301119aec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page