voly 0.0.196__py3-none-any.whl → 0.0.197__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 +9 -9
- {voly-0.0.196.dist-info → voly-0.0.197.dist-info}/METADATA +1 -1
- {voly-0.0.196.dist-info → voly-0.0.197.dist-info}/RECORD +6 -6
- {voly-0.0.196.dist-info → voly-0.0.197.dist-info}/WHEEL +0 -0
- {voly-0.0.196.dist-info → voly-0.0.197.dist-info}/licenses/LICENSE +0 -0
- {voly-0.0.196.dist-info → voly-0.0.197.dist-info}/top_level.txt +0 -0
voly/core/fit.py
CHANGED
@@ -120,7 +120,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
|
|
120
120
|
nu, psi, p, c, nu_tilde = SVIModel.raw_to_jw_params(a_scaled, b_scaled, m, rho, sigma, t)
|
121
121
|
|
122
122
|
# Compute fit statistics
|
123
|
-
w_model = np.array([SVIModel.
|
123
|
+
w_model = np.array([SVIModel.svi(x, a_scaled, b_scaled, m, rho, sigma) for x in k])
|
124
124
|
iv_model = np.sqrt(w_model / t)
|
125
125
|
iv_market = iv
|
126
126
|
rmse = np.sqrt(mean_squared_error(iv_market, iv_model))
|
@@ -134,7 +134,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
|
|
134
134
|
|
135
135
|
# Butterfly arbitrage check
|
136
136
|
k_range = np.linspace(min(k), max(k), num_points)
|
137
|
-
w_k = lambda k: SVIModel.
|
137
|
+
w_k = lambda k: SVIModel.svi(k, a_scaled, b_scaled, m, rho, sigma)
|
138
138
|
w_prime = lambda k: b_scaled * (rho + (k - m) / np.sqrt((k - m)**2 + sigma**2))
|
139
139
|
w_double_prime = lambda k: b_scaled * sigma**2 / ((k - m)**2 + sigma**2)**(3/2)
|
140
140
|
for k_val in k_range:
|
@@ -221,8 +221,8 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
|
|
221
221
|
k_check = np.unique(np.concatenate([k_market[mask], np.linspace(min(k_market[mask]), max(k_market[mask]), num_points)]))
|
222
222
|
|
223
223
|
for k_val in k_check:
|
224
|
-
w1 = SVIModel.
|
225
|
-
w2 = SVIModel.
|
224
|
+
w1 = SVIModel.svi(k_val, a1 * t1, b1 * t1, m1, rho1, sigma1)
|
225
|
+
w2 = SVIModel.svi(k_val, a2 * t2, b2 * t2, m2, rho2, sigma2)
|
226
226
|
if w2 < w1 - 1e-6:
|
227
227
|
logger.warning(f"Calendar arbitrage violation at t1={t1:.4f}, t2={t2:.4f}, k={k_val:.4f}: w1={w1:.6f}, w2={w2:.6f}")
|
228
228
|
calendar_arbitrage_free = False
|
@@ -264,7 +264,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
|
|
264
264
|
nu, psi, p, c, nu_tilde = SVIModel.raw_to_jw_params(a_scaled, b_scaled, sigma, rho, m, t2)
|
265
265
|
|
266
266
|
# Recompute fit statistics
|
267
|
-
w_model = np.array([SVIModel.
|
267
|
+
w_model = np.array([SVIModel.svi(x, a_scaled, b_scaled, m, rho, sigma) for x in k])
|
268
268
|
iv_model = np.sqrt(w_model / t2)
|
269
269
|
iv_market = iv
|
270
270
|
rmse = np.sqrt(mean_squared_error(iv_market, iv_model))
|
@@ -279,7 +279,7 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
|
|
279
279
|
# Update butterfly arbitrage check
|
280
280
|
butterfly_arbitrage_free = True
|
281
281
|
k_range = np.linspace(min(k), max(k), num_points)
|
282
|
-
w_k = lambda k: SVIModel.
|
282
|
+
w_k = lambda k: SVIModel.svi(k, a_scaled, b_scaled, m, rho, sigma)
|
283
283
|
w_prime = lambda k: b_scaled * (rho + (k - m) / np.sqrt((k - m)**2 + sigma**2))
|
284
284
|
w_double_prime = lambda k: b_scaled * sigma**2 / ((k - m)**2 + sigma**2)**(3/2)
|
285
285
|
for k_val in k_range:
|
@@ -333,8 +333,8 @@ def fit_model(option_chain: pd.DataFrame, num_points: int = 2000) -> Tuple[pd.Da
|
|
333
333
|
k_check = np.unique(np.concatenate([k_market[mask], np.linspace(min(k_market[mask]), max(k_market[mask]), num_points)]))
|
334
334
|
|
335
335
|
for k_val in k_check:
|
336
|
-
w1 = SVIModel.
|
337
|
-
w2 = SVIModel.
|
336
|
+
w1 = SVIModel.svi(k_val, a1 * t1, b1 * t1, m1, rho1, sigma1)
|
337
|
+
w2 = SVIModel.svi(k_val, a2 * t2, b2 * t2, m2, rho2, sigma2)
|
338
338
|
if w2 < w1 - 1e-6:
|
339
339
|
logger.warning(f"Calendar arbitrage violation at t1={t1:.4f}, t2={t2:.4f}, k={k_val:.4f}: w1={w1:.6f}, w2={w2:.6f}")
|
340
340
|
calendar_arbitrage_free = False
|
@@ -401,7 +401,7 @@ def get_iv_surface(model_results: pd.DataFrame,
|
|
401
401
|
r = model_results.loc[i, 'r'] if 'r' in model_results.columns else 0
|
402
402
|
|
403
403
|
# Calculate implied volatility
|
404
|
-
w = np.array([SVIModel.
|
404
|
+
w = np.array([SVIModel.svi(x, *params) for x in LM])
|
405
405
|
o = np.sqrt(w / t)
|
406
406
|
iv_surface[i] = o
|
407
407
|
|
@@ -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=
|
9
|
+
voly/core/fit.py,sha256=vRLZapQ9eXHmcX-3gA8qqyZ0A7bfZFNyshDU1Gw3JAc,17381
|
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.197.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
17
|
+
voly-0.0.197.dist-info/METADATA,sha256=wgvlUhL9lB0LlHvmgoBhyuL1btUhjP-EEJnKmXphxPY,4115
|
18
|
+
voly-0.0.197.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
|
19
|
+
voly-0.0.197.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
20
|
+
voly-0.0.197.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|