optPricing 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- optpricing-2.0.0.dist-info/METADATA +105 -0
- optpricing-2.0.0.dist-info/RECORD +92 -0
- optpricing-2.0.0.dist-info/WHEEL +5 -0
- optpricing-2.0.0.dist-info/entry_points.txt +3 -0
- optpricing-2.0.0.dist-info/licenses/LICENSE +9 -0
- optpricing-2.0.0.dist-info/top_level.txt +1 -0
- quantfin/__init__.py +101 -0
- quantfin/atoms/__init__.py +21 -0
- quantfin/atoms/bond.py +28 -0
- quantfin/atoms/option.py +70 -0
- quantfin/atoms/rate.py +46 -0
- quantfin/atoms/stock.py +39 -0
- quantfin/calibration/__init__.py +25 -0
- quantfin/calibration/calibrator.py +155 -0
- quantfin/calibration/fit_jump_parameters.py +66 -0
- quantfin/calibration/fit_market_params.py +120 -0
- quantfin/calibration/iv_surface.py +155 -0
- quantfin/calibration/technique_selector.py +47 -0
- quantfin/calibration/vectorized_bsm_iv.py +93 -0
- quantfin/calibration/vectorized_integration_iv.py +143 -0
- quantfin/cli.py +372 -0
- quantfin/config.py +57 -0
- quantfin/dashboard/__init__.py +14 -0
- quantfin/dashboard/app.py +26 -0
- quantfin/dashboard/pages/1_Calibration.py +57 -0
- quantfin/dashboard/pages/2_Pricer_and_Greeks.py +150 -0
- quantfin/dashboard/pages/3_Financial_Tools.py +69 -0
- quantfin/dashboard/pages/__init__.py +0 -0
- quantfin/dashboard/plots.py +157 -0
- quantfin/dashboard/service.py +176 -0
- quantfin/dashboard/widgets.py +87 -0
- quantfin/data/__init__.py +26 -0
- quantfin/data/historical_manager.py +86 -0
- quantfin/data/market_data_manager.py +236 -0
- quantfin/models/__init__.py +54 -0
- quantfin/models/base/__init__.py +16 -0
- quantfin/models/base/base_model.py +198 -0
- quantfin/models/base/validators.py +95 -0
- quantfin/models/bates.py +192 -0
- quantfin/models/blacks_approx.py +134 -0
- quantfin/models/bsm.py +262 -0
- quantfin/models/cev.py +109 -0
- quantfin/models/cgmy.py +189 -0
- quantfin/models/cir.py +90 -0
- quantfin/models/dupire_local.py +67 -0
- quantfin/models/heston.py +204 -0
- quantfin/models/hyperbolic.py +170 -0
- quantfin/models/kou.py +148 -0
- quantfin/models/merton_jump.py +225 -0
- quantfin/models/nig.py +180 -0
- quantfin/models/perpetual_put.py +115 -0
- quantfin/models/sabr.py +64 -0
- quantfin/models/sabr_jump.py +68 -0
- quantfin/models/vasicek.py +88 -0
- quantfin/models/vg.py +178 -0
- quantfin/parity/__init__.py +13 -0
- quantfin/parity/implied_rate.py +110 -0
- quantfin/parity/parity_model.py +178 -0
- quantfin/techniques/__init__.py +31 -0
- quantfin/techniques/base/__init__.py +21 -0
- quantfin/techniques/base/base_technique.py +54 -0
- quantfin/techniques/base/greek_mixin.py +265 -0
- quantfin/techniques/base/iv_mixin.py +116 -0
- quantfin/techniques/base/lattice_technique.py +129 -0
- quantfin/techniques/base/pricing_result.py +27 -0
- quantfin/techniques/base/random_utils.py +31 -0
- quantfin/techniques/closed_form.py +296 -0
- quantfin/techniques/crr.py +59 -0
- quantfin/techniques/fft.py +178 -0
- quantfin/techniques/integration.py +202 -0
- quantfin/techniques/kernels/__init__.py +37 -0
- quantfin/techniques/kernels/lattice_kernels.py +286 -0
- quantfin/techniques/kernels/mc_kernels.py +337 -0
- quantfin/techniques/leisen_reimer.py +59 -0
- quantfin/techniques/monte_carlo.py +259 -0
- quantfin/techniques/pde.py +155 -0
- quantfin/techniques/topm.py +59 -0
- quantfin/workflows/__init__.py +14 -0
- quantfin/workflows/backtest_workflow.py +133 -0
- quantfin/workflows/configs/__init__.py +51 -0
- quantfin/workflows/configs/bates_config.py +25 -0
- quantfin/workflows/configs/bsm_config.py +9 -0
- quantfin/workflows/configs/cev_config.py +16 -0
- quantfin/workflows/configs/cgmy_config.py +18 -0
- quantfin/workflows/configs/heston_config.py +21 -0
- quantfin/workflows/configs/hyperbolic_config.py +18 -0
- quantfin/workflows/configs/kou_config.py +16 -0
- quantfin/workflows/configs/merton_config.py +18 -0
- quantfin/workflows/configs/nig_config.py +13 -0
- quantfin/workflows/configs/sabr_config.py +19 -0
- quantfin/workflows/configs/vg_config.py +9 -0
- quantfin/workflows/daily_workflow.py +150 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: optPricing
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: A financial options pricing and analysis library.
|
|
5
|
+
Author-email: Diljit Singh <first_last22@google.com>
|
|
6
|
+
License: # MIT LICENSE
|
|
7
|
+
|
|
8
|
+
Copyright 2025 Diljit Singh
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
15
|
+
|
|
16
|
+
Project-URL: Homepage, https://diljit22.github.io/quantFin/
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy==2.2.5
|
|
25
|
+
Requires-Dist: scipy==1.15.2
|
|
26
|
+
Requires-Dist: pandas==2.2.3
|
|
27
|
+
Requires-Dist: numba==0.61.2
|
|
28
|
+
Requires-Dist: pyyaml==6.0.2
|
|
29
|
+
Requires-Dist: polygon-api-client==1.14.6
|
|
30
|
+
Requires-Dist: typer==0.15.2
|
|
31
|
+
Provides-Extra: app
|
|
32
|
+
Requires-Dist: streamlit==1.45.1; extra == "app"
|
|
33
|
+
Requires-Dist: matplotlib==3.10.1; extra == "app"
|
|
34
|
+
Requires-Dist: plotly==6.1.2; extra == "app"
|
|
35
|
+
Requires-Dist: yfinance==0.2.63; extra == "app"
|
|
36
|
+
Requires-Dist: tabulate==0.9.0; extra == "app"
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: pytest==8.3.5; extra == "dev"
|
|
39
|
+
Requires-Dist: pytest-cov==6.2.1; extra == "dev"
|
|
40
|
+
Requires-Dist: ruff==0.11.6; extra == "dev"
|
|
41
|
+
Requires-Dist: mkdocs==1.6.1; extra == "dev"
|
|
42
|
+
Requires-Dist: mkdocs-material==9.6.14; extra == "dev"
|
|
43
|
+
Requires-Dist: mkdocstrings[python]==0.29.1; extra == "dev"
|
|
44
|
+
Requires-Dist: mkdocs-section-index==0.3.10; extra == "dev"
|
|
45
|
+
Requires-Dist: line_profiler==4.2.0; extra == "dev"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
# QuantFin
|
|
49
|
+
|
|
50
|
+
[](https://github.com/diljit22/quantfin/actions/workflows/ci.yml)
|
|
51
|
+
[](https://pypi.org/project/quantfin/)
|
|
52
|
+
[](https://opensource.org/licenses/MIT)
|
|
53
|
+
[](https://www.python.org/downloads/)
|
|
54
|
+
|
|
55
|
+
**A Python library for pricing and calibrating financial options.**
|
|
56
|
+
|
|
57
|
+
## Introduction
|
|
58
|
+
|
|
59
|
+
Welcome to **QuantFin**, a comprehensive Python toolkit for pricing and calibrating financial derivatives. This library was originally designed for me to learn about the more nuanced methods of quantitative finance and has since grown into a robust framework for analysis.
|
|
60
|
+
|
|
61
|
+
QuantFin is structured around four core pillars:
|
|
62
|
+
|
|
63
|
+
- **Atoms**: Fundamental data types (`Option`, `Stock`, `Rate`) that ensure consistency and clarity of inputs across the library.
|
|
64
|
+
- **Models**: A broad library ranging from classical Black-Scholes-Merton to advanced stochastic volatility (Heston, SABR) and jump/Lévy processes.
|
|
65
|
+
- **Techniques**: Multiple pricing engines—closed-form formulas, FFT, numerical integration, PDE solvers, lattice methods, and Monte Carlo (`numba`-accelerated with variance reduction methods baked in).
|
|
66
|
+
- **Workflows**: High-level orchestrators that automate end-to-end tasks like daily calibration and out-of-sample backtesting, all accessible via a CLI or an interactive dashboard.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
Get started in minutes using the command-line interface.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# 1. Install the library with all features, including the dashboard
|
|
76
|
+
pip install optPricing[app]
|
|
77
|
+
|
|
78
|
+
# 2. Download historical data for a ticker (used by some models)
|
|
79
|
+
quantfin data download --ticker SPY
|
|
80
|
+
|
|
81
|
+
# 3. Launch the interactive dashboard to visualize the results
|
|
82
|
+
quantfin dashboard
|
|
83
|
+
|
|
84
|
+
# 4. See a demo of the engine
|
|
85
|
+
quantfin demo
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Documentation & Links
|
|
89
|
+
|
|
90
|
+
For a detailed tutorial, full API reference, and more examples, please see the official documentation.
|
|
91
|
+
|
|
92
|
+
- **Getting Started**: [Installation Guide](installation.md) · [Walkthrough](getting_started.md)
|
|
93
|
+
- **Documentation**: [API Reference](reference/atoms/index.md)
|
|
94
|
+
- **Interactive Dashboard**: [Launch the UI](dashboard.md)
|
|
95
|
+
- **About Me**: [LinkedIn]([dashboard.md](https://www.linkedin.com/in/singhdiljit/))
|
|
96
|
+
|
|
97
|
+
To explore all available commands, run:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
quantfin --help
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Contributing & License
|
|
104
|
+
|
|
105
|
+
See [CONTRIBUTING](/CONTRIBUTING.md) and [LICENSE](LICENSE).
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
optpricing-2.0.0.dist-info/licenses/LICENSE,sha256=iMYjrsUfIlYiMilTjTIy89Ot_567Cq6hpEJpedkZjCs,1084
|
|
2
|
+
quantfin/__init__.py,sha256=NPOisI-mG_2DtTjXnBYaRgzKseWTWPfngeK_yFX0Iqk,2243
|
|
3
|
+
quantfin/cli.py,sha256=6muyExS1YIk6BLrw6zUeNsQclelvXSdskSedKV_b-X4,11851
|
|
4
|
+
quantfin/config.py,sha256=T5VB6by415AiCpsHPU3YiTPvNNx-XVFNhISSLRGScUM,1694
|
|
5
|
+
quantfin/atoms/__init__.py,sha256=PpsnPtVg9jhnfdTwAxX8bRdMvmvLk4Ybb7u-X83TTUw,504
|
|
6
|
+
quantfin/atoms/bond.py,sha256=jU-DKTO5lOJ6OefHM5fMxNg0GfBseSlOoP6hkfeQEfc,698
|
|
7
|
+
quantfin/atoms/option.py,sha256=mm8PI4RNDltQw9vyiYnHfs5oorg0OCqyokzAPM4BW9Q,2009
|
|
8
|
+
quantfin/atoms/rate.py,sha256=OkaZk5T-fSew8I9ktFsuM8Q04yxKe_NQ7j_LWqLxBNc,1362
|
|
9
|
+
quantfin/atoms/stock.py,sha256=HVNTwYqYRNk049uak16SCVQp7fOnAyg-YyoSiVXhOcQ,1303
|
|
10
|
+
quantfin/calibration/__init__.py,sha256=ThFOZ01ohNwsb_HavSIjD215JDmW0u3rgdTY-KIpHJ4,827
|
|
11
|
+
quantfin/calibration/calibrator.py,sha256=d0kp1qAQxuGaHt5c-Xt2ywwbIe8Asggzof_nmkm_RkA,5782
|
|
12
|
+
quantfin/calibration/fit_jump_parameters.py,sha256=RSAGR79GYElw3RDibaAGp6F60ZFD2_cDNaXcgJR4lVY,2259
|
|
13
|
+
quantfin/calibration/fit_market_params.py,sha256=xIi3vARyAm8UgJjoTSkY-p594uXBN0lflX1Zb3Ulz60,3959
|
|
14
|
+
quantfin/calibration/iv_surface.py,sha256=GOlkMg4ZSHt8t9FDXBRmFGyuNRnQgcLGXjwT_njjZSY,5214
|
|
15
|
+
quantfin/calibration/technique_selector.py,sha256=yFSsVjKvLCqEpo4CE9KKrWd8OC1n-QCt1CN1dZ4pB8Q,1491
|
|
16
|
+
quantfin/calibration/vectorized_bsm_iv.py,sha256=0R26UQgMz7glXs93CtrDM2P50Z_bV6WiK6bZGm9D3Kc,3123
|
|
17
|
+
quantfin/calibration/vectorized_integration_iv.py,sha256=SJDVuJsiQmAb9AClGigq_ITgKZ8kWNtsM5BrKyximoc,4718
|
|
18
|
+
quantfin/dashboard/__init__.py,sha256=8Lb1QAch5aVwZSSJgOA5N-CHqhQiZVNCxINMnP7zrOg,373
|
|
19
|
+
quantfin/dashboard/app.py,sha256=S5ostUZPMFgEzA0JWN9m5KvsYJ4oDP7f7nC46TFHp-c,931
|
|
20
|
+
quantfin/dashboard/plots.py,sha256=TE0hdmEMuDNaTyfhYmAZUnXO0CYSFvsRhFNZVnPkzzs,5062
|
|
21
|
+
quantfin/dashboard/service.py,sha256=Q-YktE2w2r4Agx5SvkYcBr2aGuIhEcxmCsbzIPs6ycM,5986
|
|
22
|
+
quantfin/dashboard/widgets.py,sha256=kh1raFw3LIrkXWDfout557zeG6V0LsgapnSEeLMsVHg,2608
|
|
23
|
+
quantfin/dashboard/pages/1_Calibration.py,sha256=-XZE3Zz9aplk3VAWERyQD4SVLmkqIwyZQ9q2X-ZgfjA,2404
|
|
24
|
+
quantfin/dashboard/pages/2_Pricer_and_Greeks.py,sha256=Vhho3eindGMejxzTlft2rwQqn5E-3kzszXGk4jzMpAI,5318
|
|
25
|
+
quantfin/dashboard/pages/3_Financial_Tools.py,sha256=ypb-F0Q550gnBKp8AJYq-jwfKOrvnVNoY0rmSweeHuU,3212
|
|
26
|
+
quantfin/dashboard/pages/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
quantfin/data/__init__.py,sha256=M6Vk4QczPAAtCspA0cU34tfvYh7Ea6RFlGmhDo52IL0,677
|
|
28
|
+
quantfin/data/historical_manager.py,sha256=dvKOP8Yocn3SvoFteJSETqVPEIJz5R3yDAMRqC5ACGM,2823
|
|
29
|
+
quantfin/data/market_data_manager.py,sha256=bTpkNJSNzKQXMHEhDyV_agNGwuWmCUYMbQaMpVpJhyA,8113
|
|
30
|
+
quantfin/models/__init__.py,sha256=epqKW_ccIzeAbazMdquV_QOjZNAO8BGOxMW82S9YRrs,1455
|
|
31
|
+
quantfin/models/bates.py,sha256=r1fDyi75yuMVWlraxWvjvf6LYLMFthVYOSAAsHm-d7w,6485
|
|
32
|
+
quantfin/models/blacks_approx.py,sha256=injxkUUzKEPQkA4si5S4PKyZOTAWJvkVBr10tT1GXVQ,4428
|
|
33
|
+
quantfin/models/bsm.py,sha256=YqiArlAl0ebKiAeA8fozuCYGOeKNUinvzVHjH1cgjwE,7953
|
|
34
|
+
quantfin/models/cev.py,sha256=fcsc5HMigT1823lWPNrWNyNXMiZKjuXkjkFPVempJvc,3525
|
|
35
|
+
quantfin/models/cgmy.py,sha256=S-rdUpa5SNqkUN46HiK8ZAVqW9AwM1M7T0CiBZqypG8,5935
|
|
36
|
+
quantfin/models/cir.py,sha256=WUa9pJbQXmp-CAjq3bTVieiwabcHLhajrA2X7F8z-3E,2778
|
|
37
|
+
quantfin/models/dupire_local.py,sha256=Y3YRAOZSZEiip9BTwM4mvx4L1_c4VlyMiNFxHEKW-AU,2359
|
|
38
|
+
quantfin/models/heston.py,sha256=yqgWY7mpCS3WG1MG18XYm_2hMpMBq5Xmkultw9TqqmI,6334
|
|
39
|
+
quantfin/models/hyperbolic.py,sha256=IICnNtuI-q1u8Qu9dNXu0i7m6hyoQ4G0APLQhCzKgR0,5216
|
|
40
|
+
quantfin/models/kou.py,sha256=KVVXCm_Voc2NRWHYOs7Ba_TJGs5WutwQVYGbpQEvmhI,4327
|
|
41
|
+
quantfin/models/merton_jump.py,sha256=U-iDkBtJJHAIx1oy9IvO2BJxcBAfIlnE_XggVDr71g8,6893
|
|
42
|
+
quantfin/models/nig.py,sha256=sWua1D_5ynVXZ6TRwTsA1pvu4cOm6MMQawhSNc22k6Y,5560
|
|
43
|
+
quantfin/models/perpetual_put.py,sha256=4ZHJalDZHCNTsKHYMYcUgZY5Mfht47uI1dI4oMyedfo,3782
|
|
44
|
+
quantfin/models/sabr.py,sha256=hD-z8c5mHIj_yJ3qb1BwUZfpCtso7Ird7poFz16ff_U,2076
|
|
45
|
+
quantfin/models/sabr_jump.py,sha256=9-WtfVzPmcyUXDvkqbOcC_0IUouFRISlRO2oQb8h7PA,2020
|
|
46
|
+
quantfin/models/vasicek.py,sha256=UhyUXKR1OI9h62Y7_lO6IED5Ff1gnKDb5Pd9Z_-d9UQ,2534
|
|
47
|
+
quantfin/models/vg.py,sha256=k_x0nMX9yFcQjtU2T7paXnxlrOgw2tc-N_dvn69Ven8,5194
|
|
48
|
+
quantfin/models/base/__init__.py,sha256=zZ7b7EU_XxBMPv1Dc1TyLMET8tLRZvbgBgnnW9k7328,416
|
|
49
|
+
quantfin/models/base/base_model.py,sha256=-a5tA6aSZvuCALR98P1UmfFS_xvRgHNuS1H2RIQkjRM,6678
|
|
50
|
+
quantfin/models/base/validators.py,sha256=G5MnQBVrWZWckwmoC6adOIrHmZVzvVy_oX9g5riGFas,3118
|
|
51
|
+
quantfin/parity/__init__.py,sha256=ynOaaQpdxaxQ8qxpVIwhPOe3c9eRvwX0U7Gzxci43Is,284
|
|
52
|
+
quantfin/parity/implied_rate.py,sha256=OfanFacpTZTMjYNl5lY7VNDT5ngU_5BXNQIrfjntDng,3224
|
|
53
|
+
quantfin/parity/parity_model.py,sha256=f3oOm0fS_YxulR1fCb5cDBkbnjFSJ9CF4LvCFTSfPno,5020
|
|
54
|
+
quantfin/techniques/__init__.py,sha256=ekXkIj4yyuwcSg3UBKD2HAjar38OAk5QR1seL3BjTbE,843
|
|
55
|
+
quantfin/techniques/closed_form.py,sha256=LT2UuxZ3BwjIYEX9GM5OD32bA_nLLD_ubH-OZI-MPFM,10435
|
|
56
|
+
quantfin/techniques/crr.py,sha256=IQZIJah-0Akna4sUOpowbn1ZrcThGKH76qucSVjVpzk,1763
|
|
57
|
+
quantfin/techniques/fft.py,sha256=6H3PjULGFA1zVqJC38t-bgVVnY8pC0Vw6ddsEZHPj9Q,5765
|
|
58
|
+
quantfin/techniques/integration.py,sha256=ZcD_l6yTVJc86x_XjemGPfcitIr-TnEPLalRkrDFTyk,6494
|
|
59
|
+
quantfin/techniques/leisen_reimer.py,sha256=0STpGp4D-4BVj_vNvfv7nGM9iWjON46DwcE_TXdHzSc,1789
|
|
60
|
+
quantfin/techniques/monte_carlo.py,sha256=Q_FeDHylf6OxHMv68c_NzwUiwyFGjfgVtjWaMfPaESw,9439
|
|
61
|
+
quantfin/techniques/pde.py,sha256=0yuCrYslLZt1QitT32Qau74cmqp2x6jWiExuVJIXF80,5177
|
|
62
|
+
quantfin/techniques/topm.py,sha256=4oYXIOkY09ROmJH2uPm9zDYPdO3QUIMmhYcE4aQQa6A,1761
|
|
63
|
+
quantfin/techniques/base/__init__.py,sha256=flsXV7kxBL-kKznd_zi3cOdNK9XaCVkUnPFf5EgLTZ8,494
|
|
64
|
+
quantfin/techniques/base/base_technique.py,sha256=g345k3PmjkVLPWmoNpP988ZoRNPzIwiOohrTyTICfXE,1517
|
|
65
|
+
quantfin/techniques/base/greek_mixin.py,sha256=d-TjtVbJFHs13r6WlFEj0tlXOfQdANSQr11Obl8OYe0,8539
|
|
66
|
+
quantfin/techniques/base/iv_mixin.py,sha256=s0U53r2dBtUrb7XOBJx3ka5QtX2YitsQKUD8buPqm8s,3755
|
|
67
|
+
quantfin/techniques/base/lattice_technique.py,sha256=SCnp7dWFRJtwW7rGHDiUJlntXg0NLTpCujnfP30t-B4,4528
|
|
68
|
+
quantfin/techniques/base/pricing_result.py,sha256=aepfae0vEiemaokx9-LfX1CAB1IwfwER2C6fz21L1iA,719
|
|
69
|
+
quantfin/techniques/base/random_utils.py,sha256=IGQaK6GgI59GKcuh5_cBSLVMhh1xyiRLj2wkwiC5jsg,894
|
|
70
|
+
quantfin/techniques/kernels/__init__.py,sha256=t13XF2-7N8Ogmm5Ajc8cmz-IU_ZONO84WqQIr7rodYE,864
|
|
71
|
+
quantfin/techniques/kernels/lattice_kernels.py,sha256=4JhtAnaOzjiM5ibSdAChlCzf-OwGwC9u3N3_LT5Bd_I,8067
|
|
72
|
+
quantfin/techniques/kernels/mc_kernels.py,sha256=2OedPrcRch0B1ZRiZZ13QYc5S292p1fnm7t-ONddavQ,8707
|
|
73
|
+
quantfin/workflows/__init__.py,sha256=Wri6_MkOUafaYqQ5YlKajTWlmUm24gGKkdN4yng4S5Q,366
|
|
74
|
+
quantfin/workflows/backtest_workflow.py,sha256=UBkT_2FcqwwHjNi4HSaf8sohaVisCsurWFZWS1hldDg,4631
|
|
75
|
+
quantfin/workflows/daily_workflow.py,sha256=jQdQoKYv1jdCISeJlRbr1qRQAWyWtJxLQuq-kT6Jab8,5993
|
|
76
|
+
quantfin/workflows/configs/__init__.py,sha256=ScvbioPGYmEr5D03NlWtOZdLhImIrPcqpbDetBEEU3M,1680
|
|
77
|
+
quantfin/workflows/configs/bates_config.py,sha256=7_akOW5zC1mn9snBSc_q5nrsHdGKytp0em9iD4JvHgU,668
|
|
78
|
+
quantfin/workflows/configs/bsm_config.py,sha256=4g7lxInXxGBzALKmnLPpBqNLU5FuDkxC0ldl9v-kcHk,219
|
|
79
|
+
quantfin/workflows/configs/cev_config.py,sha256=K4VPZGjcvlw9CGV-ztsGHybebwOGVbQWQgQI1Ct0YMY,365
|
|
80
|
+
quantfin/workflows/configs/cgmy_config.py,sha256=995K_fajsk-GeBXaxYpudiPdVk8ObA7BbVz5GQU_X1M,385
|
|
81
|
+
quantfin/workflows/configs/heston_config.py,sha256=-qcSGalZLSCEb0WsjOjwNijAEA-woIEaoOzusvDsH-o,485
|
|
82
|
+
quantfin/workflows/configs/hyperbolic_config.py,sha256=KeorZuH8oMlS8sNNaabAiBro9TIqEHs9RUEJ-AWpQz0,461
|
|
83
|
+
quantfin/workflows/configs/kou_config.py,sha256=jUbLaNQdeubzCuCVJqNdXmkzazf01diUxFrBaY9IhRc,406
|
|
84
|
+
quantfin/workflows/configs/merton_config.py,sha256=hkP2xIYr42ncC1y9R80L3RZ8YfaVQflfPYrI2hbv4ck,572
|
|
85
|
+
quantfin/workflows/configs/nig_config.py,sha256=4FkOCxpgqs3oqNHdKXL-JTb9fH4zh7XklyFxAxZ4trg,352
|
|
86
|
+
quantfin/workflows/configs/sabr_config.py,sha256=5K6_ox5lISEBy1wnwNICP1Oz_Oy2Egdb4ugnAef1bIo,443
|
|
87
|
+
quantfin/workflows/configs/vg_config.py,sha256=nW00pg0BiF0zO9xLCdeB3QSPwUKDJZjG3_RtBjVdKts,358
|
|
88
|
+
optpricing-2.0.0.dist-info/METADATA,sha256=NfV22Us0hOWWhrWlE6JXjsE9o_FCrKVHvlwC74xIsMg,5271
|
|
89
|
+
optpricing-2.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
90
|
+
optpricing-2.0.0.dist-info/entry_points.txt,sha256=JW4AKTLsbov_W_ukEvhKs-uej-qPDseyZ_89sMvqxE0,76
|
|
91
|
+
optpricing-2.0.0.dist-info/top_level.txt,sha256=9UvyTQJH-cGBR5CudCBa2Nw572FA2aEGuxoOg3tI2vo,9
|
|
92
|
+
optpricing-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# MIT LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright 2025 Diljit Singh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
quantfin
|
quantfin/__init__.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""
|
|
2
|
+
quantfin - A Python Quantitative Finance Library
|
|
3
|
+
=================================================
|
|
4
|
+
This library provides a comprehensive suite of tools for pricing financial
|
|
5
|
+
derivatives, calibrating models, and analyzing market data.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Core Data Structures (Atoms)
|
|
9
|
+
from .atoms import (
|
|
10
|
+
ExerciseStyle,
|
|
11
|
+
Option,
|
|
12
|
+
OptionType,
|
|
13
|
+
Rate,
|
|
14
|
+
Stock,
|
|
15
|
+
ZeroCouponBond,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Calibration
|
|
19
|
+
from .calibration import Calibrator, VolatilitySurface
|
|
20
|
+
|
|
21
|
+
# Models
|
|
22
|
+
from .models import (
|
|
23
|
+
BatesModel,
|
|
24
|
+
BlacksApproxModel,
|
|
25
|
+
BSMModel,
|
|
26
|
+
CEVModel,
|
|
27
|
+
CGMYModel,
|
|
28
|
+
CIRModel,
|
|
29
|
+
DupireLocalVolModel,
|
|
30
|
+
HestonModel,
|
|
31
|
+
HyperbolicModel,
|
|
32
|
+
KouModel,
|
|
33
|
+
MertonJumpModel,
|
|
34
|
+
NIGModel,
|
|
35
|
+
PerpetualPutModel,
|
|
36
|
+
SABRJumpModel,
|
|
37
|
+
SABRModel,
|
|
38
|
+
VarianceGammaModel,
|
|
39
|
+
VasicekModel,
|
|
40
|
+
)
|
|
41
|
+
from .parity import ImpliedRateModel, ParityModel
|
|
42
|
+
|
|
43
|
+
# Techniques
|
|
44
|
+
from .techniques import (
|
|
45
|
+
ClosedFormTechnique,
|
|
46
|
+
CRRTechnique,
|
|
47
|
+
FFTTechnique,
|
|
48
|
+
IntegrationTechnique,
|
|
49
|
+
LeisenReimerTechnique,
|
|
50
|
+
MonteCarloTechnique,
|
|
51
|
+
PDETechnique,
|
|
52
|
+
TOPMTechnique,
|
|
53
|
+
)
|
|
54
|
+
from .techniques.base import PricingResult
|
|
55
|
+
from .workflows import BacktestWorkflow, DailyWorkflow
|
|
56
|
+
|
|
57
|
+
# Define the public API for the top level package
|
|
58
|
+
__all__ = [
|
|
59
|
+
# Atoms & Results
|
|
60
|
+
"ExerciseStyle",
|
|
61
|
+
"Option",
|
|
62
|
+
"OptionType",
|
|
63
|
+
"PricingResult",
|
|
64
|
+
"Rate",
|
|
65
|
+
"Stock",
|
|
66
|
+
"ZeroCouponBond",
|
|
67
|
+
# Models (alphabetically sorted)
|
|
68
|
+
"BatesModel",
|
|
69
|
+
"BlacksApproxModel",
|
|
70
|
+
"BSMModel",
|
|
71
|
+
"CEVModel",
|
|
72
|
+
"CGMYModel",
|
|
73
|
+
"CIRModel",
|
|
74
|
+
"DupireLocalVolModel",
|
|
75
|
+
"HestonModel",
|
|
76
|
+
"HyperbolicModel",
|
|
77
|
+
"ImpliedRateModel",
|
|
78
|
+
"KouModel",
|
|
79
|
+
"MertonJumpModel",
|
|
80
|
+
"NIGModel",
|
|
81
|
+
"ParityModel",
|
|
82
|
+
"PerpetualPutModel",
|
|
83
|
+
"SABRJumpModel",
|
|
84
|
+
"SABRModel",
|
|
85
|
+
"VarianceGammaModel",
|
|
86
|
+
"VasicekModel",
|
|
87
|
+
# Techniques (alphabetically sorted)
|
|
88
|
+
"ClosedFormTechnique",
|
|
89
|
+
"CRRTechnique",
|
|
90
|
+
"FFTTechnique",
|
|
91
|
+
"IntegrationTechnique",
|
|
92
|
+
"LeisenReimerTechnique",
|
|
93
|
+
"MonteCarloTechnique",
|
|
94
|
+
"PDETechnique",
|
|
95
|
+
"TOPMTechnique",
|
|
96
|
+
# Workflows & Calibration
|
|
97
|
+
"BacktestWorkflow",
|
|
98
|
+
"Calibrator",
|
|
99
|
+
"DailyWorkflow",
|
|
100
|
+
"VolatilitySurface",
|
|
101
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
__doc__ = """
|
|
4
|
+
The `atoms` package provides the fundamental data structures used throughout
|
|
5
|
+
the quantfin library, representing core financial concepts like options,
|
|
6
|
+
stocks, and interest rates.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .bond import ZeroCouponBond
|
|
10
|
+
from .option import ExerciseStyle, Option, OptionType
|
|
11
|
+
from .rate import Rate
|
|
12
|
+
from .stock import Stock
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Option",
|
|
16
|
+
"OptionType",
|
|
17
|
+
"ExerciseStyle",
|
|
18
|
+
"Rate",
|
|
19
|
+
"Stock",
|
|
20
|
+
"ZeroCouponBond",
|
|
21
|
+
]
|
quantfin/atoms/bond.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
__doc__ = """
|
|
6
|
+
This module defines the data structure for a zero-coupon bond.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class ZeroCouponBond:
|
|
12
|
+
"""
|
|
13
|
+
Represents a zero-coupon bond contract.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
maturity : float
|
|
18
|
+
The time to maturity of the bond, in years.
|
|
19
|
+
face_value : float, optional
|
|
20
|
+
The face value of the bond, paid at maturity. Defaults to 1.0.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
maturity: float
|
|
24
|
+
face_value: float = 1.0
|
|
25
|
+
|
|
26
|
+
def __post_init__(self):
|
|
27
|
+
if self.maturity <= 0:
|
|
28
|
+
raise ValueError(f"Maturity must be positive, got {self.maturity}")
|
quantfin/atoms/option.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass, replace
|
|
4
|
+
from enum import Enum
|
|
5
|
+
|
|
6
|
+
__doc__ = """
|
|
7
|
+
This module defines the core data structures for representing financial options.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class OptionType(Enum):
|
|
12
|
+
"""Enumeration for the type of an option (Call or Put)."""
|
|
13
|
+
|
|
14
|
+
CALL = "Call"
|
|
15
|
+
PUT = "Put"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ExerciseStyle(Enum):
|
|
19
|
+
"""Enumeration for the exercise style of an option."""
|
|
20
|
+
|
|
21
|
+
EUROPEAN = "European"
|
|
22
|
+
AMERICAN = "American"
|
|
23
|
+
BERMUDAN = "Bermudan"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True, slots=True)
|
|
27
|
+
class Option:
|
|
28
|
+
"""
|
|
29
|
+
Immutable container representing a single vanilla option contract.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
strike : float
|
|
34
|
+
The strike price of the option.
|
|
35
|
+
maturity : float
|
|
36
|
+
The time to maturity of the option, expressed in years.
|
|
37
|
+
option_type : OptionType
|
|
38
|
+
The type of the option, either CALL or PUT.
|
|
39
|
+
exercise_style : ExerciseStyle, optional
|
|
40
|
+
The exercise style of the option, by default ExerciseStyle.EUROPEAN.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
strike: float
|
|
44
|
+
maturity: float
|
|
45
|
+
option_type: OptionType
|
|
46
|
+
exercise_style: ExerciseStyle = ExerciseStyle.EUROPEAN
|
|
47
|
+
|
|
48
|
+
def __post_init__(self):
|
|
49
|
+
if self.strike <= 0:
|
|
50
|
+
raise ValueError(f"Strike must be positive, got {self.strike}")
|
|
51
|
+
if self.maturity <= 0:
|
|
52
|
+
raise ValueError(f"Maturity must be positive, got {self.maturity}")
|
|
53
|
+
|
|
54
|
+
def parity_counterpart(self) -> Option:
|
|
55
|
+
"""
|
|
56
|
+
Create the put-call parity equivalent of this option.
|
|
57
|
+
|
|
58
|
+
A call is converted to a put, and a put is converted to a call,
|
|
59
|
+
while keeping all other parameters the same.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
Option
|
|
64
|
+
A new Option instance with the opposite type.
|
|
65
|
+
"""
|
|
66
|
+
if self.option_type is OptionType.PUT:
|
|
67
|
+
other_type = OptionType.CALL
|
|
68
|
+
else:
|
|
69
|
+
other_type = OptionType.PUT
|
|
70
|
+
return replace(self, option_type=other_type)
|
quantfin/atoms/rate.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
|
|
6
|
+
__doc__ = """
|
|
7
|
+
This module defines the data structure for representing interest rates.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True, slots=True)
|
|
12
|
+
class Rate:
|
|
13
|
+
"""
|
|
14
|
+
Represents the risk-free interest rate structure.
|
|
15
|
+
|
|
16
|
+
This can be a single constant rate or a full term structure.
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
rate : float | Callable[[float], float]
|
|
21
|
+
- If a float, represents a constant risk-free rate for all maturities.
|
|
22
|
+
- If a callable, it should be a function that takes a maturity (t)
|
|
23
|
+
and returns the continuously compounded zero rate for that maturity.
|
|
24
|
+
Example: `lambda t: 0.02 + 0.01 * t`
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
rate: float | Callable[[float], float]
|
|
28
|
+
|
|
29
|
+
def get_rate(self, t: float = 0) -> float:
|
|
30
|
+
"""
|
|
31
|
+
Get the interest rate for a specific maturity.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
t : float, optional
|
|
36
|
+
The time (maturity) for which to get the rate. This is only
|
|
37
|
+
used if the rate is a term structure (callable). Default is 0.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
float
|
|
42
|
+
The continuously compounded risk-free rate.
|
|
43
|
+
"""
|
|
44
|
+
if callable(self.rate):
|
|
45
|
+
return self.rate(t)
|
|
46
|
+
return self.rate
|
quantfin/atoms/stock.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
__doc__ = """
|
|
6
|
+
This module defines the data structure for representing the underlying asset.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class Stock:
|
|
12
|
+
"""
|
|
13
|
+
Immutable container representing the underlying asset's properties.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
spot : float
|
|
18
|
+
The current price of the underlying asset.
|
|
19
|
+
volatility : float | None, optional
|
|
20
|
+
The constant (implied or historical) volatility of the asset's returns.
|
|
21
|
+
Default is `None`.
|
|
22
|
+
dividend : float, optional
|
|
23
|
+
The continuously compounded dividend yield, by default 0.0.
|
|
24
|
+
discrete_dividends : list[float] | None, optional
|
|
25
|
+
A list of discrete dividend amounts. Default is `None`.
|
|
26
|
+
ex_div_times : list[float] | None, optional
|
|
27
|
+
A list of times (in years) for the discrete dividend payments.
|
|
28
|
+
Must correspond to `discrete_dividends`. Default is `None`.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
spot: float
|
|
32
|
+
volatility: float | None = None
|
|
33
|
+
dividend: float = 0.0
|
|
34
|
+
discrete_dividends: list[float] | None = None
|
|
35
|
+
ex_div_times: list[float] | None = None
|
|
36
|
+
|
|
37
|
+
def __post_init__(self):
|
|
38
|
+
if self.spot <= 0:
|
|
39
|
+
raise ValueError(f"Spot price must be positive, got {self.spot}")
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
__doc__ = """
|
|
4
|
+
The `calibration` package provides tools for fitting financial models to
|
|
5
|
+
market data, estimating parameters from historical data, and calculating
|
|
6
|
+
implied volatility surfaces.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .calibrator import Calibrator
|
|
10
|
+
from .fit_jump_parameters import fit_jump_params_from_history
|
|
11
|
+
from .fit_market_params import fit_rate_and_dividend
|
|
12
|
+
from .iv_surface import VolatilitySurface
|
|
13
|
+
from .technique_selector import select_fastest_technique
|
|
14
|
+
from .vectorized_bsm_iv import BSMIVSolver
|
|
15
|
+
from .vectorized_integration_iv import VectorizedIntegrationIVSolver
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"BSMIVSolver",
|
|
19
|
+
"Calibrator",
|
|
20
|
+
"VectorizedIntegrationIVSolver",
|
|
21
|
+
"VolatilitySurface",
|
|
22
|
+
"fit_jump_params_from_history",
|
|
23
|
+
"fit_rate_and_dividend",
|
|
24
|
+
"select_fastest_technique",
|
|
25
|
+
]
|