stochvolmodels 1.0.11__tar.gz → 1.0.14__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 (32) hide show
  1. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/PKG-INFO +32 -17
  2. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/README.md +31 -17
  3. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/pyproject.toml +1 -1
  4. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/__init__.py +64 -47
  5. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/data/option_chain.py +7 -7
  6. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/data/test_option_chain.py +2 -2
  7. stochvolmodels-1.0.14/stochvolmodels/pricers/analytic/bsm.py +581 -0
  8. stochvolmodels-1.0.14/stochvolmodels/pricers/analytic/tdist.py +126 -0
  9. stochvolmodels-1.0.14/stochvolmodels/pricers/gmm_pricer.py +299 -0
  10. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/hawkes_jd_pricer.py +4 -4
  11. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/heston_pricer.py +65 -25
  12. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/logsv/affine_expansion.py +1 -1
  13. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/logsv_pricer.py +29 -9
  14. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/model_pricer.py +29 -17
  15. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/tests/bsm_mgf_pricer.py +3 -3
  16. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/tests/qv_pricer.py +3 -3
  17. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/utils/funcs.py +6 -0
  18. {stochvolmodels-1.0.11/stochvolmodels/pricers/core → stochvolmodels-1.0.14/stochvolmodels/utils}/mc_payoffs.py +1 -1
  19. {stochvolmodels-1.0.11/stochvolmodels/pricers/core → stochvolmodels-1.0.14/stochvolmodels/utils}/mgf_pricer.py +1 -1
  20. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/utils/plots.py +7 -4
  21. stochvolmodels-1.0.11/stochvolmodels/pricers/core/bsm_pricer.py +0 -284
  22. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/LICENSE.txt +0 -0
  23. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/data/__init__.py +0 -0
  24. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/data/fetch_option_chain.py +0 -0
  25. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/__init__.py +0 -0
  26. {stochvolmodels-1.0.11/stochvolmodels/pricers/core → stochvolmodels-1.0.14/stochvolmodels/pricers/analytic}/__init__.py +0 -0
  27. /stochvolmodels-1.0.11/stochvolmodels/pricers/core/normal_pricer.py → /stochvolmodels-1.0.14/stochvolmodels/pricers/analytic/bachelier.py +0 -0
  28. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/logsv/__init__.py +0 -0
  29. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/pricers/logsv/vol_moments_ode.py +0 -0
  30. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/tests/__init__.py +0 -0
  31. {stochvolmodels-1.0.11 → stochvolmodels-1.0.14}/stochvolmodels/utils/__init__.py +0 -0
  32. {stochvolmodels-1.0.11/stochvolmodels/pricers/core → stochvolmodels-1.0.14/stochvolmodels/utils}/config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stochvolmodels
3
- Version: 1.0.11
3
+ Version: 1.0.14
4
4
  Summary: Implementation of stochastic volatility models for option pricing
5
5
  Home-page: https://github.com/ArturSepp/StochVolModels
6
6
  License: LICENSE.txt
@@ -50,22 +50,6 @@ For the analytic implementation of stochastic volatility models, the package pro
50
50
  1) Interface for analytical pricing of vanilla options using Fourier transform with closed-form solution for moment generating function
51
51
  2) Interface for Monte-Carlo simulations of model dynamics
52
52
 
53
- ## Illustrations
54
-
55
- As illustrations of different analytics, this packadge includes the computations and visualisations
56
- for
57
-
58
- 1) Log-normal Stochastic Volatility Model with Quadratic Drift by Sepp A and Rakhmonov P, SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2522425
59
- ```python
60
- stochvolmodels/my_papers/logsv_model_wtih_quadratic_drift
61
- ```
62
-
63
-
64
- 2) What is a robust stochastic volatility model by Sepp A and Rakhmonov P, SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4647027
65
- ```python
66
- stochvolmodels/my_papers/volatility_models
67
- ```
68
-
69
53
 
70
54
  ## Installation
71
55
  ```python
@@ -82,6 +66,8 @@ pip install stochvolmodels
82
66
  3. [Comparison of model prices vs MC](#subparagraph3)
83
67
  4. [Analysis and figures for the paper](#subparagraph4)
84
68
  3. [Running Heston SV pricer](#heston)
69
+ 4. [Supporting Illustrations for Public Papers](#papers)
70
+
85
71
 
86
72
  Running model calibration to sample Bitcoin options data
87
73
 
@@ -246,3 +232,32 @@ pricer.plot_model_slices_in_params(option_slice=option_slice, params_dict=params
246
232
 
247
233
  plt.show()
248
234
  ```
235
+
236
+
237
+ ## Supporting Illustrations for Public Papers <a name="papers"></a>
238
+
239
+ As illustrations of different analytics, this packadge includes module ```my_papers```
240
+ with codes for computations and visualisations featured in several papers
241
+ for
242
+
243
+ 1) "Log-normal Stochastic Volatility Model with Quadratic Drift" by Sepp A and Rakhmonov P, SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2522425
244
+ ```python
245
+ stochvolmodels/my_papers/logsv_model_wtih_quadratic_drift
246
+ ```
247
+
248
+
249
+ 2) "What is a robust stochastic volatility model" by Sepp A and Rakhmonov P,
250
+ SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4647027
251
+ ```python
252
+ stochvolmodels/my_papers/volatility_models
253
+ ```
254
+
255
+
256
+ 3) "Valuation and Hedging of Cryptocurrency Inverse Options" by Sepp A and Lucic V,
257
+ SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4606748
258
+ ```python
259
+ stochvolmodels/my_papers/inverse_options
260
+ ```
261
+
262
+
263
+
@@ -11,22 +11,6 @@ For the analytic implementation of stochastic volatility models, the package pro
11
11
  1) Interface for analytical pricing of vanilla options using Fourier transform with closed-form solution for moment generating function
12
12
  2) Interface for Monte-Carlo simulations of model dynamics
13
13
 
14
- ## Illustrations
15
-
16
- As illustrations of different analytics, this packadge includes the computations and visualisations
17
- for
18
-
19
- 1) Log-normal Stochastic Volatility Model with Quadratic Drift by Sepp A and Rakhmonov P, SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2522425
20
- ```python
21
- stochvolmodels/my_papers/logsv_model_wtih_quadratic_drift
22
- ```
23
-
24
-
25
- 2) What is a robust stochastic volatility model by Sepp A and Rakhmonov P, SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4647027
26
- ```python
27
- stochvolmodels/my_papers/volatility_models
28
- ```
29
-
30
14
 
31
15
  ## Installation
32
16
  ```python
@@ -43,6 +27,8 @@ pip install stochvolmodels
43
27
  3. [Comparison of model prices vs MC](#subparagraph3)
44
28
  4. [Analysis and figures for the paper](#subparagraph4)
45
29
  3. [Running Heston SV pricer](#heston)
30
+ 4. [Supporting Illustrations for Public Papers](#papers)
31
+
46
32
 
47
33
  Running model calibration to sample Bitcoin options data
48
34
 
@@ -206,4 +192,32 @@ pricer = HestonPricer()
206
192
  pricer.plot_model_slices_in_params(option_slice=option_slice, params_dict=params_dict)
207
193
 
208
194
  plt.show()
209
- ```
195
+ ```
196
+
197
+
198
+ ## Supporting Illustrations for Public Papers <a name="papers"></a>
199
+
200
+ As illustrations of different analytics, this packadge includes module ```my_papers```
201
+ with codes for computations and visualisations featured in several papers
202
+ for
203
+
204
+ 1) "Log-normal Stochastic Volatility Model with Quadratic Drift" by Sepp A and Rakhmonov P, SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2522425
205
+ ```python
206
+ stochvolmodels/my_papers/logsv_model_wtih_quadratic_drift
207
+ ```
208
+
209
+
210
+ 2) "What is a robust stochastic volatility model" by Sepp A and Rakhmonov P,
211
+ SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4647027
212
+ ```python
213
+ stochvolmodels/my_papers/volatility_models
214
+ ```
215
+
216
+
217
+ 3) "Valuation and Hedging of Cryptocurrency Inverse Options" by Sepp A and Lucic V,
218
+ SSRN: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4606748
219
+ ```python
220
+ stochvolmodels/my_papers/inverse_options
221
+ ```
222
+
223
+
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "stochvolmodels"
3
- version = "1.0.11"
3
+ version = "1.0.14"
4
4
  description = "Implementation of stochastic volatility models for option pricing"
5
5
  license = "LICENSE.txt"
6
6
  authors = ["Artur Sepp <artursepp@gmail.com>"]
@@ -1,4 +1,20 @@
1
1
 
2
+
3
+ from stochvolmodels.utils.config import VariableType
4
+
5
+ from stochvolmodels.utils.mc_payoffs import compute_mc_vars_payoff
6
+
7
+ from stochvolmodels.utils.mgf_pricer import (get_phi_grid,
8
+ get_psi_grid,
9
+ get_theta_grid,
10
+ get_transform_var_grid,
11
+ compute_integration_weights,
12
+ vanilla_slice_pricer_with_mgf_grid,
13
+ digital_slice_pricer_with_mgf_grid,
14
+ slice_pricer_with_mgf_grid_with_gamma,
15
+ slice_qvar_pricer_with_a_grid,
16
+ pdf_with_mgf_grid)
17
+
2
18
  from stochvolmodels.utils.funcs import (
3
19
  set_seed,
4
20
  compute_histogram_data,
@@ -6,17 +22,20 @@ from stochvolmodels.utils.funcs import (
6
22
  to_flat_np_array,
7
23
  update_kwargs,
8
24
  ncdf,
9
- npdf
25
+ npdf,
26
+ npdf1
10
27
  )
11
28
 
12
- from stochvolmodels.pricers.core.bsm_pricer import (
29
+ from stochvolmodels.pricers.analytic.bsm import (
13
30
  OptionType,
14
- compute_bsm_delta,
15
- compute_bsm_delta_to_strike,
16
- compute_bsm_deltas_ttms,
17
- compute_bsm_price,
18
- compute_bsm_slice_deltas,
19
- compute_bsm_slice_prices,
31
+ compute_bsm_vanilla_price,
32
+ compute_bsm_vanilla_slice_deltas,
33
+ compute_bsm_vanilla_slice_prices,
34
+ compute_bsm_forward_grid_prices,
35
+ compute_bsm_vanilla_delta,
36
+ compute_bsm_vanilla_grid_deltas,
37
+ compute_bsm_strike_from_delta,
38
+ compute_bsm_vanilla_deltas_ttms,
20
39
  compute_bsm_slice_vegas,
21
40
  compute_bsm_vegas_ttms,
22
41
  infer_bsm_implied_vol,
@@ -25,7 +44,7 @@ from stochvolmodels.pricers.core.bsm_pricer import (
25
44
  infer_bsm_ivols_from_slice_prices
26
45
  )
27
46
 
28
- from stochvolmodels.pricers.core.normal_pricer import (
47
+ from stochvolmodels.pricers.analytic.bachelier import (
29
48
  compute_normal_delta,
30
49
  compute_normal_delta_from_lognormal_vol,
31
50
  compute_normal_delta_to_strike,
@@ -41,6 +60,33 @@ from stochvolmodels.pricers.core.normal_pricer import (
41
60
  infer_normal_ivols_from_slice_prices,
42
61
  )
43
62
 
63
+ from stochvolmodels.pricers.analytic.tdist import (
64
+ t_cum,
65
+ compute_tdist_price,
66
+ compute_compute_negative_prob,
67
+ infer_tdist_implied_vol,
68
+ infer_tdist_implied_vols_from_model_slice_prices
69
+ )
70
+
71
+ from stochvolmodels.pricers.logsv.affine_expansion import (
72
+ ExpansionOrder,
73
+ VariableType,
74
+ compute_logsv_a_mgf_grid,
75
+ func_a_ode_quadratic_terms,
76
+ func_rhs,
77
+ func_rhs_jac,
78
+ get_expansion_n,
79
+ get_init_conditions_a,
80
+ solve_a_ode_grid,
81
+ solve_analytic_ode_for_a,
82
+ solve_analytic_ode_for_a0,
83
+ solve_analytic_ode_grid_phi,
84
+ solve_ode_for_a,
85
+ compute_logsv_a_mgf_grid,
86
+ solve_a_ode_grid,
87
+ solve_ode_for_a,
88
+ )
89
+
44
90
  from stochvolmodels.pricers.hawkes_jd_pricer import (
45
91
  HawkesJDParams,
46
92
  HawkesJDPricer
@@ -60,12 +106,20 @@ from stochvolmodels.pricers.logsv_pricer import (
60
106
  ConstraintsType
61
107
  )
62
108
 
109
+ from stochvolmodels.pricers.gmm_pricer import (
110
+ GmmParams,
111
+ GmmPricer
112
+ )
113
+
114
+
63
115
  from stochvolmodels.data.option_chain import OptionChain, OptionSlice
64
116
 
117
+ """
65
118
  from stochvolmodels.data.fetch_option_chain import (generate_vol_chain_np,
66
119
  load_option_chain,
67
120
  sample_option_chain_at_times,
68
121
  load_price_data)
122
+ """
69
123
 
70
124
  from stochvolmodels.data.test_option_chain import (
71
125
  get_btc_test_chain_data,
@@ -98,41 +152,4 @@ from stochvolmodels.utils.plots import (
98
152
  )
99
153
 
100
154
 
101
- from stochvolmodels.pricers.core.mgf_pricer import (
102
- compute_integration_weights,
103
- digital_slice_pricer_with_mgf_grid,
104
- get_phi_grid,
105
- get_psi_grid,
106
- get_theta_grid,
107
- get_transform_var_grid,
108
- pdf_with_mgf_grid,
109
- slice_pricer_with_mgf_grid_with_gamma,
110
- slice_qvar_pricer_with_a_grid,
111
- vanilla_slice_pricer_with_mgf_grid,
112
- slice_pricer_with_mgf_grid_with_gamma,
113
- )
114
-
115
- from stochvolmodels.pricers.logsv.affine_expansion import (
116
- ExpansionOrder,
117
- VariableType,
118
- compute_logsv_a_mgf_grid,
119
- func_a_ode_quadratic_terms,
120
- func_rhs,
121
- func_rhs_jac,
122
- get_expansion_n,
123
- get_init_conditions_a,
124
- solve_a_ode_grid,
125
- solve_analytic_ode_for_a,
126
- solve_analytic_ode_for_a0,
127
- solve_analytic_ode_grid_phi,
128
- solve_ode_for_a,
129
- compute_logsv_a_mgf_grid,
130
- solve_a_ode_grid,
131
- solve_ode_for_a,
132
- )
133
-
134
- from stochvolmodels.pricers.core.config import VariableType
135
-
136
- from stochvolmodels.pricers.core.mc_payoffs import compute_mc_vars_payoff
137
-
138
-
155
+ from stochvolmodels.pricers.logsv.vol_moments_ode import compute_analytic_qvar
@@ -12,7 +12,7 @@ from dataclasses import dataclass
12
12
  from typing import Tuple, Optional
13
13
  from numba.typed import List
14
14
 
15
- import stochvolmodels.pricers.core.bsm_pricer as bsm
15
+ import stochvolmodels.pricers.analytic.bsm as bsm
16
16
 
17
17
 
18
18
  @dataclass
@@ -115,11 +115,11 @@ class OptionChain:
115
115
  return None
116
116
 
117
117
  def get_chain_deltas(self) -> List[np.ndarray]:
118
- deltas_ttms = bsm.compute_bsm_deltas_ttms(ttms=self.ttms,
119
- forwards=self.forwards,
120
- strikes_ttms=self.strikes_ttms,
121
- optiontypes_ttms=self.optiontypes_ttms,
122
- vols_ttms=self.get_mid_vols())
118
+ deltas_ttms = bsm.compute_bsm_vanilla_deltas_ttms(ttms=self.ttms,
119
+ forwards=self.forwards,
120
+ strikes_ttms=self.strikes_ttms,
121
+ optiontypes_ttms=self.optiontypes_ttms,
122
+ vols_ttms=self.get_mid_vols())
123
123
  return deltas_ttms
124
124
 
125
125
  def get_chain_vegas(self, is_unit_ttm_vega: bool = False) -> List[np.ndarray]:
@@ -233,7 +233,7 @@ class OptionChain:
233
233
  return a subset of chain for given ids
234
234
  """
235
235
  if len(ids) == 1:
236
- idx = option_chain.ids.tolist().index(ids[0])
236
+ idx = list(option_chain.ids).index(ids[0]) # get location of ids
237
237
  option_chain = cls(ids=ids,
238
238
  ttms=np.array([option_chain.ttms[idx]]),
239
239
  ticker=option_chain.ticker,
@@ -852,10 +852,10 @@ def get_qv_options_test_chain_data(num_strikes: int = 21) -> OptionChain:
852
852
  forwards = array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
853
853
  discfactors = array([1.0, 1.0, 1.0, 1.0, 1.0, 1.0])
854
854
  strikes_ttm = np.linspace(0.75, 1.5, num_strikes)
855
- strikes_ttms = (strikes_ttm, strikes_ttm, strikes_ttm, strikes_ttm)
855
+ strikes_ttms = (strikes_ttm, strikes_ttm, strikes_ttm, strikes_ttm, strikes_ttm, strikes_ttm)
856
856
 
857
857
  optiontypes_ttm = np.full(strikes_ttm.shape, 'C')
858
- optiontypes_ttms = (optiontypes_ttm, optiontypes_ttm, optiontypes_ttm, optiontypes_ttm)
858
+ optiontypes_ttms = (optiontypes_ttm, optiontypes_ttm, optiontypes_ttm, optiontypes_ttm, optiontypes_ttm, optiontypes_ttm)
859
859
 
860
860
  data = OptionChain(ids=ids,
861
861
  ttms=ttms,