voly 0.0.219__py3-none-any.whl → 0.0.221__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 CHANGED
@@ -250,13 +250,16 @@ class VolyClient:
250
250
  # Plot fit statistics
251
251
  plots['fit_performance'] = plot_fit_performance(fit_results)
252
252
 
253
- # Plot 3D surface
254
- plots['surface_3d'] = plot_3d_surface(
255
- x_surface=x_surface,
256
- iv_surface=iv_surface,
257
- fit_results=fit_results,
258
- return_domain=return_domain
259
- )
253
+ if return_domain != 'delta':
254
+ # Plot 3D surface
255
+ plots['surface_3d'] = plot_3d_surface(
256
+ x_surface=x_surface,
257
+ iv_surface=iv_surface,
258
+ fit_results=fit_results,
259
+ return_domain=return_domain
260
+ )
261
+ else:
262
+ pass
260
263
 
261
264
  return plots
262
265
 
voly/core/hd.py CHANGED
@@ -164,13 +164,8 @@ def calculate_normal_hd(df_hist: pd.DataFrame,
164
164
  mu_scaled = np.mean(scaled_returns)
165
165
  sigma_scaled = np.std(scaled_returns)
166
166
 
167
- # Apply Girsanov adjustment to shift to risk-neutral measure
168
- expected_risk_neutral_mean = (r - 0.5 * sigma_scaled ** 2) * np.sqrt(t)
169
- adjustment = mu_scaled - expected_risk_neutral_mean
170
- mu_rn = mu_scaled - adjustment
171
-
172
167
  # Calculate PDF using normal distribution in log-moneyness domain
173
- pdf_lm = stats.norm.pdf(LM, loc=mu_rn, scale=sigma_scaled)
168
+ pdf_lm = stats.norm.pdf(LM, loc=mu_scaled, scale=sigma_scaled)
174
169
 
175
170
  # Normalize the PDF
176
171
  pdf_lm = normalize_density(pdf_lm, dx)
@@ -230,11 +225,6 @@ def calculate_student_t_hd(df_hist: pd.DataFrame,
230
225
  else:
231
226
  df = 5 # Default value if kurtosis calculation fails
232
227
 
233
- # Apply Girsanov adjustment to shift to risk-neutral measure
234
- expected_risk_neutral_mean = (r - 0.5 * sigma_scaled ** 2) * np.sqrt(t)
235
- adjustment = mu_scaled - expected_risk_neutral_mean
236
- mu_rn = mu_scaled - adjustment
237
-
238
228
  # Scale parameter for t-distribution
239
229
  # In scipy's t-distribution, the scale parameter is different from normal std
240
230
  # For t-distribution: variance = (df/(df-2)) * scale^2
@@ -242,7 +232,7 @@ def calculate_student_t_hd(df_hist: pd.DataFrame,
242
232
  scale = sigma_scaled * np.sqrt((df - 2) / df) if df > 2 else sigma_scaled
243
233
 
244
234
  # Calculate PDF using t-distribution in log-moneyness domain
245
- pdf_lm = student_t.pdf(LM, df=df, loc=mu_rn, scale=scale)
235
+ pdf_lm = student_t.pdf(LM, df=df, loc=mu_scaled, scale=scale)
246
236
 
247
237
  # Normalize the PDF
248
238
  pdf_lm = normalize_density(pdf_lm, dx)
@@ -287,19 +277,8 @@ def calculate_kde_hd(df_hist: pd.DataFrame,
287
277
  # Get scaled returns
288
278
  scaled_returns, dte_returns = calculate_historical_returns(df_hist, n_periods)
289
279
 
290
- # Calculate parameters (for Girsanov adjustment)
291
- mu_scaled = np.mean(scaled_returns)
292
- sigma_scaled = np.std(scaled_returns)
293
-
294
- # Apply Girsanov adjustment to shift to risk-neutral measure
295
- expected_risk_neutral_mean = (r - 0.5 * sigma_scaled ** 2) * np.sqrt(t)
296
- adjustment = mu_scaled - expected_risk_neutral_mean
297
-
298
- # Shift the returns to be risk-neutral
299
- rn_returns = scaled_returns - adjustment + expected_risk_neutral_mean
300
-
301
280
  # Fit KDE model using scipy's gaussian_kde with Scott's rule for bandwidth
302
- kde = stats.gaussian_kde(rn_returns, bw_method='scott')
281
+ kde = stats.gaussian_kde(scaled_returns, bw_method='scott')
303
282
 
304
283
  # Evaluate KDE at points in log-moneyness domain
305
284
  pdf_lm = kde(LM)
voly/core/interpolate.py CHANGED
@@ -29,7 +29,6 @@ def interpolate_model(fit_results: pd.DataFrame,
29
29
  Returns:
30
30
  - DataFrame with interpolated model parameters for the specified days
31
31
  """
32
- logger.info(f"Interpolating model parameters using {method} method")
33
32
 
34
33
  # Check if fit_results is valid
35
34
  if fit_results is None or fit_results.empty:
@@ -68,7 +67,7 @@ def interpolate_model(fit_results: pd.DataFrame,
68
67
  "Extrapolation may give unreliable results.")
69
68
 
70
69
  # Columns to interpolate
71
- param_columns = ['u', 'a', 'b', 'sigma', 'rho', 'm', 'nu', 'psi', 'p', 'c', 'nu_tilde']
70
+ param_columns = ['a', 'b', 'm', 'rho', 'sigma', 'nu', 'psi', 'p', 'c', 'nu_tilde']
72
71
 
73
72
  # Create empty DataFrame for interpolated results
74
73
  interpolated_df = pd.DataFrame(index=[f"{day}d" for day in target_days])
@@ -119,7 +118,7 @@ def interpolate_model(fit_results: pd.DataFrame,
119
118
  interpolated_df[param] = f(target_years)
120
119
 
121
120
  # Ensure consistent ordering of columns with expected structure
122
- expected_columns = ['s', 'u', 't', 'r', 'maturity_date', 'a', 'b', 'sigma', 'rho', 'm',
121
+ expected_columns = ['s', 't', 'r', 'maturity_date', 'a', 'b', 'm', 'rho', 'sigma',
123
122
  'nu', 'psi', 'p', 'c', 'nu_tilde']
124
123
 
125
124
  # Create final column order based on available columns
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: voly
3
- Version: 0.0.219
3
+ Version: 0.0.221
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -1,5 +1,5 @@
1
1
  voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
2
- voly/client.py,sha256=0kp2_I-imcJ6uxMcvS0BipS2PgWdFaCPZG5335Vg75Q,14383
2
+ voly/client.py,sha256=BHcTRfoM2VLoBsMLmp0QGt4dlgrjZ0CdC0L4PeefUI0,14479
3
3
  voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
4
4
  voly/formulas.py,sha256=Jn9hBoIx6PGv9k4lm8PeGM4lxFJkrLau8LpnXatdQPM,11176
5
5
  voly/models.py,sha256=CGJQr13Uie7iwtx2hjViN9lMXeRN_uOqzp4u8NPaTlA,9282
@@ -7,14 +7,14 @@ 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=SNF87C7-r-1IbKwf7rAhXkJ6X305yo7fCDJDdkwz3NM,14103
9
9
  voly/core/fit.py,sha256=bVyx7qMgFFpTUjgoCUs58ppmeNN2CORnqPKbGUpV9xw,14081
10
- voly/core/hd.py,sha256=UFAyLncNUHivpPAcko6IK1bC55mudVtdlRFfXp63HXE,14771
11
- voly/core/interpolate.py,sha256=JkK172-FXyhesW3hY4pEeuJWG3Bugq7QZXbeKoRpLuo,5305
10
+ voly/core/hd.py,sha256=1Gbxvn2EVfOE89fJsjylsREzV_pE3Ab_a3rE0qEf71E,13865
11
+ voly/core/interpolate.py,sha256=-cNChFpuLnCSMOmfW2ldXxePgQXi-pxcjJvF2yImD1w,5222
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.219.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
17
- voly-0.0.219.dist-info/METADATA,sha256=Wb6kob5yD26TOnHR5ko2G8G0uP9LgaDwxIDjCVWHf2o,4115
18
- voly-0.0.219.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
19
- voly-0.0.219.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
20
- voly-0.0.219.dist-info/RECORD,,
16
+ voly-0.0.221.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
17
+ voly-0.0.221.dist-info/METADATA,sha256=tTEL0rXh-JthRV4fid-xpHwbKWPkqyt6F-J4U8itpC8,4115
18
+ voly-0.0.221.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
19
+ voly-0.0.221.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
20
+ voly-0.0.221.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (79.0.0)
2
+ Generator: setuptools (80.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5