optPricing 2.0.0__tar.gz

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.
Files changed (177) hide show
  1. optpricing-2.0.0/CHANGELOG.md +6 -0
  2. optpricing-2.0.0/LICENSE +9 -0
  3. optpricing-2.0.0/MANIFEST.in +6 -0
  4. optpricing-2.0.0/PKG-INFO +105 -0
  5. optpricing-2.0.0/README.md +58 -0
  6. optpricing-2.0.0/docs/guide/dashboard.md +45 -0
  7. optpricing-2.0.0/docs/guide/getting_started.md +218 -0
  8. optpricing-2.0.0/docs/guide/installation.md +33 -0
  9. optpricing-2.0.0/docs/guide/introduction.md +35 -0
  10. optpricing-2.0.0/docs/images/bates.png +0 -0
  11. optpricing-2.0.0/docs/images/calibration.png +0 -0
  12. optpricing-2.0.0/docs/images/fit_jump.png +0 -0
  13. optpricing-2.0.0/docs/images/zcb.png +0 -0
  14. optpricing-2.0.0/docs/index.md +19 -0
  15. optpricing-2.0.0/docs/reference/atoms/bond.md +3 -0
  16. optpricing-2.0.0/docs/reference/atoms/index.md +8 -0
  17. optpricing-2.0.0/docs/reference/atoms/option.md +11 -0
  18. optpricing-2.0.0/docs/reference/atoms/rate.md +3 -0
  19. optpricing-2.0.0/docs/reference/atoms/stock.md +3 -0
  20. optpricing-2.0.0/docs/reference/calibration/calibrator.md +3 -0
  21. optpricing-2.0.0/docs/reference/calibration/fit_jump_parameters.md +3 -0
  22. optpricing-2.0.0/docs/reference/calibration/fit_market_params.md +11 -0
  23. optpricing-2.0.0/docs/reference/calibration/index.md +9 -0
  24. optpricing-2.0.0/docs/reference/calibration/iv_surface.md +3 -0
  25. optpricing-2.0.0/docs/reference/calibration/technique_selector.md +3 -0
  26. optpricing-2.0.0/docs/reference/calibration/vectorized_bsm_iv.md +3 -0
  27. optpricing-2.0.0/docs/reference/calibration/vectorized_integration_iv.md +3 -0
  28. optpricing-2.0.0/docs/reference/cli.md +7 -0
  29. optpricing-2.0.0/docs/reference/dashboard/index.md +7 -0
  30. optpricing-2.0.0/docs/reference/dashboard/plots.md +11 -0
  31. optpricing-2.0.0/docs/reference/dashboard/service.md +5 -0
  32. optpricing-2.0.0/docs/reference/dashboard/widgets.md +7 -0
  33. optpricing-2.0.0/docs/reference/data/historical_manager.md +3 -0
  34. optpricing-2.0.0/docs/reference/data/index.md +6 -0
  35. optpricing-2.0.0/docs/reference/data/market_data_manager.md +3 -0
  36. optpricing-2.0.0/docs/reference/models/base/base_model.md +3 -0
  37. optpricing-2.0.0/docs/reference/models/base/index.md +6 -0
  38. optpricing-2.0.0/docs/reference/models/base/validators.md +3 -0
  39. optpricing-2.0.0/docs/reference/models/bates.md +3 -0
  40. optpricing-2.0.0/docs/reference/models/blacks_approx.md +3 -0
  41. optpricing-2.0.0/docs/reference/models/bsm.md +3 -0
  42. optpricing-2.0.0/docs/reference/models/cev.md +3 -0
  43. optpricing-2.0.0/docs/reference/models/cgmy.md +3 -0
  44. optpricing-2.0.0/docs/reference/models/cir.md +3 -0
  45. optpricing-2.0.0/docs/reference/models/dupire_local.md +3 -0
  46. optpricing-2.0.0/docs/reference/models/heston.md +3 -0
  47. optpricing-2.0.0/docs/reference/models/hyperbolic.md +3 -0
  48. optpricing-2.0.0/docs/reference/models/index.md +12 -0
  49. optpricing-2.0.0/docs/reference/models/kou.md +3 -0
  50. optpricing-2.0.0/docs/reference/models/merton_jump.md +3 -0
  51. optpricing-2.0.0/docs/reference/models/nig.md +3 -0
  52. optpricing-2.0.0/docs/reference/models/perpetual_put.md +3 -0
  53. optpricing-2.0.0/docs/reference/models/sabr.md +3 -0
  54. optpricing-2.0.0/docs/reference/models/sabr_jump.md +3 -0
  55. optpricing-2.0.0/docs/reference/models/vasicek.md +3 -0
  56. optpricing-2.0.0/docs/reference/models/vg.md +3 -0
  57. optpricing-2.0.0/docs/reference/parity/implied_rate.md +3 -0
  58. optpricing-2.0.0/docs/reference/parity/index.md +6 -0
  59. optpricing-2.0.0/docs/reference/parity/parity_model.md +3 -0
  60. optpricing-2.0.0/docs/reference/techniques/base/base_technique.md +3 -0
  61. optpricing-2.0.0/docs/reference/techniques/base/greek_mixin.md +3 -0
  62. optpricing-2.0.0/docs/reference/techniques/base/index.md +10 -0
  63. optpricing-2.0.0/docs/reference/techniques/base/iv_mixin.md +3 -0
  64. optpricing-2.0.0/docs/reference/techniques/base/lattice_technique.md +3 -0
  65. optpricing-2.0.0/docs/reference/techniques/base/pricing_result.md +3 -0
  66. optpricing-2.0.0/docs/reference/techniques/base/random_utils.md +3 -0
  67. optpricing-2.0.0/docs/reference/techniques/closed_form.md +3 -0
  68. optpricing-2.0.0/docs/reference/techniques/crr.md +3 -0
  69. optpricing-2.0.0/docs/reference/techniques/fft.md +3 -0
  70. optpricing-2.0.0/docs/reference/techniques/index.md +13 -0
  71. optpricing-2.0.0/docs/reference/techniques/integration.md +3 -0
  72. optpricing-2.0.0/docs/reference/techniques/kernels/index.md +6 -0
  73. optpricing-2.0.0/docs/reference/techniques/kernels/lattice_kernels.md +5 -0
  74. optpricing-2.0.0/docs/reference/techniques/kernels/mc_kernels.md +5 -0
  75. optpricing-2.0.0/docs/reference/techniques/leisen_reimer.md +3 -0
  76. optpricing-2.0.0/docs/reference/techniques/monte_carlo.md +3 -0
  77. optpricing-2.0.0/docs/reference/techniques/pde.md +3 -0
  78. optpricing-2.0.0/docs/reference/techniques/topm.md +3 -0
  79. optpricing-2.0.0/docs/reference/workflows/backtest_workflow.md +3 -0
  80. optpricing-2.0.0/docs/reference/workflows/daily_workflow.md +3 -0
  81. optpricing-2.0.0/docs/reference/workflows/index.md +10 -0
  82. optpricing-2.0.0/mkdocs.yml +149 -0
  83. optpricing-2.0.0/pyproject.toml +80 -0
  84. optpricing-2.0.0/setup.cfg +4 -0
  85. optpricing-2.0.0/src/optPricing.egg-info/PKG-INFO +105 -0
  86. optpricing-2.0.0/src/optPricing.egg-info/SOURCES.txt +175 -0
  87. optpricing-2.0.0/src/optPricing.egg-info/dependency_links.txt +1 -0
  88. optpricing-2.0.0/src/optPricing.egg-info/entry_points.txt +3 -0
  89. optpricing-2.0.0/src/optPricing.egg-info/requires.txt +24 -0
  90. optpricing-2.0.0/src/optPricing.egg-info/top_level.txt +1 -0
  91. optpricing-2.0.0/src/quantfin/__init__.py +101 -0
  92. optpricing-2.0.0/src/quantfin/atoms/__init__.py +21 -0
  93. optpricing-2.0.0/src/quantfin/atoms/bond.py +28 -0
  94. optpricing-2.0.0/src/quantfin/atoms/option.py +70 -0
  95. optpricing-2.0.0/src/quantfin/atoms/rate.py +46 -0
  96. optpricing-2.0.0/src/quantfin/atoms/stock.py +39 -0
  97. optpricing-2.0.0/src/quantfin/calibration/__init__.py +25 -0
  98. optpricing-2.0.0/src/quantfin/calibration/calibrator.py +155 -0
  99. optpricing-2.0.0/src/quantfin/calibration/fit_jump_parameters.py +66 -0
  100. optpricing-2.0.0/src/quantfin/calibration/fit_market_params.py +120 -0
  101. optpricing-2.0.0/src/quantfin/calibration/iv_surface.py +155 -0
  102. optpricing-2.0.0/src/quantfin/calibration/technique_selector.py +47 -0
  103. optpricing-2.0.0/src/quantfin/calibration/vectorized_bsm_iv.py +93 -0
  104. optpricing-2.0.0/src/quantfin/calibration/vectorized_integration_iv.py +143 -0
  105. optpricing-2.0.0/src/quantfin/cli.py +372 -0
  106. optpricing-2.0.0/src/quantfin/config.py +57 -0
  107. optpricing-2.0.0/src/quantfin/dashboard/__init__.py +14 -0
  108. optpricing-2.0.0/src/quantfin/dashboard/app.py +26 -0
  109. optpricing-2.0.0/src/quantfin/dashboard/pages/1_Calibration.py +57 -0
  110. optpricing-2.0.0/src/quantfin/dashboard/pages/2_Pricer_and_Greeks.py +150 -0
  111. optpricing-2.0.0/src/quantfin/dashboard/pages/3_Financial_Tools.py +69 -0
  112. optpricing-2.0.0/src/quantfin/dashboard/pages/__init__.py +0 -0
  113. optpricing-2.0.0/src/quantfin/dashboard/plots.py +157 -0
  114. optpricing-2.0.0/src/quantfin/dashboard/service.py +176 -0
  115. optpricing-2.0.0/src/quantfin/dashboard/widgets.py +87 -0
  116. optpricing-2.0.0/src/quantfin/data/__init__.py +26 -0
  117. optpricing-2.0.0/src/quantfin/data/historical_manager.py +86 -0
  118. optpricing-2.0.0/src/quantfin/data/market_data_manager.py +236 -0
  119. optpricing-2.0.0/src/quantfin/models/__init__.py +54 -0
  120. optpricing-2.0.0/src/quantfin/models/base/__init__.py +16 -0
  121. optpricing-2.0.0/src/quantfin/models/base/base_model.py +198 -0
  122. optpricing-2.0.0/src/quantfin/models/base/validators.py +95 -0
  123. optpricing-2.0.0/src/quantfin/models/bates.py +192 -0
  124. optpricing-2.0.0/src/quantfin/models/blacks_approx.py +134 -0
  125. optpricing-2.0.0/src/quantfin/models/bsm.py +262 -0
  126. optpricing-2.0.0/src/quantfin/models/cev.py +109 -0
  127. optpricing-2.0.0/src/quantfin/models/cgmy.py +189 -0
  128. optpricing-2.0.0/src/quantfin/models/cir.py +90 -0
  129. optpricing-2.0.0/src/quantfin/models/dupire_local.py +67 -0
  130. optpricing-2.0.0/src/quantfin/models/heston.py +204 -0
  131. optpricing-2.0.0/src/quantfin/models/hyperbolic.py +170 -0
  132. optpricing-2.0.0/src/quantfin/models/kou.py +148 -0
  133. optpricing-2.0.0/src/quantfin/models/merton_jump.py +225 -0
  134. optpricing-2.0.0/src/quantfin/models/nig.py +180 -0
  135. optpricing-2.0.0/src/quantfin/models/perpetual_put.py +115 -0
  136. optpricing-2.0.0/src/quantfin/models/sabr.py +64 -0
  137. optpricing-2.0.0/src/quantfin/models/sabr_jump.py +68 -0
  138. optpricing-2.0.0/src/quantfin/models/vasicek.py +88 -0
  139. optpricing-2.0.0/src/quantfin/models/vg.py +178 -0
  140. optpricing-2.0.0/src/quantfin/parity/__init__.py +13 -0
  141. optpricing-2.0.0/src/quantfin/parity/implied_rate.py +110 -0
  142. optpricing-2.0.0/src/quantfin/parity/parity_model.py +178 -0
  143. optpricing-2.0.0/src/quantfin/techniques/__init__.py +31 -0
  144. optpricing-2.0.0/src/quantfin/techniques/base/__init__.py +21 -0
  145. optpricing-2.0.0/src/quantfin/techniques/base/base_technique.py +54 -0
  146. optpricing-2.0.0/src/quantfin/techniques/base/greek_mixin.py +265 -0
  147. optpricing-2.0.0/src/quantfin/techniques/base/iv_mixin.py +116 -0
  148. optpricing-2.0.0/src/quantfin/techniques/base/lattice_technique.py +129 -0
  149. optpricing-2.0.0/src/quantfin/techniques/base/pricing_result.py +27 -0
  150. optpricing-2.0.0/src/quantfin/techniques/base/random_utils.py +31 -0
  151. optpricing-2.0.0/src/quantfin/techniques/closed_form.py +296 -0
  152. optpricing-2.0.0/src/quantfin/techniques/crr.py +59 -0
  153. optpricing-2.0.0/src/quantfin/techniques/fft.py +178 -0
  154. optpricing-2.0.0/src/quantfin/techniques/integration.py +202 -0
  155. optpricing-2.0.0/src/quantfin/techniques/kernels/__init__.py +37 -0
  156. optpricing-2.0.0/src/quantfin/techniques/kernels/lattice_kernels.py +286 -0
  157. optpricing-2.0.0/src/quantfin/techniques/kernels/mc_kernels.py +337 -0
  158. optpricing-2.0.0/src/quantfin/techniques/leisen_reimer.py +59 -0
  159. optpricing-2.0.0/src/quantfin/techniques/monte_carlo.py +259 -0
  160. optpricing-2.0.0/src/quantfin/techniques/pde.py +155 -0
  161. optpricing-2.0.0/src/quantfin/techniques/topm.py +59 -0
  162. optpricing-2.0.0/src/quantfin/workflows/__init__.py +14 -0
  163. optpricing-2.0.0/src/quantfin/workflows/backtest_workflow.py +133 -0
  164. optpricing-2.0.0/src/quantfin/workflows/configs/__init__.py +51 -0
  165. optpricing-2.0.0/src/quantfin/workflows/configs/bates_config.py +25 -0
  166. optpricing-2.0.0/src/quantfin/workflows/configs/bsm_config.py +9 -0
  167. optpricing-2.0.0/src/quantfin/workflows/configs/cev_config.py +16 -0
  168. optpricing-2.0.0/src/quantfin/workflows/configs/cgmy_config.py +18 -0
  169. optpricing-2.0.0/src/quantfin/workflows/configs/heston_config.py +21 -0
  170. optpricing-2.0.0/src/quantfin/workflows/configs/hyperbolic_config.py +18 -0
  171. optpricing-2.0.0/src/quantfin/workflows/configs/kou_config.py +16 -0
  172. optpricing-2.0.0/src/quantfin/workflows/configs/merton_config.py +18 -0
  173. optpricing-2.0.0/src/quantfin/workflows/configs/nig_config.py +13 -0
  174. optpricing-2.0.0/src/quantfin/workflows/configs/sabr_config.py +19 -0
  175. optpricing-2.0.0/src/quantfin/workflows/configs/vg_config.py +9 -0
  176. optpricing-2.0.0/src/quantfin/workflows/daily_workflow.py +150 -0
  177. optpricing-2.0.0/tests/test_cli.py +88 -0
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## [2.0.0] - 2025-06-26
4
+ ### Added
5
+ - Shipped to PyPI `pyproject.toml`
6
+
@@ -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,6 @@
1
+ include README.md
2
+ include LICENSE
3
+ include CHANGELOG.md
4
+ include pyproject.toml
5
+ include mkdocs.yml
6
+ recursive-include docs *
@@ -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
+ [![CI/CD](https://github.com/diljit22/quantfin/actions/workflows/ci.yml/badge.svg)](https://github.com/diljit22/quantfin/actions/workflows/ci.yml)
51
+ [![PyPI Version](https://badge.fury.io/py/quantfin.svg)](https://pypi.org/project/quantfin/)
52
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
53
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](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,58 @@
1
+ # QuantFin
2
+
3
+ [![CI/CD](https://github.com/diljit22/quantfin/actions/workflows/ci.yml/badge.svg)](https://github.com/diljit22/quantfin/actions/workflows/ci.yml)
4
+ [![PyPI Version](https://badge.fury.io/py/quantfin.svg)](https://pypi.org/project/quantfin/)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
7
+
8
+ **A Python library for pricing and calibrating financial options.**
9
+
10
+ ## Introduction
11
+
12
+ 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.
13
+
14
+ QuantFin is structured around four core pillars:
15
+
16
+ - **Atoms**: Fundamental data types (`Option`, `Stock`, `Rate`) that ensure consistency and clarity of inputs across the library.
17
+ - **Models**: A broad library ranging from classical Black-Scholes-Merton to advanced stochastic volatility (Heston, SABR) and jump/Lévy processes.
18
+ - **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).
19
+ - **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.
20
+
21
+ ---
22
+
23
+ ## Quick Start
24
+
25
+ Get started in minutes using the command-line interface.
26
+
27
+ ```bash
28
+ # 1. Install the library with all features, including the dashboard
29
+ pip install optPricing[app]
30
+
31
+ # 2. Download historical data for a ticker (used by some models)
32
+ quantfin data download --ticker SPY
33
+
34
+ # 3. Launch the interactive dashboard to visualize the results
35
+ quantfin dashboard
36
+
37
+ # 4. See a demo of the engine
38
+ quantfin demo
39
+ ```
40
+
41
+ ## Documentation & Links
42
+
43
+ For a detailed tutorial, full API reference, and more examples, please see the official documentation.
44
+
45
+ - **Getting Started**: [Installation Guide](installation.md) · [Walkthrough](getting_started.md)
46
+ - **Documentation**: [API Reference](reference/atoms/index.md)
47
+ - **Interactive Dashboard**: [Launch the UI](dashboard.md)
48
+ - **About Me**: [LinkedIn]([dashboard.md](https://www.linkedin.com/in/singhdiljit/))
49
+
50
+ To explore all available commands, run:
51
+
52
+ ```bash
53
+ quantfin --help
54
+ ```
55
+
56
+ ## Contributing & License
57
+
58
+ See [CONTRIBUTING](/CONTRIBUTING.md) and [LICENSE](LICENSE).
@@ -0,0 +1,45 @@
1
+ # Using the Interactive Dashboard
2
+
3
+ The `quantfin` library includes an interactive dashboard built with Streamlit,
4
+ providing a visual interface for the library's core features.
5
+
6
+ ## Launching the Dashboard
7
+
8
+ To use the dashboard, you must first install the library with the `[app]` extra dependencies:
9
+
10
+ ```bash
11
+ pip install optPricing[app]
12
+ ```
13
+
14
+ Once installed, you can launch the application from your terminal with a single command:
15
+
16
+ ```bash
17
+ quantfin dashboard
18
+ ```
19
+
20
+ This will open the application in a new browser tab.
21
+
22
+ ## Dashboard Pages
23
+
24
+ The dashboard is organized into several pages, accessible from the sidebar on the left.
25
+
26
+ ### Calibration
27
+
28
+ This is the main page for model calibration. It allows you to select a ticker and one or more models, run the calibration workflow, and see a detailed analysis of the results.
29
+
30
+ ![alt text](../images/calibration.png)
31
+
32
+ ### Pricer and Greeks
33
+
34
+ This page is an interactive pricing tool that allows you to explore the behavior of different models and techniques in real-time. You can adjust all market and model parameters to see their effect on the option price and its Greeks.
35
+ ![alt text](../images/bates.png)
36
+
37
+ ### Financial Tools
38
+
39
+ This page provides access to several utility functions from the library for more specific analyses.
40
+ Historical Jump Fitter: Select a ticker to estimate jump-diffusion parameters directly from its historical returns data.
41
+ ![alt text](../images/fit_jump.png)
42
+
43
+ Term Structure Pricer: Price a zero-coupon bond using interest rate models like Vasicek or CIR.
44
+
45
+ ![alt text](../images/zcb.png)
@@ -0,0 +1,218 @@
1
+ # Getting Started: A Walkthrough
2
+
3
+ This guide is a hands-on tutorial that will walk you through the library's core features,
4
+ from pricing a single option to running a full model calibration, using the command-line
5
+ interface (CLI).
6
+
7
+ ---
8
+
9
+ ## 1. Run the Built-In Demo
10
+
11
+ The quickest way to see QuantFin in action is with the included benchmark script.
12
+
13
+ **Prerequisite**: install the library if you haven’t already:
14
+
15
+ ```bash
16
+ pip install optPricing
17
+ ```
18
+
19
+ Then execute:
20
+
21
+ ```bash
22
+ quantfin demo
23
+ ```
24
+
25
+ This will price a standard option across multiple models and techniques and print a
26
+ formatted comparison table.
27
+
28
+ ---
29
+
30
+ ## 2. Pricing an Option Programmatically
31
+
32
+ First, import and configure the objects you need:
33
+
34
+ ```python
35
+ from quantfin.atoms import Option, Stock, Rate, OptionType, ZeroCouponBond
36
+ from quantfin.models import BSMModel, VasicekModel, CIRModel
37
+ from quantfin.techniques import ClosedFormTechnique
38
+
39
+ # 1. Define an option, underlying and rate
40
+ option = Option(strike=105, maturity=1.0, option_type=OptionType.CALL)
41
+ stock = Stock(spot=100, dividend=0.01)
42
+ rate = Rate(rate=0.05)
43
+
44
+ # 2. Choose a model and technique
45
+ bsm_model = BSMModel(params={"sigma": 0.20})
46
+ cf_technique = ClosedFormTechnique()
47
+ ```
48
+
49
+ ### 2.1 Compute the Price
50
+
51
+ ```python
52
+ result = cf_technique.price(option, stock, bsm_model, rate)
53
+ print(f"The option price is: {result.price:.4f}")
54
+ >>> The option price is: 7.4917
55
+ ```
56
+
57
+ ### 2.2 Compute the Greeks
58
+
59
+ ```python
60
+ delta = cf_technique.delta(option, stock, bsm_model, rate)
61
+ gamma = cf_technique.gamma(option, stock, bsm_model, rate)
62
+ vega = cf_technique.vega(option, stock, bsm_model, rate)
63
+
64
+ print(f"Delta: {delta:.4f}")
65
+ print(f"Gamma: {gamma:.4f}")
66
+ print(f"Vega: {vega:.4f}")
67
+
68
+ >>> Delta: 0.5172
69
+ >>> Gamma: 0.0197
70
+ >>> Vega: 39.4353
71
+ ```
72
+
73
+ ### 2.3 Find Implied Volatility
74
+
75
+ ```python
76
+ target_price = 7.50
77
+ iv = cf_technique.implied_volatility(
78
+ option, stock, bsm_model, rate, target_price=target_price
79
+ )
80
+ print(f"Implied volatility for price ${target_price:.2f}: {iv:.4%}")
81
+ >>> Implied volatility for price $7.50: 20.0211%
82
+ ```
83
+
84
+ ---
85
+
86
+ ## 3. Pricing Interest‐Rate Instruments
87
+
88
+ QuantFin reuses the same pricing interfaces for interest‐rate models:
89
+
90
+ ```python
91
+ # Zero‐coupon bond maturing in 1 year
92
+ bond = ZeroCouponBond(maturity=1.0)
93
+ r0_stock = Stock(spot=0.05) # initial short rate
94
+ dummy_rate = Rate(rate=0.0) # ignored by rate models
95
+
96
+ vasicek = VasicekModel(params={"kappa":0.86, "theta":0.09, "sigma":0.02})
97
+ cir = CIRModel(params={"kappa":0.86, "theta":0.09, "sigma":0.02})
98
+
99
+ p_vasi = cf_technique.price(bond, r0_stock, vasicek, dummy_rate).price
100
+ p_cir = cf_technique.price(bond, r0_stock, cir, dummy_rate).price
101
+
102
+ print(f"Vasicek ZCB Price: {p_vasi:.4f}")
103
+ print(f"CIR ZCB Price: {p_cir:.4f}")
104
+
105
+ >>> Vasicek ZCB Price: 0.9388
106
+ >>> CIR ZCB Price: 0.9388
107
+ ```
108
+
109
+ ---
110
+
111
+ ## 4. Live Pricing and Analysis via CLI
112
+
113
+ ### 4.1 Price an Option
114
+
115
+ ```bash
116
+ quantfin price \
117
+ --ticker SPY \
118
+ --strike 500 \
119
+ --maturity 2025-12-19 \
120
+ --type call \
121
+ --model Heston \
122
+ --param "v0=0.04" \
123
+ --param "kappa=2.0" \
124
+ --param "theta=0.05" \
125
+ --param "rho=-0.7" \
126
+ --param "vol_of_vol=0.5"
127
+ ```
128
+
129
+ ### 4.2 Implied Rate from Put-Call Parity
130
+
131
+ The tools implied-rate command fetches live prices for a call-put pair and calculates the risk-free rate implied by put-call parity.
132
+
133
+ ```bash
134
+ quantfin tools implied-rate --ticker SPY --strike 500 --maturity 2025-12-19
135
+ ```
136
+
137
+ ---
138
+
139
+ ## 5. Model Calibration with the CLI
140
+
141
+ Download historical returns (for initial guesses and jump paramaters):
142
+
143
+ ```bash
144
+ quantfin data download --ticker SPY
145
+ ```
146
+
147
+ Download a snapshot of the market-data
148
+
149
+ ```bash
150
+ # For the 25 benchmark stocks use --all
151
+ quantfin data snapshot --all
152
+
153
+ # If just a particular ticker use e.g.
154
+ quantfin data snapshot --ticker SPY --ticker AAPL
155
+ ```
156
+
157
+ A simple calibration for the Merton Jump model. The workflow will find the latest market data
158
+ for SPY and solve for the implied volatility that best fits the front-month options.
159
+
160
+ The `--verbose` flag provides detailed logs from the workflow.
161
+
162
+ ```bash
163
+ quantfin calibrate --ticker SPY --model Merton --verbose
164
+ ```
165
+
166
+ The final calibrated parameters are printed to the console and saved to a JSON file in
167
+ the `artifacts/calibrated_params/` directory.
168
+
169
+ ---
170
+
171
+ ## 6. Managing Data
172
+
173
+ * Download specific tickers:
174
+
175
+ ```bash
176
+ quantfin data download --ticker AAPL --ticker TSLA
177
+ ```
178
+
179
+ * Download all defaults (from `config.yaml`):
180
+
181
+ ```bash
182
+ quantfin data download --all
183
+ ```
184
+
185
+ * Snapshot the live option chain:
186
+
187
+ ```bash
188
+ quantfin data snapshot --ticker NVDA
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 7. Running Tests
194
+
195
+ If you have installed dev dependencies:
196
+
197
+ ```bash
198
+ pip install -e .[dev]
199
+ pytest
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 8. Launching the Dashboard
205
+
206
+ Make sure you have the `[app]` extras installed:
207
+
208
+ ```bash
209
+ pip install optPricing[app]
210
+ ```
211
+
212
+ Then run:
213
+
214
+ ```bash
215
+ quantfin dashboard
216
+ ```
217
+
218
+ This will open the Streamlit application in your browser for interactive exploration.
@@ -0,0 +1,33 @@
1
+ # Installation
2
+
3
+ The QuantFin library is published on the Python Package Index (PyPI) and can be easily installed using `pip`. A Python version of 3.10 or higher is required.
4
+
5
+ ## Standard Installation
6
+
7
+ For most use cases, including running the command-line interface for calibration and backtesting, you can install the core library with the following command:
8
+
9
+ ```bash
10
+ pip install optPricing
11
+ ```
12
+
13
+ This will install the library and all its core dependencies, such as numpy, scipy, and typer.
14
+
15
+ ## Full Installation (with Dashboard)
16
+
17
+ The library includes an optional interactive dashboard built with Streamlit, which provides a visual way to interact with the pricing and calibration tools. To install the core library along with the dependencies needed to run the dashboard, use the [app] extra:
18
+
19
+ ```bash
20
+ pip install optPricing[app]
21
+ ```
22
+
23
+ This is the recommended installation if you plan to use the visual tools.
24
+
25
+ ## Developer Installation
26
+
27
+ If you wish to contribute to the development of QuantFin, or if you want to make local modifications to the source code, you should clone the repository and install it in "editable" mode.
28
+
29
+ ```bash
30
+ git clone https://github.com/diljit22/quantfin.git
31
+ cd quantfin
32
+ pip install -e .[app,dev]
33
+ ```
@@ -0,0 +1,35 @@
1
+ # Introduction
2
+
3
+ Welcome to the QuantFin library! This documentation is your comprehensive guide to understanding and using all the features this library has to offer.
4
+
5
+ ## What is QuantFin?
6
+
7
+ QuantFin is a Python library designed to provide a toolkit for quantitative finance, with a primary focus on the pricing and analysis of financial derivatives.
8
+
9
+ The library is organized around a few core concepts; understanding these will help you navigate the codebase and documentation.
10
+
11
+ - **Atoms**: These are the fundamental, immutable data structures representing core financial concepts like `Option`, `Stock`, and `Rate`. By using these "atoms," we ensure that data is passed through the system in a consistent and predictable way.
12
+
13
+ - **Models**: This is a collection of classes representing financial models. It includes everything from the standard Black-Scholes-Merton to advanced models with stochastic volatility (Heston, SABR) and jumps (Merton, Bates, Kou). Each model is a self-contained representation of a specific financial theory.
14
+
15
+ - **Techniques**: These are the numerical or analytical algorithms used for pricing, such as Monte Carlo simulation, Fast Fourier Transform (FFT), or finite difference methods (PDEs). This design choice decouples the "what" (the model) from the "how" (the pricing algorithm), allowing you to, for example, price a Heston model using either FFT or Monte Carlo.
16
+
17
+ - **Workflows**: These are high-level orchestrators that combine data, models, and techniques to perform complex, real-world tasks like daily model calibration or historical backtesting. They are the engines that power the command-line interface and the dashboard.
18
+
19
+ ## Our Philosophy
20
+
21
+ The library was designed with the following principles in mind:
22
+
23
+ - **Speed**: For computationally intensive tasks like Monte Carlo simulation, we use `numba` to JIT-compile the core numerical kernels, resulting in performance that rivals compiled languages like C or Fortran.
24
+
25
+ - **Accuracy**: Standard, well-vetted numerical algorithms are used for pricing, calibration, and root-finding, providing a reliable foundation for your analysis.
26
+
27
+ - **Extensibility**: The object-oriented design, centered around the `BaseModel` and `BaseTechnique` abstract classes, makes it straightforward for you or other developers to add new models or pricing methods without disrupting the existing structure.
28
+
29
+ - **Usability**: A powerful command-line interface (CLI) and an interactive Streamlit dashboard are provided for common tasks, making the library accessible to users who may not want to write Python code for every analysis.
30
+
31
+ Ready to get started? Head over to:
32
+
33
+ - [Getting Started](guide/getting_started.md)
34
+ - [API Reference](reference/atoms/index.md)
35
+ - [Interactive Dashboard](guide/dashboard.md)
Binary file
Binary file
@@ -0,0 +1,19 @@
1
+ # Welcome to QuantFin
2
+
3
+ QuantFin is a Python library for pricing and calibrating financial derivatives.
4
+
5
+ It features a rich CLI, as well as an interactive dashboard;
6
+
7
+ ```bash
8
+ quantfin dashboard
9
+ ```
10
+
11
+ This will open a Streamlit application in your browser where you can perform calibrations, price options, and visualize results without writing any code.
12
+
13
+ ![QuantFin Calibration Dashboard](images/calibration.png)
14
+
15
+ ---
16
+
17
+ - [Getting Started](guide/getting_started.md)
18
+ - [API Reference](reference/atoms/index.md)
19
+ - [Interactive Dashboard](guide/dashboard.md)
@@ -0,0 +1,3 @@
1
+ # ZeroCouponBond
2
+
3
+ ::: src.quantfin.atoms.bond.ZeroCouponBond
@@ -0,0 +1,8 @@
1
+ # Atoms Package
2
+
3
+ The `atoms` package provides the fundamental data structures used throughout the `quantfin` library. These classes are immutable containers that represent core financial concepts.
4
+
5
+ - **Stock**: Represents the underlying asset.
6
+ - **Option**: Represents a vanilla option contract, including its type and style.
7
+ - **Rate**: Represents the risk-free interest rate structure.
8
+ - **Bond**: Represents a simple zero-coupon bond.
@@ -0,0 +1,11 @@
1
+ # Option
2
+
3
+ ::: src.quantfin.atoms.option.Option
4
+
5
+ ## OptionType
6
+
7
+ ::: src.quantfin.atoms.option.OptionType
8
+
9
+ ## ExerciseStyle
10
+
11
+ ::: src.quantfin.atoms.option.ExerciseStyle
@@ -0,0 +1,3 @@
1
+ # Rate
2
+
3
+ ::: src.quantfin.atoms.rate.Rate
@@ -0,0 +1,3 @@
1
+ # Stock
2
+
3
+ ::: src.quantfin.atoms.stock.Stock
@@ -0,0 +1,3 @@
1
+ # Calibrator
2
+
3
+ ::: src.quantfin.calibration.calibrator.Calibrator
@@ -0,0 +1,3 @@
1
+ # Fit Jump Parameters
2
+
3
+ ::: src.quantfin.calibration.fit_jump_parameters.fit_jump_params_from_history
@@ -0,0 +1,11 @@
1
+ # Fit Market Parameters
2
+
3
+ This module provides utilities to fit market-implied parameters from option prices.
4
+
5
+ ### Fit Rate and Dividend
6
+
7
+ ::: src.quantfin.calibration.fit_market_params.fit_rate_and_dividend
8
+
9
+ ### Find ATM Options
10
+
11
+ ::: src.quantfin.calibration.fit_market_params.find_atm_options
@@ -0,0 +1,9 @@
1
+ # Calibration Package
2
+
3
+ The `calibration` package provides a comprehensive suite of tools for fitting financial models to market data, estimating parameters from historical data, and calculating implied volatility surfaces.
4
+
5
+ - **Calibrator**: The main class for orchestrating the optimization process to fit model parameters to market option prices.
6
+ - **VolatilitySurface**: A class to compute and manage implied volatility surfaces from both market and model-generated prices.
7
+ - **Parameter Fitters**: Utility functions to estimate specific parameters, such as `fit_rate_and_dividend` from put-call parity or `fit_jump_params_from_history` from historical returns.
8
+ - **Technique Selector**: A helper function to automatically select the most efficient pricing technique for a given model.
9
+ - **IV Solvers**: High-performance, vectorized solvers for calculating implied volatility.
@@ -0,0 +1,3 @@
1
+ # Volatility Surface
2
+
3
+ ::: src.quantfin.calibration.iv_surface.VolatilitySurface
@@ -0,0 +1,3 @@
1
+ # Technique Selector
2
+
3
+ ::: src.quantfin.calibration.technique_selector.select_fastest_technique
@@ -0,0 +1,3 @@
1
+ # Vectorized BSM IV Solver
2
+
3
+ ::: src.quantfin.calibration.vectorized_bsm_iv.BSMIVSolver
@@ -0,0 +1,3 @@
1
+ # Vectorized Integration IV Solver
2
+
3
+ ::: src.quantfin.calibration.vectorized_integration_iv.VectorizedIntegrationIVSolver
@@ -0,0 +1,7 @@
1
+ # Command-Line Interface (CLI)
2
+
3
+ The `quantfin` library provides a powerful command-line interface for running common tasks like data downloading, model calibration, and backtesting.
4
+
5
+ The main entry point is the `quantfin` command. You can see all available commands by running:
6
+ ```bash
7
+ quantfin --help
@@ -0,0 +1,7 @@
1
+ # Dashboard Package
2
+
3
+ The `dashboard` package provides all the necessary components to build and run the Streamlit user interface. It is organized into three main parts:
4
+
5
+ - **Service**: The core logic and state management for the application.
6
+ - **Plots**: Functions dedicated to creating visualizations.
7
+ - **Widgets**: Reusable UI components for displaying specific analyses.