voly 0.0.249__py3-none-any.whl → 0.0.251__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 +11 -12
- {voly-0.0.249.dist-info → voly-0.0.251.dist-info}/METADATA +1 -1
- {voly-0.0.249.dist-info → voly-0.0.251.dist-info}/RECORD +6 -6
- {voly-0.0.249.dist-info → voly-0.0.251.dist-info}/WHEEL +0 -0
- {voly-0.0.249.dist-info → voly-0.0.251.dist-info}/licenses/LICENSE +0 -0
- {voly-0.0.249.dist-info → voly-0.0.251.dist-info}/top_level.txt +0 -0
voly/core/fit.py
CHANGED
@@ -67,8 +67,7 @@ class SVICalibrator:
|
|
67
67
|
def filter_market_data(self, group):
|
68
68
|
"""Filter and prepare market data"""
|
69
69
|
# Filter for call options only
|
70
|
-
group = group[group['
|
71
|
-
group['log_moneyness'] = np.log(group['strikes'] / group['spot_price'].iloc[0])
|
70
|
+
group = group[group['option_type'] == 'C']
|
72
71
|
|
73
72
|
# Handle duplicated IVs by keeping the row closest to log_moneyness=0
|
74
73
|
duplicated_iv = group[group.duplicated('mark_iv', keep=False)]
|
@@ -150,7 +149,7 @@ class SVICalibrator:
|
|
150
149
|
result = self.failed_calibration(expiry, maturity, t, len(k))
|
151
150
|
logger.error(f'\033[31mFAILED\033[0m for {maturity} (insufficient data points)')
|
152
151
|
self.update_results(result)
|
153
|
-
return
|
152
|
+
return expiry
|
154
153
|
|
155
154
|
# Perform SVI fitting
|
156
155
|
params, loss = SVIModel.fit(tiv=w, vega=vega, k=k, tau=t)
|
@@ -160,10 +159,10 @@ class SVICalibrator:
|
|
160
159
|
result = self.failed_calibration(expiry, maturity, t, len(k))
|
161
160
|
logger.error(f'\033[31mFAILED\033[0m for {maturity}')
|
162
161
|
self.update_results(result)
|
163
|
-
return
|
162
|
+
return expiry
|
164
163
|
|
165
164
|
# Successful fitting
|
166
|
-
self.params_dict[
|
165
|
+
self.params_dict[expiry] = (t, params)
|
167
166
|
|
168
167
|
# Calculate all model statistics
|
169
168
|
stats = self.calculate_model_stats(params, t, k, iv)
|
@@ -185,7 +184,7 @@ class SVICalibrator:
|
|
185
184
|
logger.info(f'\033[32mSUCCESS\033[0m for {maturity}')
|
186
185
|
|
187
186
|
self.update_results(result)
|
188
|
-
return
|
187
|
+
return expiry
|
189
188
|
|
190
189
|
def update_results(self, result_row):
|
191
190
|
"""Update results data dictionary"""
|
@@ -211,7 +210,7 @@ class SVICalibrator:
|
|
211
210
|
# Create results DataFrame and mapping for updates
|
212
211
|
fit_results = pd.DataFrame(self.results_data, index=self.results_data['maturity'])
|
213
212
|
fit_results = fit_results.sort_values(by='t')
|
214
|
-
|
213
|
+
maturities_dict = {row['expiry']: idx for idx, row in fit_results.iterrows()}
|
215
214
|
|
216
215
|
# Check for calendar arbitrage
|
217
216
|
sorted_maturities = sorted(self.params_dict.keys(), key=lambda x: self.params_dict[x][0])
|
@@ -221,11 +220,11 @@ class SVICalibrator:
|
|
221
220
|
|
222
221
|
# Update calendar arbitrage status
|
223
222
|
for mat in sorted_maturities:
|
224
|
-
mat_name =
|
223
|
+
mat_name = maturities_dict[mat]
|
225
224
|
fit_results.at[mat_name, 'calendar_arbitrage_free'] = calendar_arbitrage_free
|
226
225
|
|
227
226
|
# Correct calendar arbitrage violations
|
228
|
-
self.correct_calendar_arbitrage(sorted_maturities, fit_results,
|
227
|
+
self.correct_calendar_arbitrage(sorted_maturities, fit_results, maturities_dict)
|
229
228
|
|
230
229
|
# Clean up results and report execution time
|
231
230
|
fit_results = fit_results.drop(columns='maturity')
|
@@ -234,7 +233,7 @@ class SVICalibrator:
|
|
234
233
|
|
235
234
|
return fit_results
|
236
235
|
|
237
|
-
def correct_calendar_arbitrage(self, sorted_maturities, fit_results,
|
236
|
+
def correct_calendar_arbitrage(self, sorted_maturities, fit_results, maturities_dict):
|
238
237
|
"""Handle calendar arbitrage corrections"""
|
239
238
|
for i in range(1, len(sorted_maturities)):
|
240
239
|
mat2 = sorted_maturities[i]
|
@@ -260,7 +259,7 @@ class SVICalibrator:
|
|
260
259
|
|
261
260
|
# Calculate new stats and update results
|
262
261
|
stats = self.calculate_model_stats(new_params, t2, k, iv)
|
263
|
-
mat2_name =
|
262
|
+
mat2_name = maturities_dict[mat2]
|
264
263
|
|
265
264
|
# Update all stats at once
|
266
265
|
for key, value in stats.items():
|
@@ -274,7 +273,7 @@ class SVICalibrator:
|
|
274
273
|
|
275
274
|
# Update final status
|
276
275
|
for mat in sorted_maturities:
|
277
|
-
mat_name =
|
276
|
+
mat_name = maturities_dict[mat]
|
278
277
|
fit_results.at[mat_name, 'calendar_arbitrage_free'] = calendar_arbitrage_free
|
279
278
|
|
280
279
|
|
@@ -6,15 +6,15 @@ voly/models.py,sha256=CGJQr13Uie7iwtx2hjViN9lMXeRN_uOqzp4u8NPaTlA,9282
|
|
6
6
|
voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
|
7
7
|
voly/core/charts.py,sha256=6MSU0z01fPOVSssodxdnFqchzDfupSmXq_e71WwDmVQ,12635
|
8
8
|
voly/core/data.py,sha256=A0zrIjg-pf3mG28UR313Bc57h74G5smWCVBB7vysM_4,13527
|
9
|
-
voly/core/fit.py,sha256=
|
9
|
+
voly/core/fit.py,sha256=diRCAqBURekXa0SYLFKb8HOT3xS611YUQvUDiwbar3c,13929
|
10
10
|
voly/core/hd.py,sha256=dSv197RmSWFWbRRdoBzMrD_poT7ZiJ8hdD_wKE-Li_M,13559
|
11
11
|
voly/core/interpolate.py,sha256=GAkrqaar7A0D6UMipXQUp4vSHRfb44TmCG5Xiv9elXg,5176
|
12
12
|
voly/core/rnd.py,sha256=wiZ5OIjPDf1Th5_sQ9CZG5JgAo3EL8f63T_Rj1_VP-0,13214
|
13
13
|
voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
|
14
14
|
voly/utils/density.py,sha256=ONpRli-IaJDgOZ2sb27HHFc9_tkkGSATKl94JODd86A,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.251.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
17
|
+
voly-0.0.251.dist-info/METADATA,sha256=uiYM2x3Kro8MEb_TKqQsdCFQ-mZ_GPRK8siP15v_xa4,4115
|
18
|
+
voly-0.0.251.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
19
|
+
voly-0.0.251.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
20
|
+
voly-0.0.251.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|