voly 0.0.189__py3-none-any.whl → 0.0.191__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 +1 -1
- voly/core/fit.py +23 -24
- {voly-0.0.189.dist-info → voly-0.0.191.dist-info}/METADATA +1 -1
- {voly-0.0.189.dist-info → voly-0.0.191.dist-info}/RECORD +7 -7
- {voly-0.0.189.dist-info → voly-0.0.191.dist-info}/WHEEL +0 -0
- {voly-0.0.189.dist-info → voly-0.0.191.dist-info}/licenses/LICENSE +0 -0
- {voly-0.0.189.dist-info → voly-0.0.191.dist-info}/top_level.txt +0 -0
voly/client.py
CHANGED
@@ -175,7 +175,7 @@ class VolyClient:
|
|
175
175
|
Returns:
|
176
176
|
- DataFrame with fit results including arbitrage checks
|
177
177
|
"""
|
178
|
-
logger.info(f"Fitting
|
178
|
+
logger.info(f"Fitting model to market data")
|
179
179
|
|
180
180
|
# Fit the model
|
181
181
|
fit_results = fit_model(
|
voly/core/fit.py
CHANGED
@@ -94,6 +94,7 @@ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
|
|
94
94
|
maturity_data = pd.concat([unique_iv, cleaned_duplicated_iv])
|
95
95
|
maturity_date = maturity_data['maturity_date'].iloc[0]
|
96
96
|
|
97
|
+
|
97
98
|
t = group['t'].iloc[0]
|
98
99
|
K = group['strikes'].values
|
99
100
|
iv = group['mark_iv'].values
|
@@ -103,8 +104,6 @@ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
|
|
103
104
|
mask = ~np.isnan(w) & ~np.isnan(vega) & ~np.isnan(k) & (iv >= 0)
|
104
105
|
k, w, vega, iv = k[mask], w[mask], vega[mask], iv[mask]
|
105
106
|
|
106
|
-
logger.info(f"Processing maturity {maturity}, points after filtering: {len(k)}")
|
107
|
-
|
108
107
|
params = [np.nan] * 5
|
109
108
|
loss = np.inf
|
110
109
|
nu = psi = p = c = nu_tilde = np.nan
|
@@ -155,7 +154,6 @@ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
|
|
155
154
|
GREEN, RED, RESET = '\033[32m', '\033[31m', '\033[0m'
|
156
155
|
status = f'{GREEN}SUCCESS{RESET}' if not np.isnan(params[0]) else f'{RED}FAILED{RESET}'
|
157
156
|
logger.info(f'Optimization for {maturity}: {status}')
|
158
|
-
logger.info("================================================")
|
159
157
|
|
160
158
|
# Store results
|
161
159
|
results_data['s'].append(float(s))
|
@@ -211,7 +209,6 @@ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
|
|
211
209
|
results_df = results_df.sort_values(by='t')
|
212
210
|
|
213
211
|
# Calendar arbitrage check (pre-correction) with timer
|
214
|
-
logger.info("\nChecking calendar arbitrage (pre-correction)...")
|
215
212
|
k_grid = np.linspace(-2, 2, num_points)
|
216
213
|
sorted_maturities = sorted(params_dict.keys(), key=lambda x: params_dict[x][0])
|
217
214
|
calendar_arbitrage_free = True
|
@@ -245,7 +242,7 @@ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
|
|
245
242
|
results_df.at[mat, 'calendar_arbitrage_free'] = calendar_arbitrage_free
|
246
243
|
|
247
244
|
# Calendar arbitrage correction with timer
|
248
|
-
logger.info("
|
245
|
+
logger.info("Performing calendar arbitrage correction...")
|
249
246
|
for i in range(1, len(sorted_maturities)):
|
250
247
|
mat2 = sorted_maturities[i]
|
251
248
|
mat1 = sorted_maturities[i - 1]
|
@@ -304,24 +301,26 @@ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
|
|
304
301
|
butterfly_arbitrage_free = False
|
305
302
|
break
|
306
303
|
|
307
|
-
results_df
|
308
|
-
|
309
|
-
results_df.
|
310
|
-
results_df.
|
311
|
-
results_df.
|
312
|
-
results_df.
|
313
|
-
results_df.
|
314
|
-
results_df.
|
315
|
-
results_df.
|
316
|
-
results_df.
|
317
|
-
results_df.
|
318
|
-
results_df.
|
319
|
-
results_df.
|
320
|
-
results_df.
|
321
|
-
results_df.
|
322
|
-
results_df.
|
323
|
-
results_df.
|
324
|
-
results_df.
|
304
|
+
# Update results_df using maturity_name
|
305
|
+
mat_name = group['maturity_name'].iloc[0]
|
306
|
+
results_df.loc[mat_name, 'a'] = float(a_scaled)
|
307
|
+
results_df.loc[mat_name, 'b'] = float(b_scaled)
|
308
|
+
results_df.loc[mat_name, 'm'] = float(m)
|
309
|
+
results_df.loc[mat_name, 'rho'] = float(rho)
|
310
|
+
results_df.loc[mat_name, 'sigma'] = float(sigma)
|
311
|
+
results_df.loc[mat_name, 'nu'] = float(nu)
|
312
|
+
results_df.loc[mat_name, 'psi'] = float(psi)
|
313
|
+
results_df.loc[mat_name, 'p'] = float(p)
|
314
|
+
results_df.loc[mat_name, 'c'] = float(c)
|
315
|
+
results_df.loc[mat_name, 'nu_tilde'] = float(nu_tilde)
|
316
|
+
results_df.loc[mat_name, 'rmse'] = float(rmse)
|
317
|
+
results_df.loc[mat_name, 'mae'] = float(mae)
|
318
|
+
results_df.loc[mat_name, 'r2'] = float(r2)
|
319
|
+
results_df.loc[mat_name, 'max_error'] = float(max_error)
|
320
|
+
results_df.loc[mat_name, 'log_min_strike'] = float(log_min_strike)
|
321
|
+
results_df.loc[mat_name, 'usd_min_strike'] = float(usd_min_strike)
|
322
|
+
results_df.loc[mat_name, 'butterfly_arbitrage_free'] = butterfly_arbitrage_free
|
323
|
+
results_df.loc[mat_name, 'fit_success'] = bool(not np.isnan(a))
|
325
324
|
|
326
325
|
# Calendar arbitrage check (post-correction)
|
327
326
|
calendar_arbitrage_free = True
|
@@ -357,7 +356,7 @@ def fit_model(option_chain: pd.DataFrame) -> pd.DataFrame:
|
|
357
356
|
|
358
357
|
# End overall timer and print total time
|
359
358
|
end_total = time.time()
|
360
|
-
logger.info(f"
|
359
|
+
logger.info(f"Total execution time for model fit: {end_total - start_total:.4f} seconds")
|
361
360
|
|
362
361
|
logger.info("Model fitting complete.")
|
363
362
|
return results_df
|
@@ -1,20 +1,20 @@
|
|
1
1
|
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
2
|
-
voly/client.py,sha256=
|
2
|
+
voly/client.py,sha256=0kp2_I-imcJ6uxMcvS0BipS2PgWdFaCPZG5335Vg75Q,14383
|
3
3
|
voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
|
4
4
|
voly/formulas.py,sha256=JnEs6G0wlfRNH6X_YEJMe2RtLH-ryhzufjsim73Bj3c,11176
|
5
5
|
voly/models.py,sha256=2aNGsF3joCx4jGbiF8m0zxEW_nvcSBERSYPSKCXV3us,7019
|
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=
|
9
|
+
voly/core/fit.py,sha256=edpcBPxM7PQMaZHJbxfTDaoiWfhIuS7MSubQthYBhO0,17173
|
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.
|
17
|
-
voly-0.0.
|
18
|
-
voly-0.0.
|
19
|
-
voly-0.0.
|
20
|
-
voly-0.0.
|
16
|
+
voly-0.0.191.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
17
|
+
voly-0.0.191.dist-info/METADATA,sha256=RFgevmqNE4J7TvqFEW_83-nxgMW0mdF7GAT2sKVNC3k,4115
|
18
|
+
voly-0.0.191.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
19
|
+
voly-0.0.191.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
20
|
+
voly-0.0.191.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|