voly 0.0.179__tar.gz → 0.0.181__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 (26) hide show
  1. {voly-0.0.179/src/voly.egg-info → voly-0.0.181}/PKG-INFO +1 -1
  2. {voly-0.0.179 → voly-0.0.181}/pyproject.toml +2 -2
  3. {voly-0.0.179 → voly-0.0.181}/src/voly/client.py +2 -5
  4. {voly-0.0.179 → voly-0.0.181}/src/voly/core/fit.py +7 -9
  5. {voly-0.0.179 → voly-0.0.181/src/voly.egg-info}/PKG-INFO +1 -1
  6. {voly-0.0.179 → voly-0.0.181}/LICENSE +0 -0
  7. {voly-0.0.179 → voly-0.0.181}/README.md +0 -0
  8. {voly-0.0.179 → voly-0.0.181}/setup.cfg +0 -0
  9. {voly-0.0.179 → voly-0.0.181}/setup.py +0 -0
  10. {voly-0.0.179 → voly-0.0.181}/src/voly/__init__.py +0 -0
  11. {voly-0.0.179 → voly-0.0.181}/src/voly/core/__init__.py +0 -0
  12. {voly-0.0.179 → voly-0.0.181}/src/voly/core/charts.py +0 -0
  13. {voly-0.0.179 → voly-0.0.181}/src/voly/core/data.py +0 -0
  14. {voly-0.0.179 → voly-0.0.181}/src/voly/core/hd.py +0 -0
  15. {voly-0.0.179 → voly-0.0.181}/src/voly/core/interpolate.py +0 -0
  16. {voly-0.0.179 → voly-0.0.181}/src/voly/core/rnd.py +0 -0
  17. {voly-0.0.179 → voly-0.0.181}/src/voly/exceptions.py +0 -0
  18. {voly-0.0.179 → voly-0.0.181}/src/voly/formulas.py +0 -0
  19. {voly-0.0.179 → voly-0.0.181}/src/voly/models.py +0 -0
  20. {voly-0.0.179 → voly-0.0.181}/src/voly/utils/__init__.py +0 -0
  21. {voly-0.0.179 → voly-0.0.181}/src/voly/utils/density.py +0 -0
  22. {voly-0.0.179 → voly-0.0.181}/src/voly/utils/logger.py +0 -0
  23. {voly-0.0.179 → voly-0.0.181}/src/voly.egg-info/SOURCES.txt +0 -0
  24. {voly-0.0.179 → voly-0.0.181}/src/voly.egg-info/dependency_links.txt +0 -0
  25. {voly-0.0.179 → voly-0.0.181}/src/voly.egg-info/requires.txt +0 -0
  26. {voly-0.0.179 → voly-0.0.181}/src/voly.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: voly
3
- Version: 0.0.179
3
+ Version: 0.0.181
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.179"
7
+ version = "0.0.181"
8
8
  description = "Options & volatility research package"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -60,7 +60,7 @@ line_length = 100
60
60
  multi_line_output = 3
61
61
 
62
62
  [tool.mypy]
63
- python_version = "0.0.179"
63
+ python_version = "0.0.181"
64
64
  warn_return_any = true
65
65
  warn_unused_configs = true
66
66
  disallow_untyped_defs = true
@@ -165,14 +165,12 @@ class VolyClient:
165
165
  # -------------------------------------------------------------------------
166
166
 
167
167
  @staticmethod
168
- def fit_model(option_chain: pd.DataFrame,
169
- domain_params: Tuple[float, float, int] = (-2, 2, 1000)) -> pd.DataFrame:
168
+ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
170
169
  """
171
170
  Fit a volatility model to market data using the improved SVI approach.
172
171
 
173
172
  Parameters:
174
173
  - option_chain: DataFrame with option market data
175
- - domain_params: Tuple of (min, max, num_points) for the log-moneyness grid
176
174
 
177
175
  Returns:
178
176
  - DataFrame with fit results including arbitrage checks
@@ -181,8 +179,7 @@ class VolyClient:
181
179
 
182
180
  # Fit the model
183
181
  fit_results = fit_model(
184
- option_chain=option_chain,
185
- domain_params=domain_params
182
+ option_chain=option_chain
186
183
  )
187
184
 
188
185
  return fit_results
@@ -19,14 +19,12 @@ warnings.filterwarnings("ignore")
19
19
 
20
20
 
21
21
  @catch_exception
22
- def fit_model(option_chain: pd.DataFrame,
23
- domain_params: Tuple[float, float, int] = (-2, 2, 1000)) -> pd.DataFrame:
22
+ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
24
23
  """
25
24
  Fit a volatility model to market data.
26
25
 
27
26
  Parameters:
28
27
  - option_chain: DataFrame with market data
29
- - domain_params: Tuple of (min, max, num_points) for the log-moneyness grid
30
28
 
31
29
  Returns:
32
30
  - DataFrame with all fit results and performance metrics as columns, maturity_names as index
@@ -130,7 +128,7 @@ def fit_model(option_chain: pd.DataFrame,
130
128
  usd_min_strike = np.exp(log_min_strike) * s
131
129
 
132
130
  # Butterfly arbitrage check
133
- k_range = np.linspace(min(k), max(k), domain_params[2])
131
+ k_range = np.linspace(min(k), max(k), 200)
134
132
  w_k = lambda k: SVIModel.svi(k, a_scaled, b_scaled, m, rho, sigma)
135
133
  w_prime = lambda k: b_scaled * (rho + (k - m) / np.sqrt((k - m) ** 2 + sigma ** 2))
136
134
  w_double_prime = lambda k: b_scaled * sigma ** 2 / ((k - m) ** 2 + sigma ** 2) ** (3 / 2)
@@ -147,7 +145,7 @@ def fit_model(option_chain: pd.DataFrame,
147
145
  # Log result
148
146
  status = f'{GREEN}SUCCESS{RESET}' if not np.isnan(params[0]) else f'{RED}FAILED{RESET}'
149
147
  logger.info(f'Optimization for {maturity_name}: {status}')
150
- logger.info("=================================================================")
148
+ logger.info("================================================")
151
149
 
152
150
  results_data['s'].append(float(s))
153
151
  results_data['u'].append(float(u))
@@ -191,7 +189,7 @@ def fit_model(option_chain: pd.DataFrame,
191
189
 
192
190
  # Calendar arbitrage check (pre-correction)
193
191
  logger.info("\nChecking calendar arbitrage (pre-correction)...")
194
- k_grid = np.linspace(domain_params[0], domain_params[1], domain_params[2])
192
+ k_grid = np.linspace(-2, 2, 200)
195
193
  sorted_maturities = sorted(params_dict.keys(), key=lambda x: params_dict[x][0])
196
194
  calendar_arbitrage_free = True
197
195
 
@@ -211,7 +209,7 @@ def fit_model(option_chain: pd.DataFrame,
211
209
  k_market = np.log(K / s)
212
210
  mask = ~np.isnan(k_market)
213
211
  k_check = np.unique(
214
- np.concatenate([k_market[mask], np.linspace(min(k_market[mask]), max(k_market[mask]), domain_params[2])]))
212
+ np.concatenate([k_market[mask], np.linspace(min(k_market[mask]), max(k_market[mask]), 200)]))
215
213
 
216
214
  for k_val in k_check:
217
215
  w1 = SVIModel.svi(k_val, a1 * t1, b1 * t1, m1, rho1, sigma1)
@@ -281,7 +279,7 @@ def fit_model(option_chain: pd.DataFrame,
281
279
 
282
280
  # Update butterfly arbitrage check
283
281
  butterfly_arbitrage_free = True
284
- k_range = np.linspace(min(k), max(k), domain_params[2])
282
+ k_range = np.linspace(min(k), max(k), 200)
285
283
  w_k = lambda k: SVIModel.svi(k, a_scaled, b_scaled, m, rho, sigma)
286
284
  w_prime = lambda k: b_scaled * (rho + (k - m) / np.sqrt((k - m) ** 2 + sigma ** 2))
287
285
  w_double_prime = lambda k: b_scaled * sigma ** 2 / ((k - m) ** 2 + sigma ** 2) ** (3 / 2)
@@ -341,7 +339,7 @@ def fit_model(option_chain: pd.DataFrame,
341
339
  k_market = np.log(K / s)
342
340
  mask = ~np.isnan(k_market)
343
341
  k_check = np.unique(np.concatenate(
344
- [k_market[mask], np.linspace(min(k_market[mask]), max(k_market[mask]), domain_params[2])]))
342
+ [k_market[mask], np.linspace(min(k_market[mask]), max(k_market[mask]), 200)]))
345
343
 
346
344
  for k_val in k_check:
347
345
  w1 = SVIModel.svi(k_val, a1 * t1, b1 * t1, m1, rho1, sigma1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: voly
3
- Version: 0.0.179
3
+ Version: 0.0.181
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
File without changes