voly 0.0.86__py3-none-any.whl → 0.0.87__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/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 get_x_domain(log_moneyness_params: Tuple[float, float, int] = (-1.5, 1.5, 1000),
283
- return_domain: str = 'log_moneyness',
284
- s: float = None,
285
- r: float = None,
286
- iv_array: np.ndarray = None,
287
- ytm: float = None) -> np.ndarray:
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
- log_moneyness_params : Tuple[float, float, int],
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
- iv_array : np.ndarray, optional
300
+ o : np.ndarray, optional
304
301
  Array of implied volatilities. Required for 'delta' domain.
305
- ytm : float, optional
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
- min_m, max_m, num_points = log_moneyness_params
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 log_moneyness
324
+ return LM
326
325
 
327
326
  elif return_domain == 'moneyness':
328
- return np.exp(log_moneyness)
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(log_moneyness) # K = S/exp(log_moneyness)
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, 'r': r, 'iv_array': iv_array, 'ytm': ytm}
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(iv_array) != len(log_moneyness):
344
+ if len(o) != len(LM):
343
345
  raise ValueError(
344
- f"iv_array must have the same length as the log-moneyness array ({len(log_moneyness)}).")
346
+ f"'o' must have the same length as the log-moneyness array ({len(log_moneyness)}).")
345
347
 
346
348
  # Compute strikes
347
- strikes = s / np.exp(log_moneyness)
349
+ K = s / np.exp(LM)
348
350
 
349
351
  # Compute deltas
350
- delta_values = np.array([
351
- delta(s, k, r, vol, ytm, 'call')
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
@@ -8,8 +8,6 @@ from typing import Tuple, Dict, List, Optional, Union
8
8
  # Configuration settings
9
9
  DEFAULT_MONEYNESS_RANGE = (-2, 2)
10
10
  DEFAULT_MONEYNESS_POINTS = 500
11
- MIN_DTE = 2.0 # Minimum days to expiry to include
12
-
13
11
 
14
12
  class SVIModel:
15
13
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: voly
3
- Version: 0.0.86
3
+ Version: 0.0.87
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -0,0 +1,18 @@
1
+ voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
2
+ voly/client.py,sha256=y3i2Tfrq7u0XiQMghR9QtQnmsAlR4HxVGqfHZyBPL9U,15545
3
+ voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
4
+ voly/formulas.py,sha256=6T0CuCtJpDp8nq0MUJ_3fA_su8nL4yfCU2H3m3_Sc_s,11699
5
+ voly/models.py,sha256=fUtTKVpUtAnudVHzuFE6IodMzKbFQ7hr987ElJ2k7SQ,3607
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=3nA3oAwoLtv_EnlLIjTelFmkafKnZeFIv4Ne_3LYWL4,9249
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.87.dist-info/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
15
+ voly-0.0.87.dist-info/METADATA,sha256=3RgL3l8_JcK-_AGM6Q5oEMP9S84EkU_hVgGLgVbto4M,4092
16
+ voly-0.0.87.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
17
+ voly-0.0.87.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
18
+ voly-0.0.87.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (76.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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