voly 0.0.86__py3-none-any.whl → 0.0.89__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 +20 -204
- voly/core/charts.py +10 -517
- voly/core/data.py +1 -4
- voly/core/fit.py +35 -43
- voly/core/interpolate.py +5 -6
- voly/core/rnd.py +255 -334
- voly/formulas.py +27 -29
- voly/models.py +0 -6
- {voly-0.0.86.dist-info → voly-0.0.89.dist-info}/METADATA +1 -1
- voly-0.0.89.dist-info/RECORD +18 -0
- {voly-0.0.86.dist-info → voly-0.0.89.dist-info}/WHEEL +1 -1
- voly-0.0.86.dist-info/RECORD +0 -18
- {voly-0.0.86.dist-info → voly-0.0.89.dist-info}/LICENSE +0 -0
- {voly-0.0.86.dist-info → voly-0.0.89.dist-info}/top_level.txt +0 -0
voly/formulas.py
CHANGED
|
@@ -254,7 +254,7 @@ def iv(option_price: float, s: float, k: float, r: float, t: float,
|
|
|
254
254
|
for _ in range(max_iterations):
|
|
255
255
|
# Calculate option price and vega with current volatility
|
|
256
256
|
price = bs(s, k, r, vol, t, option_type)
|
|
257
|
-
v = vega(s, k, r, vol, t)
|
|
257
|
+
v = vega(s, k, r, vol, t, option_type)
|
|
258
258
|
|
|
259
259
|
# Calculate price difference
|
|
260
260
|
price_diff = price - option_price
|
|
@@ -279,31 +279,31 @@ def iv(option_price: float, s: float, k: float, r: float, t: float,
|
|
|
279
279
|
|
|
280
280
|
|
|
281
281
|
@catch_exception
|
|
282
|
-
def
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
282
|
+
def get_domain(domain_params: Tuple[float, float, int] = (-1.5, 1.5, 1000),
|
|
283
|
+
s: float = None,
|
|
284
|
+
r: float = None,
|
|
285
|
+
o: np.ndarray = None,
|
|
286
|
+
t: float = None,
|
|
287
|
+
return_domain: str = 'log_moneyness') -> np.ndarray:
|
|
288
288
|
"""
|
|
289
289
|
Compute the x-domain for a given return type (log-moneyness, moneyness, strikes, or delta).
|
|
290
290
|
|
|
291
291
|
Parameters:
|
|
292
292
|
-----------
|
|
293
|
-
|
|
293
|
+
domain_params : Tuple[float, float, int],
|
|
294
294
|
Parameters for log-moneyness domain: (min_log_moneyness, max_log_moneyness, num_points).
|
|
295
295
|
Default is (-1.5, 1.5, 1000).
|
|
296
|
-
return_domain : str, optional
|
|
297
|
-
The desired domain to return. Options are 'log_moneyness', 'moneyness', 'strikes', or 'delta'.
|
|
298
|
-
Default is 'log_moneyness'.
|
|
299
296
|
s : float, optional
|
|
300
297
|
Spot price of the underlying asset. Required for 'strikes' and 'delta' domains.
|
|
301
298
|
r : float, optional
|
|
302
299
|
Risk-free interest rate. Required for 'delta' domain.
|
|
303
|
-
|
|
300
|
+
o : np.ndarray, optional
|
|
304
301
|
Array of implied volatilities. Required for 'delta' domain.
|
|
305
|
-
|
|
302
|
+
t : float, optional
|
|
306
303
|
Time to maturity in years. Required for 'delta' domain.
|
|
304
|
+
return_domain : str, optional
|
|
305
|
+
The desired domain to return. Options are 'log_moneyness', 'moneyness', 'returns' 'strikes', or 'delta'.
|
|
306
|
+
Default is 'log_moneyness'.
|
|
307
307
|
|
|
308
308
|
Returns:
|
|
309
309
|
--------
|
|
@@ -317,43 +317,41 @@ def get_x_domain(log_moneyness_params: Tuple[float, float, int] = (-1.5, 1.5, 10
|
|
|
317
317
|
"""
|
|
318
318
|
|
|
319
319
|
# Extract log-moneyness parameters and generate array
|
|
320
|
-
|
|
321
|
-
log_moneyness = np.linspace(min_m, max_m, num_points)
|
|
320
|
+
LM = np.linspace(domain_params[0], domain_params[1], domain_params[2])
|
|
322
321
|
|
|
323
322
|
# Handle different return domains
|
|
324
323
|
if return_domain == 'log_moneyness':
|
|
325
|
-
return
|
|
324
|
+
return LM
|
|
326
325
|
|
|
327
326
|
elif return_domain == 'moneyness':
|
|
328
|
-
return np.exp(
|
|
327
|
+
return np.exp(LM)
|
|
328
|
+
|
|
329
|
+
elif return_domain == 'returns':
|
|
330
|
+
return np.exp(LM) - 1
|
|
329
331
|
|
|
330
332
|
elif return_domain == 'strikes':
|
|
331
333
|
if s is None:
|
|
332
334
|
raise ValueError("Spot price 's' is required for return_domain='strikes'.")
|
|
333
|
-
return s / np.exp(
|
|
335
|
+
return s / np.exp(LM)
|
|
334
336
|
|
|
335
337
|
elif return_domain == 'delta':
|
|
336
338
|
# Check for required parameters
|
|
337
|
-
required_params = {'s': s, '
|
|
339
|
+
required_params = {'s': s, 'o': o, 'r': r, 't': t}
|
|
338
340
|
missing_params = [param for param, value in required_params.items() if value is None]
|
|
339
341
|
if missing_params:
|
|
340
342
|
raise ValueError(f"The following parameters are required for return_domain='delta': {missing_params}")
|
|
341
343
|
|
|
342
|
-
if len(
|
|
344
|
+
if len(o) != len(LM):
|
|
343
345
|
raise ValueError(
|
|
344
|
-
f"
|
|
346
|
+
f"'o' must have the same length as the log-moneyness array ({len(log_moneyness)}).")
|
|
345
347
|
|
|
346
348
|
# Compute strikes
|
|
347
|
-
|
|
349
|
+
K = s / np.exp(LM)
|
|
348
350
|
|
|
349
351
|
# Compute deltas
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
for k, vol in zip(strikes, iv_array)
|
|
353
|
-
])
|
|
354
|
-
|
|
355
|
-
return delta_values
|
|
352
|
+
D = np.array([delta(s, K, r, o, t, 'call') for K, o in zip(K, o)])
|
|
353
|
+
return D
|
|
356
354
|
|
|
357
355
|
else:
|
|
358
356
|
raise ValueError(
|
|
359
|
-
f"Invalid return_domain: {return_domain}. Must be one of ['log_moneyness', 'moneyness', 'strikes', 'delta'].")
|
|
357
|
+
f"Invalid return_domain: {return_domain}. Must be one of ['log_moneyness', 'moneyness', 'returns', 'strikes', 'delta'].")
|
voly/models.py
CHANGED
|
@@ -5,12 +5,6 @@ Volatility models for the Voly package.
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from typing import Tuple, Dict, List, Optional, Union
|
|
7
7
|
|
|
8
|
-
# Configuration settings
|
|
9
|
-
DEFAULT_MONEYNESS_RANGE = (-2, 2)
|
|
10
|
-
DEFAULT_MONEYNESS_POINTS = 500
|
|
11
|
-
MIN_DTE = 2.0 # Minimum days to expiry to include
|
|
12
|
-
|
|
13
|
-
|
|
14
8
|
class SVIModel:
|
|
15
9
|
"""
|
|
16
10
|
Stochastic Volatility Inspired (SVI) model.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
|
2
|
+
voly/client.py,sha256=M_XmGQAheVSPOBJPXVYJzm1s8ZOcBZ6keeZhb9Yu0R4,15367
|
|
3
|
+
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
|
4
|
+
voly/formulas.py,sha256=6T0CuCtJpDp8nq0MUJ_3fA_su8nL4yfCU2H3m3_Sc_s,11699
|
|
5
|
+
voly/models.py,sha256=Vs69QZYQ_Tt6hkaZ6Mfnq3II1dHDqQrZTzBNiaOIbwo,3516
|
|
6
|
+
voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
|
7
|
+
voly/core/charts.py,sha256=5PgunB8oVPoD5R9eIjc9efCbc6d9C5yswO2yG1qj8uo,12734
|
|
8
|
+
voly/core/data.py,sha256=OzWbzmMQN4CEG8lUdwMK2RrnvEjkJrNcMDMv4JDRewA,8871
|
|
9
|
+
voly/core/fit.py,sha256=rMYXuiDOWlyR5FbgK1nc8h_wSc9r6CBQS6b6DI6ZsYc,9252
|
|
10
|
+
voly/core/interpolate.py,sha256=JkK172-FXyhesW3hY4pEeuJWG3Bugq7QZXbeKoRpLuo,5305
|
|
11
|
+
voly/core/rnd.py,sha256=fZpwoPo64YvR7g0tgOW_uk88gnZ0N0hL4FlCECARZco,10052
|
|
12
|
+
voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
|
|
13
|
+
voly/utils/logger.py,sha256=4-_2bVJmq17Q0d7Rd2mPg1AeR8gxv6EPvcmBDMFWcSM,1744
|
|
14
|
+
voly-0.0.89.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
|
15
|
+
voly-0.0.89.dist-info/METADATA,sha256=aTaX34vQn5u1TRt2DBkLH4sBlpUsCYGiVGl1RaZsvL8,4092
|
|
16
|
+
voly-0.0.89.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
17
|
+
voly-0.0.89.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
|
18
|
+
voly-0.0.89.dist-info/RECORD,,
|
voly-0.0.86.dist-info/RECORD
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
|
2
|
-
voly/client.py,sha256=ABScTJhB-KXjv3ddJ6XEoSIt9DB4Z40TzH8GGalrox8,21859
|
|
3
|
-
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
|
4
|
-
voly/formulas.py,sha256=wSbGAH6GuQThT9QyQY4Ud2eUf9fo1YFHglUmP6fNris,11871
|
|
5
|
-
voly/models.py,sha256=LXXIlpXZQEfXTuCngxC8Hd3bWtw6wdXDCSGxTLmHM-c,3659
|
|
6
|
-
voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
|
7
|
-
voly/core/charts.py,sha256=ycZgbPeROYVRMO61auVXCGLmKZA2NwS3vLOsQ9wqCyo,27526
|
|
8
|
-
voly/core/data.py,sha256=JCPD44UDSJqh83jjapAtXVpJEHm8Hq4JC8lVhl5Zb4A,8935
|
|
9
|
-
voly/core/fit.py,sha256=voWB2KAoeWf1j5PHoBif-4ZB0tF6V2qDXgkhdYT-fbc,9599
|
|
10
|
-
voly/core/interpolate.py,sha256=BzLwEuE-PIf0k0oVka7gH6NASlaEdtZAo7zUVwarkoQ,5384
|
|
11
|
-
voly/core/rnd.py,sha256=8FTU-Qp9epW9yE4XSOdiFGIRXrGyXqF6mVgZn1NMvxk,11813
|
|
12
|
-
voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
|
|
13
|
-
voly/utils/logger.py,sha256=4-_2bVJmq17Q0d7Rd2mPg1AeR8gxv6EPvcmBDMFWcSM,1744
|
|
14
|
-
voly-0.0.86.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
|
15
|
-
voly-0.0.86.dist-info/METADATA,sha256=BgXv50AoaUgr8fngU3tkvuBHvdYwaoBc5O7dzBNGbxI,4092
|
|
16
|
-
voly-0.0.86.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
|
17
|
-
voly-0.0.86.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
|
18
|
-
voly-0.0.86.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|