voly 0.0.221__py3-none-any.whl → 0.0.222__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 +0 -1
- voly/core/hd.py +4 -23
- {voly-0.0.221.dist-info → voly-0.0.222.dist-info}/METADATA +1 -1
- {voly-0.0.221.dist-info → voly-0.0.222.dist-info}/RECORD +7 -7
- {voly-0.0.221.dist-info → voly-0.0.222.dist-info}/WHEEL +0 -0
- {voly-0.0.221.dist-info → voly-0.0.222.dist-info}/licenses/LICENSE +0 -0
- {voly-0.0.221.dist-info → voly-0.0.222.dist-info}/top_level.txt +0 -0
voly/client.py
CHANGED
voly/core/hd.py
CHANGED
@@ -128,8 +128,6 @@ def calculate_historical_returns(df_hist: pd.DataFrame, n_periods: int) -> Tuple
|
|
128
128
|
|
129
129
|
@catch_exception
|
130
130
|
def calculate_normal_hd(df_hist: pd.DataFrame,
|
131
|
-
t: float,
|
132
|
-
r: float,
|
133
131
|
n_periods: int,
|
134
132
|
domains: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
|
135
133
|
"""
|
@@ -139,10 +137,6 @@ def calculate_normal_hd(df_hist: pd.DataFrame,
|
|
139
137
|
-----------
|
140
138
|
df_hist : pd.DataFrame
|
141
139
|
Historical price data
|
142
|
-
t : float
|
143
|
-
Time to maturity in years
|
144
|
-
r : float
|
145
|
-
Risk-free rate
|
146
140
|
n_periods : int
|
147
141
|
Number of periods to scale returns
|
148
142
|
domains : Dict[str, np.ndarray]
|
@@ -178,8 +172,6 @@ def calculate_normal_hd(df_hist: pd.DataFrame,
|
|
178
172
|
|
179
173
|
@catch_exception
|
180
174
|
def calculate_student_t_hd(df_hist: pd.DataFrame,
|
181
|
-
t: float,
|
182
|
-
r: float,
|
183
175
|
n_periods: int,
|
184
176
|
domains: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
|
185
177
|
"""
|
@@ -189,10 +181,6 @@ def calculate_student_t_hd(df_hist: pd.DataFrame,
|
|
189
181
|
-----------
|
190
182
|
df_hist : pd.DataFrame
|
191
183
|
Historical price data
|
192
|
-
t : float
|
193
|
-
Time to maturity in years
|
194
|
-
r : float
|
195
|
-
Risk-free rate
|
196
184
|
n_periods : int
|
197
185
|
Number of periods to scale returns
|
198
186
|
domains : Dict[str, np.ndarray]
|
@@ -245,8 +233,6 @@ def calculate_student_t_hd(df_hist: pd.DataFrame,
|
|
245
233
|
|
246
234
|
@catch_exception
|
247
235
|
def calculate_kde_hd(df_hist: pd.DataFrame,
|
248
|
-
t: float,
|
249
|
-
r: float,
|
250
236
|
n_periods: int,
|
251
237
|
domains: Dict[str, np.ndarray]) -> Dict[str, np.ndarray]:
|
252
238
|
"""
|
@@ -256,10 +242,6 @@ def calculate_kde_hd(df_hist: pd.DataFrame,
|
|
256
242
|
-----------
|
257
243
|
df_hist : pd.DataFrame
|
258
244
|
Historical price data
|
259
|
-
t : float
|
260
|
-
Time to maturity in years
|
261
|
-
r : float
|
262
|
-
Risk-free rate
|
263
245
|
n_periods : int
|
264
246
|
Number of periods to scale returns
|
265
247
|
domains : Dict[str, np.ndarray]
|
@@ -276,6 +258,8 @@ def calculate_kde_hd(df_hist: pd.DataFrame,
|
|
276
258
|
|
277
259
|
# Get scaled returns
|
278
260
|
scaled_returns, dte_returns = calculate_historical_returns(df_hist, n_periods)
|
261
|
+
vol = np.sqrt(scaled_returns.std())
|
262
|
+
scaled_returns = scaled_returns / vol
|
279
263
|
|
280
264
|
# Fit KDE model using scipy's gaussian_kde with Scott's rule for bandwidth
|
281
265
|
kde = stats.gaussian_kde(scaled_returns, bw_method='scott')
|
@@ -323,7 +307,7 @@ def get_hd_surface(model_results: pd.DataFrame,
|
|
323
307
|
Dictionary with pdf_surface, cdf_surface, x_surface, and moments
|
324
308
|
"""
|
325
309
|
# Validate inputs
|
326
|
-
required_columns = ['s', 't'
|
310
|
+
required_columns = ['s', 't']
|
327
311
|
missing_columns = [col for col in required_columns if col not in model_results.columns]
|
328
312
|
if missing_columns:
|
329
313
|
raise VolyError(f"Required columns missing in model_results: {missing_columns}")
|
@@ -350,7 +334,7 @@ def get_hd_surface(model_results: pd.DataFrame,
|
|
350
334
|
logger.info("Using Kernel Density Estimation (KDE) for historical density")
|
351
335
|
else: # default to normal
|
352
336
|
calculate_hd = calculate_normal_hd
|
353
|
-
logger.info("Using
|
337
|
+
logger.info("Using Normal distribution for historical density")
|
354
338
|
|
355
339
|
# Determine granularity from data (minutes between data points)
|
356
340
|
time_diff = (df_hist.index[1] - df_hist.index[0]).total_seconds() / 60
|
@@ -368,7 +352,6 @@ def get_hd_surface(model_results: pd.DataFrame,
|
|
368
352
|
# Get parameters for this maturity
|
369
353
|
s = model_results.loc[i, 's'] # Spot price
|
370
354
|
t = model_results.loc[i, 't'] # Time to maturity in years
|
371
|
-
r = model_results.loc[i, 'r'] # Risk-free rate
|
372
355
|
|
373
356
|
# Calculate relevant periods for this maturity
|
374
357
|
dte = t * 365.25 # Days to expiry
|
@@ -380,8 +363,6 @@ def get_hd_surface(model_results: pd.DataFrame,
|
|
380
363
|
# Calculate density using the selected method
|
381
364
|
pdfs = calculate_hd(
|
382
365
|
df_hist=df_hist,
|
383
|
-
t=t,
|
384
|
-
r=r,
|
385
366
|
n_periods=n_periods,
|
386
367
|
domains=domains
|
387
368
|
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
|
2
|
-
voly/client.py,sha256=
|
2
|
+
voly/client.py,sha256=F5jRdmEfxoE2RGHryCntRFrKLlyS7W974jEtEcBz8Co,14410
|
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=
|
10
|
+
voly/core/hd.py,sha256=gyGfrqMH52Y1umqCDcyO3yD35fh_JRM2ZfAeqb_--vU,13381
|
11
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.
|
17
|
-
voly-0.0.
|
18
|
-
voly-0.0.
|
19
|
-
voly-0.0.
|
20
|
-
voly-0.0.
|
16
|
+
voly-0.0.222.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
|
17
|
+
voly-0.0.222.dist-info/METADATA,sha256=38E1kmnHs1z5ivWU4Bf7lnce5v5Bd2hFb9RDOtJMNc8,4115
|
18
|
+
voly-0.0.222.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
19
|
+
voly-0.0.222.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
|
20
|
+
voly-0.0.222.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|