roughprix 0.1.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 (36) hide show
  1. roughprix-0.1.0/LICENSE +202 -0
  2. roughprix-0.1.0/MANIFEST.in +2 -0
  3. roughprix-0.1.0/NOTICE +2 -0
  4. roughprix-0.1.0/PKG-INFO +401 -0
  5. roughprix-0.1.0/README.md +374 -0
  6. roughprix-0.1.0/pyproject.toml +42 -0
  7. roughprix-0.1.0/setup.cfg +4 -0
  8. roughprix-0.1.0/src/roughprix/__init__.py +10 -0
  9. roughprix-0.1.0/src/roughprix/fourier.py +539 -0
  10. roughprix-0.1.0/src/roughprix/heston/__init__.py +42 -0
  11. roughprix-0.1.0/src/roughprix/heston/base_solution.py +157 -0
  12. roughprix-0.1.0/src/roughprix/heston/integration.py +1094 -0
  13. roughprix-0.1.0/src/roughprix/heston/pade.py +610 -0
  14. roughprix-0.1.0/src/roughprix/heston/rough_heston.py +1771 -0
  15. roughprix-0.1.0/src/roughprix.egg-info/PKG-INFO +401 -0
  16. roughprix-0.1.0/src/roughprix.egg-info/SOURCES.txt +34 -0
  17. roughprix-0.1.0/src/roughprix.egg-info/dependency_links.txt +1 -0
  18. roughprix-0.1.0/src/roughprix.egg-info/requires.txt +5 -0
  19. roughprix-0.1.0/src/roughprix.egg-info/top_level.txt +1 -0
  20. roughprix-0.1.0/tests/conftest.py +18 -0
  21. roughprix-0.1.0/tests/data/reference_smiles.json +74 -0
  22. roughprix-0.1.0/tests/reference_pricer.py +215 -0
  23. roughprix-0.1.0/tests/test_accuracy_check.py +161 -0
  24. roughprix-0.1.0/tests/test_contour_defaults.py +173 -0
  25. roughprix-0.1.0/tests/test_exact_heston.py +128 -0
  26. roughprix-0.1.0/tests/test_fourier_truncation.py +92 -0
  27. roughprix-0.1.0/tests/test_heston_expansion.py +1847 -0
  28. roughprix-0.1.0/tests/test_input_checks.py +93 -0
  29. roughprix-0.1.0/tests/test_integration.py +521 -0
  30. roughprix-0.1.0/tests/test_iv_inversion.py +139 -0
  31. roughprix-0.1.0/tests/test_log_cf_integrand.py +90 -0
  32. roughprix-0.1.0/tests/test_param_convention.py +69 -0
  33. roughprix-0.1.0/tests/test_reference_smiles.py +67 -0
  34. roughprix-0.1.0/tests/test_rough_heston_pade.py +876 -0
  35. roughprix-0.1.0/tests/test_series_pade_diagnostic.py +180 -0
  36. roughprix-0.1.0/tests/test_solver_cost.py +198 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ graft tests
2
+ global-exclude *.py[cod]
roughprix-0.1.0/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ roughprix
2
+ Copyright 2026 Paul P. Hager
@@ -0,0 +1,401 @@
1
+ Metadata-Version: 2.4
2
+ Name: roughprix
3
+ Version: 0.1.0
4
+ Summary: European option pricing for the rough Heston model with H-expansion
5
+ Author-email: "Paul P. Hager" <hagerpa@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/hagerpa/roughprix
8
+ Project-URL: Repository, https://github.com/hagerpa/roughprix
9
+ Project-URL: Changelog, https://github.com/hagerpa/roughprix/blob/main/CHANGELOG.md
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
16
+ Classifier: Intended Audience :: Science/Research
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Requires-Dist: numpy
22
+ Requires-Dist: scipy
23
+ Requires-Dist: jax
24
+ Requires-Dist: jaxlib
25
+ Requires-Dist: numba
26
+ Dynamic: license-file
27
+
28
+ # roughprix: option pricing in the rough Heston model
29
+
30
+ European option pricing for rough stochastic volatility models via Fourier inversion. The current implementation focuses on the **rough Heston model**; further models will follow.
31
+
32
+ Pricing rests on the log-price characteristic function, which is expressed through a Riccati-type Volterra equation. `roughprix` provides several methods for solving that equation, ranging from direct numerical Volterra solvers to analytic approximations, and adds a **Taylor expansion in the Hurst exponent** $H$ (Hager & Kreher 2026, [arXiv:2606.16619](https://arxiv.org/abs/2606.16619)) that makes evaluating the characteristic function across a range of roughness values nearly free once the anchor solve is done. The numerical solvers are implemented in **JAX** for JIT-compiled execution.
33
+
34
+ ### Methods implemented
35
+
36
+ | Method | `base_solution` | Description |
37
+ |--------|-----------------|-------------|
38
+ | Adams–PECE | `"direct_riccati"` | Fractional Adams predictor–corrector (El Euch & Rosenbaum 2019); high accuracy, $\mathcal{O}(J^2)$ in time steps |
39
+ | Implicit-$\pi$ | `"direct_riccati"` | Product-integration implicit solver; the default away from $H = \tfrac{1}{2}$, more stable than Adams for small $H$ or non-uniform grids |
40
+ | Padé $[m/m]$ | `"pade"` | Gatheral closed-form Padé approximant to the Riccati solution; fast, no ODE solve, but much less accurate than root-Padé; kept for comparison |
41
+ | Root-Padé $[m/(m+1)]$ | `"root_pade"` | Root-transformed Padé that matches the short-time series and the leading long-time tail (Hager & Kreher 2026, App. D.3); fast, and much more accurate than the plain Padé near $H = 0$ |
42
+ | $H$-expansion | any base | Taylor series $\sum_{n=0}^{N} \frac{(\Delta H)^n}{n!} f_n$ around an anchor $H_0$; coefficients $f_n$ obtained by recursive differentiation of the Riccati equation |
43
+
44
+ With `base_solution="direct_riccati"`, the default `direct_riccati_solver="auto"` uses implicit-$\pi$. Adams is opt-in via `direct_riccati_solver="adams"` and requires a uniform time grid (`time_grid="uniform"`; the default is `"graded"`); it can return NaN for $H \le 0$ or on coarse grids.
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install roughprix
50
+ ```
51
+
52
+ or, from a clone of the repository, `pip install -e .`.
53
+
54
+ Requires Python ≥ 3.10, NumPy, SciPy, JAX, and Numba.
55
+
56
+ ## Model
57
+
58
+ The spot $S$ and instantaneous variance $V$ satisfy
59
+
60
+ $$
61
+ \frac{dS_t}{S_t} = \sqrt{V_t}\, dW_t,
62
+ $$
63
+
64
+ $$
65
+ V_t = V_0 + \frac{1}{\Gamma(H+\tfrac{1}{2})} \int_0^t (t-s)^{H-\tfrac{1}{2}}
66
+ \Bigl[(\theta - \lambda V_s)\, ds + \nu\sqrt{V_s}\, dB_s\Bigr],
67
+ $$
68
+
69
+ $$
70
+ d\langle W, B\rangle_t = \rho\, dt,
71
+ $$
72
+
73
+ where $H \in (-\tfrac{1}{2}, \tfrac{1}{2}]$ is the Hurst exponent. $H = \tfrac{1}{2}$ recovers classical Heston.
74
+
75
+ The coefficients are raw: $\theta$ is the drift constant, and the long-run variance is $\theta/\lambda$. For the usual form $\kappa(\bar v - V_s)$, set $\lambda = \kappa$ and $\theta = \kappa \bar v$.
76
+
77
+ ## Quick start
78
+
79
+ ```python
80
+ import numpy as np
81
+ from roughprix import RoughHeston, RoughHestonParam
82
+
83
+ param = RoughHestonParam(
84
+ lam=0.3, # mean-reversion speed λ
85
+ theta=0.3*0.02, # drift constant θ; long-run variance θ/λ = 0.02
86
+ nu=0.3, # vol-of-vol ν
87
+ rho=-0.7, # spot–vol correlation ρ
88
+ V0=0.02, # initial variance V₀
89
+ H=0.1, # Hurst exponent H
90
+ )
91
+
92
+ model = RoughHeston(param, riskfree=0.0)
93
+
94
+ K = np.array([0.8, 0.9, 1.0, 1.1, 1.2])
95
+ T = 1.0
96
+ ```
97
+
98
+ ## Pricing
99
+
100
+ The characteristic function is evaluated numerically at `param.H` and inverted via Fourier quadrature. The `base_solution` constructor argument selects the Riccati solver:
101
+
102
+ | `base_solution` | When to use |
103
+ |--------------------|-------------|
104
+ | `"auto"` (default) | `"exact_heston"` if $H = \tfrac{1}{2}$, else `"direct_riccati"` with implicit-$\pi$ |
105
+ | `"root_pade"` | $H$ away from $\tfrac{1}{2}$; fast closed-form approximation, less accurate at long maturities and on steep skews |
106
+ | `"exact_heston"` | $H = \tfrac{1}{2}$ exactly (classical Heston closed form); the other bases warn there |
107
+ | `"pade"` | Gatheral $[m/m]$ Padé, for comparison: much less accurate than `"root_pade"` (the accuracy check warns), and order `"44"` can fail near $H = 0$ |
108
+ | `"direct_riccati"` | Full numerical Volterra solve; most stable and accurate, slower than the Padé bases |
109
+
110
+ ```python
111
+ ivs = model.eur_call_put(
112
+ K=K,
113
+ maturity=T,
114
+ implied_vol=True,
115
+ payoff_selection="otm", # calls for K >= F, puts for K < F
116
+ integration="panel",
117
+ L=200.0, # Fourier truncation
118
+ time_steps=500, # time-grid nodes for Volterra solve
119
+ )
120
+ print(ivs)
121
+ ```
122
+
123
+ ```python
124
+ # Direct numerical Riccati solve
125
+ benchmark_model = RoughHeston(
126
+ param, riskfree=0.0, base_solution="direct_riccati"
127
+ )
128
+ ivs_benchmark = benchmark_model.eur_call_put(
129
+ K=K, maturity=T, implied_vol=True, L=200.0
130
+ )
131
+ ```
132
+
133
+ ### Adaptive Fourier truncation
134
+
135
+ Use `integration="adaptive_panel"` to let the pricer automatically select $L$:
136
+
137
+ ```python
138
+ ivs = model.eur_call_put(
139
+ K=K,
140
+ maturity=T,
141
+ implied_vol=True,
142
+ expansion_order=0,
143
+ integration="adaptive_panel",
144
+ adaptive_tol=1e-4, # stop when max IV change < 1e-4
145
+ adaptive_verbose=True,
146
+ )
147
+ ```
148
+
149
+ ## Pricing with the H-expansion
150
+
151
+ The H-expansion approximates the log characteristic function as a Taylor series in $\Delta H = H - H_0$ around an anchor $H_0$:
152
+
153
+ $$
154
+ \log \varphi(u, T;\, H) \;\approx\; \sum_{n=0}^{N} \frac{(\Delta H)^n}{n!}\, f_n(u, T),
155
+ $$
156
+
157
+ where the coefficients $f_n$ are obtained by differentiating the Riccati–Volterra equation recursively. At order $N = 0$ the result equals the quasi-exact benchmark. Higher orders extend the valid range of $|\Delta H|$.
158
+
159
+ ### Anchor at $H_0 = 0$ (`"root_pade"` base)
160
+
161
+ Useful when pricing across a range of small $H$ values.
162
+
163
+ ```python
164
+ # Anchor at H₀ = 0, target H = 0.1
165
+ param_anchor0 = RoughHestonParam(
166
+ lam=0.3, theta=0.3*0.02, nu=0.3, rho=-0.7, V0=0.02,
167
+ H=0.0, # anchor H₀ = 0
168
+ )
169
+ model_expansion = RoughHeston(
170
+ param_anchor0, riskfree=0.0, base_solution="root_pade"
171
+ )
172
+
173
+ ivs_N4 = model_expansion.eur_call_put(
174
+ K=K,
175
+ maturity=T,
176
+ implied_vol=True,
177
+ expansion_order=4, # 4th-order Taylor in H
178
+ H=0.1, # evaluate at this target H
179
+ L=200.0,
180
+ )
181
+ ```
182
+
183
+ ### Anchor at $H_0 = \tfrac{1}{2}$ (`"exact_heston"` base)
184
+
185
+ Useful near the classical Heston regime.
186
+
187
+ ```python
188
+ param_half = RoughHestonParam(
189
+ lam=0.3, theta=0.3*0.02, nu=0.3, rho=-0.7, V0=0.02,
190
+ H=0.5, # anchor: classical Heston
191
+ )
192
+ model_half = RoughHeston(
193
+ param_half, riskfree=0.0, base_solution="exact_heston"
194
+ )
195
+
196
+ ivs_N2 = model_half.eur_call_put(
197
+ K=K,
198
+ maturity=T,
199
+ implied_vol=True,
200
+ expansion_order=2, # 2nd-order Taylor in H around ½
201
+ H=0.4, # evaluate at H = 0.4
202
+ L=200.0,
203
+ )
204
+ ```
205
+
206
+ ### Pricing across multiple $H$ values
207
+
208
+ Pass an array to `H` to price all values simultaneously. The expensive Volterra fields are computed once and shared:
209
+
210
+ ```python
211
+ H_values = np.array([0.05, 0.1, 0.15, 0.2])
212
+
213
+ # Returns shape (N_K, N_H)
214
+ ivs_grid = model_expansion.eur_call_put(
215
+ K=K,
216
+ maturity=T,
217
+ implied_vol=True,
218
+ expansion_order=4,
219
+ H=H_values,
220
+ L=200.0,
221
+ )
222
+ print(ivs_grid.shape) # (5, 4)
223
+ ```
224
+
225
+ ### Choosing expansion order
226
+
227
+ | Order $N$ | Truncation error | Cost |
228
+ |-----------|-------|------|
229
+ | 0 | $\mathcal{O}(\Delta H)$; the base solution itself at $H = H_0$ | baseline |
230
+ | 1 | $\mathcal{O}(\Delta H^2)$ | $+1$ Volterra solve |
231
+ | 2 | $\mathcal{O}(\Delta H^3)$ | $+2$ solves |
232
+ | 4 | $\mathcal{O}(\Delta H^5)$ | $+4$ solves |
233
+
234
+ ### Accuracy
235
+
236
+ The error depends on $|\Delta H|$, the maturity, how far out of the money the strikes are, and the model parameters. We compared order 4 from an anchor at $H_0 = 0$ (`"root_pade"` base, library defaults) with a converged direct solve at the target $H$, on 18 parameter sets. Largest implied-vol error over strikes within two standard deviations of the forward, $\lvert\log(K/F)\rvert \le 2\sqrt{V_0 T}$, for the 15 sets with $\rho \ge -0.7$:
237
+
238
+ | $\lvert\Delta H\rvert$ | 1 day | 1 week | 1 month | 3 months | 1 year | 5 years |
239
+ |---|---|---|---|---|---|---|
240
+ | 0.05 | 0.6 bp | 0.3 bp | 0.2 bp | 0.2 bp | 0.1 bp | 0.06 bp |
241
+ | 0.1 | 30 bp | 3 bp | 0.3 bp | 0.2 bp | 0.1 bp | 0.06 bp |
242
+ | 0.2 | fails | 170 bp | 15 bp | 4.5 bp | 0.2 bp | 0.1 bp |
243
+
244
+ ("fails": some prices come out invalid.)
245
+
246
+ - **Strikes further out are harder at short maturities.** At one week and $\lvert\Delta H\rvert = 0.1$, the largest error is 0.7 bp within one standard deviation, 3 bp within two and 48 bp within three. At one and two years it stays below 0.4 bp out to three standard deviations.
247
+ - **Steep skews** ($\rho \le -0.9$) raise the largest error to about 2–10 bp from one month to one year. Most of that is the root-Padé base: with `base_solution="direct_riccati"` it stays below 1 bp for $\lvert\Delta H\rvert \le 0.1$.
248
+ - **Targets above the anchor are harder than targets below it** at short maturities: at one day, $H = 0.1$ gives 30 bp and $H = -0.1$ gives 8 bp.
249
+ - **At a week or less with $\lvert\Delta H\rvert \gtrsim 0.1$**, price at the target directly (anchor at the target, order 0).
250
+
251
+ `eur_call_put` checks its own accuracy and warns (`UserWarning`) when the estimated implied-vol error exceeds `accuracy_tol` (default 1 bp) at a strike whose out-of-the-money price is at least $10^{-6} S_0$. The returned values do not change.
252
+
253
+ - **H-expansion** ($N \ge 1$): it also computes order $N+1$ and takes the change of the implied vols at the lowest and the highest target $H$. On the same sets and maturities (orders 1–3, from $H_0 = 0$ with the implicit-$\pi$ base and from $H_0 = \tfrac12$ with exact Heston; 4158 smile–order cases) the estimate was within 0.76–1.18 times the true error for 80 % of the cases above 1 bp. It missed 21 of the 2247 cases above 1 bp, by at most 1.7 bp, and warned on 10 of the 1911 below.
254
+ - **Padé bases** away from $H_0 = \tfrac12$: it compares the two `log_cf_integrand` formulas at the anchor. Both are exact for the exact Riccati solution, and `"rhs"` amplifies the error of an approximate one, so they differ by about the error of `"rhs"`. With `"root_pade"` the default `"solution"` is 3–10 times more accurate than that difference, so there the check uses a third of it. On 756 root-Padé smiles it warned on 25 of the 26 above 1 bp (it missed one at 1.4 bp) and on 11 of the 730 below.
255
+
256
+ The check adds about 10–35 % run time. `accuracy_check=False` turns it off.
257
+
258
+ ## API reference
259
+
260
+ ### `RoughHestonParam`
261
+
262
+ | Field | Type | Description |
263
+ |-------|------|-------------|
264
+ | `lam` | `float` | Mean-reversion speed $\lambda$ |
265
+ | `theta` | `float` | Drift constant $\theta$; the long-run variance is $\theta/\lambda$ |
266
+ | `nu` | `float` | Vol-of-vol $\nu$ |
267
+ | `rho` | `float` | Spot–vol correlation $\rho \in (-1, 1)$ |
268
+ | `V0` | `float` | Initial variance $V_0$ |
269
+ | `H` | `float` | Hurst exponent $H \in (-\tfrac{1}{2}, \tfrac{1}{2}]$; $H = \tfrac{1}{2}$ is classical Heston |
270
+
271
+ ### `RoughHeston(param, riskfree, base_solution="auto", ...)`
272
+
273
+ | Argument | Description |
274
+ |----------|-------------|
275
+ | `param` | `RoughHestonParam` instance |
276
+ | `riskfree` | Continuously compounded risk-free rate $r$ |
277
+ | `base_solution` | Riccati solver: `"auto"`, `"root_pade"`, `"exact_heston"`, `"pade"`, `"direct_riccati"` |
278
+ | `pade_order` | `"22"`, `"33"`, or `"44"` (only for `"pade"`) |
279
+ | `root_pade_degree` | Padé numerator degree $m$ (default 9; Hager & Kreher 2026 use 7) |
280
+ | `root_pade_tail_match` | Replace the highest short-time Padé equation with the exact large-$x$ tail constraint (default `True`) |
281
+ | `log_cf_integrand` | What the log characteristic function integrates: `"solution"` integrates the Riccati solution $h$, $\theta\, I^1 h(T) + V_0\, I^{1-\alpha} h(T)$ (El Euch & Rosenbaum 2019); `"rhs"` integrates the right-hand side, $\int_0^T F(h(s))\,(V_0 + \theta (T-s)^\alpha/\Gamma(1+\alpha))\, ds$, as in Hager & Kreher (2026), Eq. (1.1). Both are exact for the exact $h$. `"solution"` does not amplify the error of an approximate $h$; `"rhs"` restores the target's short-time behaviour, which helps expansions from $H_0 = \tfrac12$. `"auto"` (default) uses `"rhs"` for expansions from $H_0 = \tfrac12$ and `"solution"` otherwise. For the paper's settings see [Reproducing the paper](#reproducing-the-paper) |
282
+
283
+ ### `model.eur_call_put(K, maturity, ...)`
284
+
285
+ | Argument | Default | Description |
286
+ |----------|---------|-------------|
287
+ | `K` | — | Strike(s), scalar or array |
288
+ | `maturity` | — | Option maturity $T > 0$ |
289
+ | `S_0` | `1.0` | Initial spot $S_0$ |
290
+ | `call` | `True` | `True` returns calls, `False` puts |
291
+ | `digital` | `False` | Cash-or-nothing digitals instead of vanillas |
292
+ | `implied_vol` | `False` | Return Black–Scholes implied vols $\sigma_\text{BS}$ (vanillas only) |
293
+ | `payoff_selection` | `"otm"` | `"otm"` prices the out-of-the-money option at each strike (calls for $K \ge F$, puts otherwise) and converts to `call` by put–call parity; `"as_requested"` prices the requested option directly |
294
+ | `expansion_order` | `0` | Taylor order $N$ in $H$ |
295
+ | `H` | `None` | Target $H$ (scalar or array; `None` uses `param.H`) |
296
+ | `L` | `None` | Fourier truncation $L$. `None` picks where $\lvert\varphi\rvert$ has decayed to about $10^{-10}$, from the model parameters and maturity |
297
+ | `integration` | `"panel"` | `"panel"` (fixed $L$) or `"adaptive_panel"` (auto-select $L$; warns when no two successive $L$ agree) |
298
+ | `time_steps` | `400` | Time-grid nodes for the expansion Volterra solve |
299
+ | `time_grid` | `"graded"` | `"graded"` clusters nodes near $t = 0$, where the solution is rough; `"uniform"` or `"symmetric_graded"`. Adams needs `"uniform"` |
300
+ | `R` | `0.5` | Fourier contour height. $R = 0.5$ prices every strike as a call and gets puts by parity (the Lewis contour for vanillas); it needs only $E[S_T^{1/2}]$, which is always finite. Other values use damped contours at $\pm |R|$, which need $E[S_T^{\pm |R|}] < \infty$. Below $|R| = 1$ vanilla calls get the residue $S_0$ of the payoff's pole at 1 added, as in the Lewis formula (half of it at 1); $R = 0$ runs through the pole at 0 and adds half of its residue. Near a pole the integrand has a peak of width $\lvert R - \text{pole}\rvert$ at $u = 0$: $10^{-2}$ from a pole prices are off by $4 \cdot 10^{-9}$, $10^{-3}$ from it by up to $2 \cdot 10^{-3} S_0$ |
301
+ | `m_cheb` | `16` | Chebyshev nodes per Fourier panel |
302
+ | `adaptive_tol` | `1e-4` | Max implied-vol change threshold for adaptive convergence (digitals compare prices instead) |
303
+ | `accuracy_check` | `True` | Estimate the error of the H-expansion and of the Padé bases and warn when it exceeds `accuracy_tol`; see [Accuracy](#accuracy) |
304
+ | `accuracy_tol` | `1e-4` | Warning threshold of the check, in implied vol (1 bp) |
305
+
306
+ ## Roadmap
307
+
308
+ The following extensions are planned:
309
+
310
+ - **Further European payoffs** — spreads, variance swaps.
311
+ - **Path-dependent options** — barriers, Asians, and lookbacks.
312
+ - **Rough Bergomi model.**
313
+ - **American options.**
314
+
315
+ ## Reproducing the paper
316
+
317
+ The numerical results in Section 4 of Hager & Kreher (2026, [arXiv:2606.16619v1](https://arxiv.org/abs/2606.16619v1)) were computed with the code as of June 2026. Version 0.1.0 corrects several errors of that code and changes its defaults (see the [changelog](https://github.com/hagerpa/roughprix/blob/main/CHANGELOG.md)). One of these corrections changes published numbers. Around $H_0 = \tfrac12$ the linearised equations of the expansion have an exponential kernel, which 0.1.0 integrates exactly; the earlier code used the trapezoidal rule. This moves the smiles of Figure 2 with $N \ge 1$ by up to $1.4 \cdot 10^{-5}$ in implied volatility, and it changes Table 1 at $(H, T, N) = (0.2, 0.019, 4)$ from 0.3965 to 0.3966.
318
+
319
+ To reproduce the published numbers exactly, install commit [`320dfd9`](https://github.com/hagerpa/roughprix/tree/320dfd9792f8f2b32a1e85ef66309440e37a7f35) in a separate environment. It is version 0.0.1 with its import error fixed.
320
+
321
+ ```bash
322
+ pip install "git+https://github.com/hagerpa/roughprix@320dfd9792f8f2b32a1e85ef66309440e37a7f35"
323
+ ```
324
+
325
+ With the paper's parameters and strikes, these calls reproduce Figures 2 and 3:
326
+
327
+ ```python
328
+ import numpy as np
329
+ from dataclasses import replace
330
+ from roughprix import RoughHeston, RoughHestonParam
331
+
332
+ param = RoughHestonParam(lam=0.3, theta=0.3*0.02, nu=0.3, rho=-0.7, V0=0.02, H=0.5)
333
+ T = 0.083 # 0.019, 0.083, 0.25 or 1
334
+ K = np.exp(np.sqrt(T) * np.linspace(-1.0, 0.5, 76)) # S_0 = 1, r = 0
335
+ pricing = dict(implied_vol=True, integration="adaptive_panel",
336
+ adaptive_L_candidates=[110, 150, 200, 270, 350, 500, 700, 1000])
337
+
338
+ # Benchmark at each target H: implicit product integration with 2000 steps
339
+ bench = RoughHeston(replace(param, H=0.2), 0.0, base_solution="direct_riccati",
340
+ direct_riccati_solver="implicit_pi")
341
+ iv_bench = bench.eur_call_put(K, T, R=0.5, time_steps=2000, time_grid="uniform",
342
+ adaptive_tol=1.5e-4, **pricing)
343
+
344
+ # Expansion around H0 = 1/2 (Figure 2)
345
+ half = RoughHeston(replace(param, H=0.5), 0.0, base_solution="exact_heston")
346
+ iv_half = half.eur_call_put(K, T, H=[0.2, 0.3, 0.4], expansion_order=4, R=0.5,
347
+ time_steps=500, time_grid="symmetric_graded", **pricing)
348
+
349
+ # Expansion around H0 = 0 (Figure 3): root-Padé of degree 7 with tail matching
350
+ zero = RoughHeston(replace(param, H=0.0), 0.0, base_solution="root_pade",
351
+ root_pade_degree=7, root_pade_tail_match=True)
352
+ iv_zero = zero.eur_call_put(K, T, H=[-0.3, -0.2, -0.1, 0.0, 0.1, 0.2], expansion_order=4,
353
+ R=0.5, time_steps=500, time_grid="symmetric_graded", **pricing)
354
+ ```
355
+
356
+ - Tables 1 and 2 price the expansions with `R=1.2` instead of `R=0.5`, and Table 2 also uses `root_pade_tail_match=False`. The benchmark is the same.
357
+ - Price all target $H$ of a figure in one call, as above. The adaptive loop then raises the cutoff until the implied vols at all of them have converged.
358
+ - Figure 1 uses the root-Padé base of degree 7 without tail matching at both expansion points, $H_0 = 0$ and $H_0 = \tfrac12$:
359
+
360
+ ```python
361
+ u = np.linspace(1, 300, 300)
362
+ z = 0.5 - 1j * u # R - iu with R = 1/2
363
+ fbar = {}
364
+ for H0 in (0.0, 0.5):
365
+ model = RoughHeston(replace(param, H=H0), 0.0, base_solution="root_pade",
366
+ root_pade_degree=7, root_pade_tail_match=False)
367
+ state = model.expansion_state(-1j * z, maturity=1.0, order=12, # order=20 for R*
368
+ time_steps=500, time_grid="graded", return_lists=True)
369
+ # max over the time grid of |d^n/dH^n psi(t; H0, z)|, n = 0, ..., 12
370
+ fbar[H0] = [np.abs(np.asarray(f.values)).max(axis=-1) for f in state.f_list]
371
+ ```
372
+
373
+ With commit `320dfd9` these calls reproduce all 64 table entries in all printed digits. They reproduce the smiles of Figures 2 and 3 to $10^{-8}$ in implied volatility, the precision of the published figures, and the data of Figure 1 to $10^{-14}$.
374
+
375
+ With version 0.1.0, add `log_cf_integrand="rhs"` to each `RoughHeston(...)`. Otherwise 0.1.0 uses another formula for the log characteristic function at anchors $H_0 \neq \tfrac12$, which includes the benchmark. The results then agree with the published numbers to the same precision, apart from the correction above. In 0.1.0 many of these calls warn, either from the accuracy check or because the cutoff reaches 1000 without meeting `adaptive_tol` (mostly at $T \le 0.083$). The warnings do not change the values.
376
+
377
+ ## Citation
378
+
379
+ If you use `roughprix` in your research, please cite the paper
380
+
381
+ ```bibtex
382
+ @misc{HagerKreher2026,
383
+ author = {Hager, Paul P. and Kreher, D{\"o}rte},
384
+ title = {Expanding the rough {H}eston model in {$H$}},
385
+ year = {2026},
386
+ eprint = {2606.16619},
387
+ archivePrefix = {arXiv},
388
+ }
389
+ ```
390
+
391
+ To cite the software itself, use [`CITATION.cff`](https://github.com/hagerpa/roughprix/blob/main/CITATION.cff) ("Cite this repository" on GitHub); every release is archived on Zenodo with its own DOI.
392
+
393
+ ## References
394
+
395
+ - El Euch, O. & Rosenbaum, M. (2019). *The characteristic function of rough Heston models.* Mathematical Finance, 29(1), 3–38. [doi:10.1111/mafi.12173](https://doi.org/10.1111/mafi.12173)
396
+ - Gatheral, J., Jaisson, T. & Rosenbaum, M. (2018). *Volatility is rough.* Quantitative Finance, 18(6), 933–949. [doi:10.1080/14697688.2017.1393551](https://doi.org/10.1080/14697688.2017.1393551)
397
+ - Diethelm, K., Ford, N. J. & Freed, A. D. (2002). *A predictor-corrector approach for the numerical solution of fractional differential equations.* Nonlinear Dynamics, 29, 3–22. [doi:10.1023/A:1016592219341](https://doi.org/10.1023/A:1016592219341) — Adams–PECE solver.
398
+ - Garrappa, R. (2018). *Numerical solution of fractional differential equations: A survey and a software tutorial.* Mathematics, 6(2), 16. [doi:10.3390/math6020016](https://doi.org/10.3390/math6020016) — implicit trapezoidal product-integration rule.
399
+ - Gatheral, J. & Radoičić, R. (2019). *Rational approximation of the rough Heston solution.* International Journal of Theoretical and Applied Finance, 22(3), 1950010. [doi:10.1142/S0219024919500109](https://doi.org/10.1142/S0219024919500109)
400
+ - Gatheral, J. & Radoičić, R. (2024). *A generalization of the rational rough Heston approximation.* Quantitative Finance, 24(2), 329–335. [doi:10.1080/14697688.2024.2302055](https://doi.org/10.1080/14697688.2024.2302055)
401
+ - Hager, P. P. & Kreher, D. (2026). *Expanding the rough Heston model in $H$.* Preprint. [arXiv:2606.16619](https://arxiv.org/abs/2606.16619)