voly 0.0.123__py3-none-any.whl → 0.0.126__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- voly/client.py +16 -3
- voly/core/hd.py +7 -7
- voly/core/rnd.py +1 -2
- {voly-0.0.123.dist-info → voly-0.0.126.dist-info}/METADATA +1 -1
- {voly-0.0.123.dist-info → voly-0.0.126.dist-info}/RECORD +8 -8
- {voly-0.0.123.dist-info → voly-0.0.126.dist-info}/WHEEL +0 -0
- {voly-0.0.123.dist-info → voly-0.0.126.dist-info}/licenses/LICENSE +0 -0
- {voly-0.0.123.dist-info → voly-0.0.126.dist-info}/top_level.txt +0 -0
voly/client.py
CHANGED
|
@@ -216,7 +216,10 @@ class VolyClient:
|
|
|
216
216
|
return_domain=return_domain
|
|
217
217
|
)
|
|
218
218
|
|
|
219
|
-
return
|
|
219
|
+
return {
|
|
220
|
+
'iv_surface': iv_surface,
|
|
221
|
+
'x_surface': x_surface
|
|
222
|
+
}
|
|
220
223
|
|
|
221
224
|
@staticmethod
|
|
222
225
|
def plot_model(fit_results: pd.DataFrame,
|
|
@@ -316,7 +319,12 @@ class VolyClient:
|
|
|
316
319
|
method=method
|
|
317
320
|
)
|
|
318
321
|
|
|
319
|
-
return
|
|
322
|
+
return {
|
|
323
|
+
'pdf_surface': pdf_surface,
|
|
324
|
+
'cdf_surface': cdf_surface,
|
|
325
|
+
'x_surface': x_surface,
|
|
326
|
+
'moments': moments
|
|
327
|
+
}
|
|
320
328
|
|
|
321
329
|
# -------------------------------------------------------------------------
|
|
322
330
|
# Historical Density (HD)
|
|
@@ -354,7 +362,12 @@ class VolyClient:
|
|
|
354
362
|
return_domain=return_domain
|
|
355
363
|
)
|
|
356
364
|
|
|
357
|
-
return
|
|
365
|
+
return {
|
|
366
|
+
'pdf_surface': pdf_surface,
|
|
367
|
+
'cdf_surface': cdf_surface,
|
|
368
|
+
'x_surface': x_surface,
|
|
369
|
+
'moments': moments
|
|
370
|
+
}
|
|
358
371
|
|
|
359
372
|
@staticmethod
|
|
360
373
|
def get_rv_surface(model_results: pd.DataFrame,
|
voly/core/hd.py
CHANGED
|
@@ -221,18 +221,18 @@ def get_rv_surface(model_results: pd.DataFrame,
|
|
|
221
221
|
if missing_columns:
|
|
222
222
|
raise VolyError(f"Required columns missing in model_results: {missing_columns}")
|
|
223
223
|
|
|
224
|
-
|
|
224
|
+
rv_surface = {}
|
|
225
225
|
new_x_surface = {}
|
|
226
226
|
all_params = {}
|
|
227
227
|
|
|
228
|
-
# Check if
|
|
229
|
-
if not
|
|
228
|
+
# Check if pdf_surface is empty
|
|
229
|
+
if not pdf_surface:
|
|
230
230
|
logger.warning("Historical density surface is empty.")
|
|
231
231
|
return {}, {}, pd.DataFrame()
|
|
232
232
|
|
|
233
233
|
# Process each maturity
|
|
234
234
|
for i in model_results.index:
|
|
235
|
-
if i not in
|
|
235
|
+
if i not in pdf_surface:
|
|
236
236
|
logger.warning(f"No historical density available for maturity {i}, skipping.")
|
|
237
237
|
continue
|
|
238
238
|
|
|
@@ -256,7 +256,7 @@ def get_rv_surface(model_results: pd.DataFrame,
|
|
|
256
256
|
for j, lm_k in enumerate(LM):
|
|
257
257
|
mask = LM >= lm_k
|
|
258
258
|
if np.any(mask):
|
|
259
|
-
integrand = s * (np.exp(LM[mask]) - np.exp(lm_k)) *
|
|
259
|
+
integrand = s * (np.exp(LM[mask]) - np.exp(lm_k)) * pdf[mask]
|
|
260
260
|
c_recovered[j] = np.exp(-r * t) * np.trapz(integrand, LM[mask])
|
|
261
261
|
|
|
262
262
|
# Ensure call prices are at least the intrinsic value
|
|
@@ -352,7 +352,7 @@ def get_rv_surface(model_results: pd.DataFrame,
|
|
|
352
352
|
o_recovered = np.sqrt(w / t)
|
|
353
353
|
|
|
354
354
|
# Store results
|
|
355
|
-
|
|
355
|
+
rv_surface[i] = o_recovered
|
|
356
356
|
|
|
357
357
|
if return_domain == 'log_moneyness':
|
|
358
358
|
x = LM
|
|
@@ -370,4 +370,4 @@ def get_rv_surface(model_results: pd.DataFrame,
|
|
|
370
370
|
# Create a DataFrame with parameters
|
|
371
371
|
fit_results = pd.DataFrame(all_params).T
|
|
372
372
|
x_surface = new_x_surface
|
|
373
|
-
return
|
|
373
|
+
return rv_surface, x_surface, fit_results
|
voly/core/rnd.py
CHANGED
|
@@ -220,8 +220,7 @@ def get_all_moments(x, pdf):
|
|
|
220
220
|
def get_rnd_surface(model_results: pd.DataFrame,
|
|
221
221
|
domain_params: Tuple[float, float, int] = (-1.5, 1.5, 1000),
|
|
222
222
|
return_domain: str = 'log_moneyness',
|
|
223
|
-
method: str = 'rookley') ->
|
|
224
|
-
Dict[str, np.ndarray], Dict[str, np.ndarray], Dict[str, np.ndarray], pd.DataFrame]:
|
|
223
|
+
method: str = 'rookley') -> Dict[str, np.ndarray]:
|
|
225
224
|
"""
|
|
226
225
|
Generate RND surface from vol smile parameters.
|
|
227
226
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
|
2
|
-
voly/client.py,sha256=
|
|
2
|
+
voly/client.py,sha256=3Qe_fLkBTEPHzZ9rZdXd4u4xhaIpQGesn1XjkcBIk1A,14887
|
|
3
3
|
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
|
4
4
|
voly/formulas.py,sha256=HejPfgVh6-hmWDhvwbHgAIfQMt8iPbIiaKqcBrB5Spw,10766
|
|
5
5
|
voly/models.py,sha256=BF-O7BjGf0BLMpw4rCtfwW7s8_f4iyUZdUY6q1dVxLs,3363
|
|
@@ -7,13 +7,13 @@ voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
|
|
7
7
|
voly/core/charts.py,sha256=E21OZB5lTY4YL2flgaFJ6s5g3_ExtAQT2zryZZxLPyM,12735
|
|
8
8
|
voly/core/data.py,sha256=pDeuYhP0GX4RbtlqByvsE3rfHcIkix0BU5MLW8sKIeI,8935
|
|
9
9
|
voly/core/fit.py,sha256=Tb9eeG7e_2dQTcqt6aqEwFrZdy6jR9rSNqe6tzOdVhQ,9245
|
|
10
|
-
voly/core/hd.py,sha256=
|
|
10
|
+
voly/core/hd.py,sha256=l4oh7ESy6XVPLErKZaF1fSv0EX8hT-0Z5DrpqPhmP3Q,13459
|
|
11
11
|
voly/core/interpolate.py,sha256=JkK172-FXyhesW3hY4pEeuJWG3Bugq7QZXbeKoRpLuo,5305
|
|
12
|
-
voly/core/rnd.py,sha256=
|
|
12
|
+
voly/core/rnd.py,sha256=0VE77lxesx_BPAO46QwKpcauZNaHnPTiDhmRbSURn3c,10022
|
|
13
13
|
voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
|
|
14
14
|
voly/utils/logger.py,sha256=4-_2bVJmq17Q0d7Rd2mPg1AeR8gxv6EPvcmBDMFWcSM,1744
|
|
15
|
-
voly-0.0.
|
|
16
|
-
voly-0.0.
|
|
17
|
-
voly-0.0.
|
|
18
|
-
voly-0.0.
|
|
19
|
-
voly-0.0.
|
|
15
|
+
voly-0.0.126.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
|
16
|
+
voly-0.0.126.dist-info/METADATA,sha256=rUDMhX7wzVYkuEOZWHbaWW0igWTAotTuHkZ80Il4z0k,4115
|
|
17
|
+
voly-0.0.126.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
|
18
|
+
voly-0.0.126.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
|
19
|
+
voly-0.0.126.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|