voly 0.0.2__tar.gz → 0.0.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: voly
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "voly"
7
- version = "0.0.2"
7
+ version = "0.0.4"
8
8
  description = "Options & volatility research package"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -61,7 +61,7 @@ line_length = 100
61
61
  multi_line_output = 3
62
62
 
63
63
  [tool.mypy]
64
- python_version = "0.0.2"
64
+ python_version = "0.0.4"
65
65
  warn_return_any = true
66
66
  warn_unused_configs = true
67
67
  disallow_untyped_defs = true
@@ -12,10 +12,10 @@ from typing import Dict, List, Tuple, Optional, Union, Any, Callable
12
12
  import plotly.graph_objects as go
13
13
 
14
14
  from voly.utils.logger import logger, catch_exception, setup_file_logging
15
- from voly.exceptions import VolyError, ValidationError, DataError
15
+ from voly.exceptions import VolyError
16
16
  from voly.models import SVIModel
17
17
  from voly.formulas import (
18
- bs, delta, gamma, vega, theta, rho, vanna, volga, charm, greeks, iv, implied_underlying
18
+ bs, delta, gamma, vega, theta, rho, vanna, volga, charm, greeks, iv
19
19
  )
20
20
  from voly.core.data import fetch_option_chain, process_option_chain
21
21
  from voly.core.fit import fit_model
@@ -390,7 +390,7 @@ class VolyClient:
390
390
  # Use first maturity if not specified
391
391
  maturity = list(rnd_surface.keys())[0]
392
392
  elif maturity not in rnd_surface:
393
- raise ValidationError(f"Maturity '{maturity}' not found in RND results")
393
+ raise VolyError(f"Maturity '{maturity}' not found in RND results")
394
394
 
395
395
  # Get RND values for the selected maturity
396
396
  rnd_values = rnd_surface[maturity]
@@ -438,7 +438,7 @@ class VolyClient:
438
438
  # Use first maturity if not specified
439
439
  maturity = list(rnd_surface.keys())[0]
440
440
  elif maturity not in rnd_surface:
441
- raise ValidationError(f"Maturity '{maturity}' not found in RND results")
441
+ raise VolyError(f"Maturity '{maturity}' not found in RND results")
442
442
 
443
443
  # Get RND values for the selected maturity
444
444
  rnd_values = rnd_surface[maturity]
@@ -477,7 +477,7 @@ class VolyClient:
477
477
  - Probability (0 to 1)
478
478
  """
479
479
  if direction not in ['above', 'below']:
480
- raise ValidationError("Direction must be 'above' or 'below'")
480
+ raise VolyError("Direction must be 'above' or 'below'")
481
481
 
482
482
  # Extract required data
483
483
  moneyness_grid = rnd_results['moneyness_grid']
@@ -489,7 +489,7 @@ class VolyClient:
489
489
  # Use first maturity if not specified
490
490
  maturity = list(rnd_surface.keys())[0]
491
491
  elif maturity not in rnd_surface:
492
- raise ValidationError(f"Maturity '{maturity}' not found in RND results")
492
+ raise VolyError(f"Maturity '{maturity}' not found in RND results")
493
493
 
494
494
  # Get RND values for the selected maturity
495
495
  rnd_values = rnd_surface[maturity]
@@ -17,7 +17,7 @@ import re
17
17
  import numpy as np
18
18
  from typing import List, Dict, Any, Optional, Union
19
19
  from voly.utils.logger import logger, catch_exception
20
- from voly.exceptions import DataError, ExchangeError, ConnectionError
20
+ from voly.exceptions import VolyError
21
21
 
22
22
 
23
23
  async def subscribe_channels(ws, channels):
@@ -157,7 +157,7 @@ async def get_deribit_data(currency: str = "BTC") -> pd.DataFrame:
157
157
  try:
158
158
  instruments = [i['instrument_name'] for i in response.json()['result']]
159
159
  except (KeyError, json.JSONDecodeError) as e:
160
- raise DataError(f"Failed to parse Deribit API response: {str(e)}")
160
+ raise VolyError(f"Failed to parse Deribit API response: {str(e)}")
161
161
 
162
162
  total_instruments = len(instruments)
163
163
  logger.info(f"Found {total_instruments} active {currency} options")
@@ -183,7 +183,7 @@ async def get_deribit_data(currency: str = "BTC") -> pd.DataFrame:
183
183
  logger.info(f"Total processing time: {total_time:.2f}s - {len(all_data)} instruments processed")
184
184
 
185
185
  if not all_data:
186
- raise DataError("No data collected from Deribit")
186
+ raise VolyError("No data collected from Deribit")
187
187
 
188
188
  return pd.DataFrame(all_data)
189
189
 
@@ -297,7 +297,7 @@ async def fetch_option_chain(exchange: str = 'deribit',
297
297
  pd.DataFrame: Processed option chain data
298
298
  """
299
299
  if exchange.lower() != 'deribit':
300
- raise ExchangeError(f"Exchange '{exchange}' is not supported. Currently only 'deribit' is available.")
300
+ raise VolyError(f"Exchange '{exchange}' is not supported. Currently only 'deribit' is available.")
301
301
 
302
302
  # Get raw data
303
303
  raw_data = await get_deribit_data(currency=currency)
@@ -11,7 +11,7 @@ from typing import List, Tuple, Dict, Optional, Union, Any
11
11
  from scipy.optimize import least_squares
12
12
  from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
13
13
  from voly.utils.logger import logger, catch_exception
14
- from voly.exceptions import ModelError, ValidationError
14
+ from voly.exceptions import VolyError
15
15
  from voly.models import SVIModel
16
16
 
17
17
 
@@ -90,7 +90,7 @@ def optimize_svi_parameters(market_data: pd.DataFrame,
90
90
  max_nfev=1000
91
91
  )
92
92
  except Exception as e:
93
- raise ModelError(f"Optimization failed for {maturity_name}: {str(e)}")
93
+ raise VolyError(f"Optimization failed for {maturity_name}: {str(e)}")
94
94
 
95
95
  # Store results with maturity name as key
96
96
  results[maturity_name] = {
@@ -300,7 +300,7 @@ def fit_model(market_data: pd.DataFrame,
300
300
  - Dictionary with fitting results
301
301
  """
302
302
  if model_name.lower() != 'svi':
303
- raise ValidationError(f"Model type '{model_name}' is not supported. Currently only 'svi' is available.")
303
+ raise VolyError(f"Model type '{model_name}' is not supported. Currently only 'svi' is available.")
304
304
 
305
305
  # Step 1: Optimize model parameters
306
306
  optimization_results = optimize_svi_parameters(market_data)
@@ -10,7 +10,7 @@ import pandas as pd
10
10
  from typing import List, Tuple, Dict, Optional, Union, Any
11
11
  from scipy.interpolate import interp1d, pchip_interpolate
12
12
  from voly.utils.logger import logger, catch_exception
13
- from voly.exceptions import InterpolationError
13
+ from voly.exceptions import VolyError
14
14
  from voly.models import SVIModel
15
15
 
16
16
 
@@ -36,7 +36,7 @@ def interpolate_surface_time(
36
36
  - 2D array of interpolated values (rows=target_expiries, cols=moneyness)
37
37
  """
38
38
  if len(expiries) < 2:
39
- raise InterpolationError("At least two expiries are required for time interpolation")
39
+ raise VolyError("At least two expiries are required for time interpolation")
40
40
 
41
41
  # Initialize the output array
42
42
  interpolated_surface = np.zeros((len(target_expiries), len(moneyness_grid)))
@@ -122,7 +122,7 @@ def interpolate_svi_parameters(
122
122
 
123
123
  # Check if we have enough points for interpolation
124
124
  if len(expiry_years) < 2:
125
- raise InterpolationError("At least two expiries are required for interpolation")
125
+ raise VolyError("At least two expiries are required for interpolation")
126
126
 
127
127
  # Create new parameter matrix for interpolated values
128
128
  interp_param_matrix = pd.DataFrame(
@@ -7,7 +7,7 @@ import numpy as np
7
7
  import pandas as pd
8
8
  from typing import Dict, List, Tuple, Optional, Union, Any
9
9
  from voly.utils.logger import logger, catch_exception
10
- from voly.exceptions import RNDError
10
+ from voly.exceptions import VolyError
11
11
  from voly.models import SVIModel
12
12
  from voly.formulas import rnd_base
13
13
 
@@ -364,7 +364,7 @@ def calculate_rnd(
364
364
  if maturity is not None:
365
365
  # Validate maturity
366
366
  if maturity not in raw_param_matrix.columns:
367
- raise RNDError(f"Maturity '{maturity}' not found in fit results")
367
+ raise VolyError(f"Maturity '{maturity}' not found in fit results")
368
368
 
369
369
  # Just calculate for the specified maturity
370
370
  yte = raw_param_matrix.attrs['yte_values'][maturity]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: voly
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes