voly 0.0.199__py3-none-any.whl → 0.0.200__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/core/fit.py CHANGED
@@ -71,6 +71,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
71
71
  maturity_data_groups = option_chain.groupby('maturity_date')
72
72
  params_dict = {}
73
73
  results_data = {col: [] for col in column_dtypes.keys()}
74
+ results_data['maturity_name'] = []
74
75
 
75
76
  def process_maturity(maturity, maturity_data):
76
77
  """Process single maturity for SVI calibration."""
@@ -94,6 +95,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
94
95
  # Combine cleaned duplicates and unique rows
95
96
  maturity_data = pd.concat([unique_iv, cleaned_duplicated_iv])
96
97
  maturity_date = maturity_data['maturity_date'].iloc[0]
98
+ maturity_name = maturity_data['maturity_name'].iloc[0]
97
99
 
98
100
  t = maturity_data['t'].iloc[0]
99
101
  K = maturity_data['strikes'].values
@@ -155,6 +157,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
155
157
  results_data['s'].append(float(s))
156
158
  results_data['t'].append(float(t))
157
159
  results_data['maturity_date'].append(maturity_date)
160
+ results_data['maturity_name'].append(maturity_name)
158
161
  results_data['a'].append(float(a_scaled) if not np.isnan(params[0]) else np.nan)
159
162
  results_data['b'].append(float(b_scaled) if not np.isnan(params[0]) else np.nan)
160
163
  results_data['m'].append(float(m))
@@ -177,7 +180,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
177
180
  results_data['loss'].append(float(loss))
178
181
  results_data['n_points'].append(int(len(k)))
179
182
 
180
- return maturity_date
183
+ return maturity_name
181
184
 
182
185
  # Parallel processing of maturities
183
186
  with ThreadPoolExecutor() as executor:
@@ -187,7 +190,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
187
190
  future.result()
188
191
 
189
192
  # Create results DataFrame
190
- results_df = pd.DataFrame(results_data, index=results_data['maturity_date'])
193
+ results_df = pd.DataFrame(results_data, index=results_data['maturity_name'])
191
194
 
192
195
  # Convert columns to appropriate types
193
196
  for col, dtype in column_dtypes.items():
@@ -234,7 +237,6 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
234
237
  results_df.at[mat, 'calendar_arbitrage_free'] = calendar_arbitrage_free
235
238
 
236
239
  # Calendar arbitrage correction
237
- start_correction = time.time()
238
240
  for i in range(1, len(sorted_maturities)):
239
241
  mat2 = sorted_maturities[i]
240
242
  mat1 = sorted_maturities[i - 1]
@@ -309,12 +311,8 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
309
311
  results_df.at[mat2, 'usd_min_strike'] = float(usd_min_strike)
310
312
  results_df.at[mat2, 'butterfly_arbitrage_free'] = butterfly_arbitrage_free
311
313
  results_df.at[mat2, 'fit_success'] = bool(not np.isnan(a))
312
- end_correction = time.time()
313
- logger.info(f"Calendar arbitrage correction completed in {end_correction - start_correction:.4f} seconds")
314
314
 
315
315
  # Calendar arbitrage check (post-correction)
316
- logger.info("\nChecking calendar arbitrage (post-correction)...")
317
- start_post_check = time.time()
318
316
  calendar_arbitrage_free = True
319
317
  for i in range(len(sorted_maturities) - 1):
320
318
  mat1, mat2 = sorted_maturities[i], sorted_maturities[i + 1]
@@ -341,15 +339,13 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
341
339
  break
342
340
  if not calendar_arbitrage_free:
343
341
  break
344
- end_post_check = time.time()
345
- logger.info(f"Post-correction calendar arbitrage check completed in {end_post_check - start_post_check:.4f} seconds")
346
342
 
347
343
  for mat in sorted_maturities:
348
344
  results_df.at[mat, 'calendar_arbitrage_free'] = calendar_arbitrage_free
349
345
 
350
346
  # End overall timer and print total time
351
347
  end_total = time.time()
352
- logger.info(f"\nTotal execution time for fit_model: {end_total - start_total:.4f} seconds")
348
+ logger.info(f"Total execution time for the model: {end_total - start_total:.4f} seconds")
353
349
 
354
350
  logger.info("Model fitting complete.")
355
351
  return results_df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: voly
3
- Version: 0.0.199
3
+ Version: 0.0.200
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -6,15 +6,15 @@ voly/models.py,sha256=Wop6gZbvAOXSmI0JpYapjVSeJub_i8RLif2PzxRsfFE,7185
6
6
  voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
7
7
  voly/core/charts.py,sha256=2S-BfCo30aj1_xlNLqF-za5rQWxF_mWKIdtdOe5bgbw,12735
8
8
  voly/core/data.py,sha256=9v9iuE2XdIIlzoRAB7q1ol7YghBzBsPGAiwZ11oDuis,13650
9
- voly/core/fit.py,sha256=fK-mgmfRZGQXssSVG0UE6rxy-8YQ43sEheyy2LybsRM,17347
9
+ voly/core/fit.py,sha256=qWs7rce9QcC7CDlB4PVi1fIfH5PmShwPWcKH_8N46_A,17068
10
10
  voly/core/hd.py,sha256=UFAyLncNUHivpPAcko6IK1bC55mudVtdlRFfXp63HXE,14771
11
11
  voly/core/interpolate.py,sha256=JkK172-FXyhesW3hY4pEeuJWG3Bugq7QZXbeKoRpLuo,5305
12
12
  voly/core/rnd.py,sha256=GoC3m1Q46Wnk5tV_mstr-3_aktHeue6BBLh4DQTciW0,13307
13
13
  voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
14
14
  voly/utils/density.py,sha256=q0fX4im9TGwMCZ32Hzdv8CNh56KnJo8bmG5w0gVWZH8,5879
15
15
  voly/utils/logger.py,sha256=4-_2bVJmq17Q0d7Rd2mPg1AeR8gxv6EPvcmBDMFWcSM,1744
16
- voly-0.0.199.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
17
- voly-0.0.199.dist-info/METADATA,sha256=7xLOBjmGlVBTpdZJenrGjbVjM5KJ3zU2LPD7Iz8Qo0k,4115
18
- voly-0.0.199.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
19
- voly-0.0.199.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
20
- voly-0.0.199.dist-info/RECORD,,
16
+ voly-0.0.200.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
17
+ voly-0.0.200.dist-info/METADATA,sha256=AT0HE9o9XQccEK1nuOdAh2kRMLuk1E_4e7o7-kEUQRg,4115
18
+ voly-0.0.200.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
19
+ voly-0.0.200.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
20
+ voly-0.0.200.dist-info/RECORD,,
File without changes