stochvolmodels 1.1.5__tar.gz → 1.1.6__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 (94) hide show
  1. {stochvolmodels-1.1.5/stochvolmodels.egg-info → stochvolmodels-1.1.6}/PKG-INFO +1 -1
  2. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/pyproject.toml +1 -1
  3. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/logsv_pricer.py +2 -2
  4. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/rough_logsv/split_simulation.py +56 -2
  5. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6/stochvolmodels.egg-info}/PKG-INFO +1 -1
  6. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/.gitignore +0 -0
  7. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/LICENSE.txt +0 -0
  8. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/MANIFEST.in +0 -0
  9. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/README.md +0 -0
  10. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/forward_var/calibrate_forward_var.py +0 -0
  11. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/il_hedging/README.md +0 -0
  12. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/il_hedging/logsv_figures.py +0 -0
  13. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/il_hedging/run_logsv_for_il_payoff.py +0 -0
  14. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/inverse_options/README.md +0 -0
  15. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/inverse_options/compare_net_delta.py +0 -0
  16. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/README.md +0 -0
  17. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/article_figures.py +0 -0
  18. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/calibrations.py +0 -0
  19. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/compare_admis_reg.py +0 -0
  20. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/model_fit_to_options_timeseries.py +0 -0
  21. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/moments_vol_qvar.py +0 -0
  22. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/ode_sol_in_time.py +0 -0
  23. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/steady_state_pdf.py +0 -0
  24. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/logsv_model_wtih_quadratic_drift/vol_drift.py +0 -0
  25. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/risk_premia_gmm/check_kernel.py +0 -0
  26. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/risk_premia_gmm/gmm_slides.py +0 -0
  27. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/risk_premia_gmm/plot_gmm.py +0 -0
  28. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/risk_premia_gmm/q_kernel.py +0 -0
  29. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/risk_premia_gmm/run_gmm_fit.py +0 -0
  30. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/sv_for_factor_hjm/README.md +0 -0
  31. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/sv_for_factor_hjm/calibration_fig_5_6_7.py +0 -0
  32. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/sv_for_factor_hjm/calibration_fig_8_9.py +0 -0
  33. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/t_distribution/illustrations.py +0 -0
  34. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/t_distribution/market_data_fit.py +0 -0
  35. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/t_distribution/mc_pricer_with_kernel.py +0 -0
  36. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/volatility_models/README.md +0 -0
  37. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/volatility_models/article_figures.py +0 -0
  38. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/volatility_models/autocorr_fit.py +0 -0
  39. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/volatility_models/load_data.py +0 -0
  40. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/volatility_models/ss_distribution_fit.py +0 -0
  41. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/my_papers/volatility_models/vol_beta.py +0 -0
  42. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/requirements.txt +0 -0
  43. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/setup.cfg +0 -0
  44. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/__init__.py +0 -0
  45. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/data/__init__.py +0 -0
  46. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/data/fetch_option_chain.py +0 -0
  47. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/data/option_chain.py +0 -0
  48. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/data/test_option_chain.py +0 -0
  49. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/examples/quick_run_lognormal_sv_pricer.py +0 -0
  50. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/examples/run_hawkes_pricer.py +0 -0
  51. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/examples/run_heston.py +0 -0
  52. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/examples/run_heston_sv_pricer.py +0 -0
  53. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/examples/run_lognormal_sv_pricer.py +0 -0
  54. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/examples/run_pricing_options_on_qvar.py +0 -0
  55. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/__init__.py +0 -0
  56. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/analytic/__init__.py +0 -0
  57. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/analytic/bachelier.py +0 -0
  58. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/analytic/bsm.py +0 -0
  59. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/analytic/tdist.py +0 -0
  60. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/double_exp_pricer.py +0 -0
  61. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/factor_hjm_pricer.py +0 -0
  62. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/rate_affine_expansion.py +0 -0
  63. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/rate_core.py +0 -0
  64. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/rate_evaluate.py +0 -0
  65. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/rate_factor_basis.py +0 -0
  66. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/rate_logsv_ivols.py +0 -0
  67. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/rate_logsv_params.py +0 -0
  68. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/factor_hjm/rate_logsv_pricer.py +0 -0
  69. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/gmm_pricer.py +0 -0
  70. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/hawkes_jd_pricer.py +0 -0
  71. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/heston_pricer.py +0 -0
  72. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/logsv/__init__.py +0 -0
  73. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/logsv/affine_expansion.py +0 -0
  74. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/logsv/logsv_params.py +0 -0
  75. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/logsv/vol_moments_ode.py +0 -0
  76. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/model_pricer.py +0 -0
  77. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/rough_logsv/RoughKernel.py +0 -0
  78. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/rough_logsv/expm.py +0 -0
  79. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/rough_logsv/test_kernel_approx.py +0 -0
  80. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/pricers/tdist_pricer.py +0 -0
  81. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/tests/__init__.py +0 -0
  82. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/tests/bsm_mgf_pricer.py +0 -0
  83. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/tests/qv_pricer.py +0 -0
  84. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/utils/__init__.py +0 -0
  85. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/utils/config.py +0 -0
  86. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/utils/funcs.py +0 -0
  87. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/utils/mc_payoffs.py +0 -0
  88. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/utils/mgf_pricer.py +0 -0
  89. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/utils/plots.py +0 -0
  90. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels/utils/var_swap_pricer.py +0 -0
  91. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels.egg-info/SOURCES.txt +0 -0
  92. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels.egg-info/dependency_links.txt +0 -0
  93. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels.egg-info/requires.txt +0 -0
  94. {stochvolmodels-1.1.5 → stochvolmodels-1.1.6}/stochvolmodels.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stochvolmodels
3
- Version: 1.1.5
3
+ Version: 1.1.6
4
4
  Summary: Python implementation of pricing analytics and Monte Carlo simulations for stochastic volatility models including log-normal SV model, Heston
5
5
  Author-email: Artur Sepp <artursepp@gmail.com>
6
6
  Maintainer-email: Artur Sepp <artursepp@gmail.com>, Parviz Rakhmonov <ParvizRZ@gmail.com>
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "stochvolmodels"
10
- version = "1.1.5"
10
+ version = "1.1.6"
11
11
  description = "Python implementation of pricing analytics and Monte Carlo simulations for stochastic volatility models including log-normal SV model, Heston"
12
12
  readme = "README.md"
13
13
  license = {file = "LICENSE.txt"}
@@ -906,8 +906,8 @@ def rough_logsv_mc_chain_pricer_fixed_randoms(ttms: np.ndarray,
906
906
  nodes_vec = np.repeat(nodes[:, None], nb_path,axis=1)
907
907
  log_spot_str, vol_str, qv_str = log_spot_full_combined(nodes_vec, weight_vec, v0_vec, theta, kappa1, kappa2, log_s0,
908
908
  v_init, rho, volvol, timegrid, nb_path, Z0_, Z1_)
909
- print(f"Number of paths with negative vol: {np.sum(weights @ vol_str < 0.0)}")
910
- print(f"Mean spot Strand: {np.mean(np.exp(log_spot_str))}")
909
+ print(f"Number of paths with negative vol: {np.sum(weights @ vol_str < 0.0)}, nan vol: {np.count_nonzero(np.isnan(weights @ vol_str))}")
910
+ print(f"Mean spot Strand: {np.mean(np.exp(log_spot_str))}, nan spots: {np.count_nonzero(np.isnan(log_spot_str))}")
911
911
 
912
912
  option_prices, option_std = compute_mc_vars_payoff(x0=log_spot_str, sigma0=vol_str, qvar0=qv_str,
913
913
  ttm=ttm,
@@ -75,6 +75,57 @@ def drift_ode_solve(nodes: np.ndarray, v0: np.ndarray, theta: float, kappa1: flo
75
75
  return Dzh
76
76
 
77
77
 
78
+ @njit(cache=False, fastmath=True)
79
+ def drift_ode_solve2(nodes: np.ndarray, v0: np.ndarray, theta: float, kappa1: float, kappa2: float,
80
+ z0: np.ndarray, weight: np.ndarray, h: float):
81
+ """
82
+
83
+ Parameters
84
+ ----------
85
+ nodes : (fixed argument) exponents x_i, array of size (n,)
86
+ v0 : (fixed argument) array of size (n, nb_path)
87
+ theta : long-run level, scalar
88
+ kappa1 : linear mean-reversion speed, scalar
89
+ kappa2 : quadratic mean-reversion speed, scalar
90
+ z0 : initial values, array of size (n, nb_path)
91
+ weight : wieghts, array of size (n, )
92
+ h : step size
93
+
94
+ Returns
95
+ -------
96
+ Array of size (n, nb_path)
97
+ """
98
+ assert nodes.shape == v0.shape == z0.shape == weight.shape
99
+ n, nb_path = weight.shape
100
+
101
+ # --- k1 ---
102
+ z0w = np.sum(weight * z0, axis=0)
103
+ c1 = (kappa1 + kappa2 * z0w) * (theta - z0w)
104
+ s1 = -nodes * (z0 - v0) + c1
105
+
106
+ # --- k2 ---
107
+ z_tmp = z0 + 0.5 * h * s1
108
+ z1w = np.sum(weight * z_tmp, axis=0)
109
+ c2 = (kappa1 + kappa2 * z1w) * (theta - z1w)
110
+ s2 = -nodes * (z_tmp - v0) + c2
111
+
112
+ # --- k3 ---
113
+ z_tmp = z0 + 0.5 * h * s2
114
+ z2w = np.sum(weight * z_tmp, axis=0)
115
+ c3 = (kappa1 + kappa2 * z2w) * (theta - z2w)
116
+ s3 = -nodes * (z_tmp - v0) + c3
117
+
118
+ # --- k4 ---
119
+ z_tmp = z0 + h * s3
120
+ z3w = np.sum(weight * z_tmp, axis=0)
121
+ c4 = (kappa1 + kappa2 * z3w) * (theta - z3w)
122
+ s4 = -nodes * (z_tmp - v0) + c4
123
+
124
+ zh = z0 + (h / 6.0) * (s1 + 2.0 * s2 + 2.0 * s3 + s4)
125
+
126
+ return zh
127
+
128
+
78
129
  @njit(cache=False, fastmath=True)
79
130
  def drift_ode_solve3(nodes: np.ndarray, v0: np.ndarray, theta: float, kappa1: float, kappa2: float,
80
131
  z0: np.ndarray, weight: np.ndarray, h: float):
@@ -185,9 +236,9 @@ def drift_diffus_strand(nodes: np.ndarray, v0: np.ndarray, theta: float, kappa1:
185
236
  -------
186
237
 
187
238
  """
188
- D_inn = drift_ode_solve3(nodes, v0, theta, kappa1, kappa2, v_init, weight, 0.5 * h)
239
+ D_inn = drift_ode_solve2(nodes, v0, theta, kappa1, kappa2, v_init, weight, 0.5 * h)
189
240
  S_inn = diffus_sde_solve(D_inn, weight, volvol, h, nb_path, z_rand)
190
- sol = drift_ode_solve3(nodes, v0, theta, kappa1, kappa2, S_inn, weight, 0.5 * h)
241
+ sol = drift_ode_solve2(nodes, v0, theta, kappa1, kappa2, S_inn, weight, 0.5 * h)
191
242
 
192
243
  return sol
193
244
 
@@ -208,6 +259,9 @@ def log_spot_full_solve2(nodes: np.ndarray, weight: np.ndarray,
208
259
  assert z0.shape == (nb_path,) and z1.shape == (nb_path,)
209
260
 
210
261
  vol_h = drift_diffus_strand(nodes, v0, theta, kappa1, kappa2, volvol, v, weight, h, nb_path, z0)
262
+ w_vol_h = np.sum(weight * vol_h, axis=0)
263
+ idx_bad = np.nonzero(np.logical_or(np.isnan(w_vol_h), w_vol_h <= 0.0))[0]
264
+ vol_h[:, idx_bad] = 1e-6
211
265
 
212
266
  wlam = weight * nodes
213
267
  vw = np.sum(weight * v, axis=0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stochvolmodels
3
- Version: 1.1.5
3
+ Version: 1.1.6
4
4
  Summary: Python implementation of pricing analytics and Monte Carlo simulations for stochastic volatility models including log-normal SV model, Heston
5
5
  Author-email: Artur Sepp <artursepp@gmail.com>
6
6
  Maintainer-email: Artur Sepp <artursepp@gmail.com>, Parviz Rakhmonov <ParvizRZ@gmail.com>
File without changes
File without changes