voly 0.0.141__py3-none-any.whl → 0.0.142__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/rnd.py CHANGED
@@ -221,54 +221,48 @@ def get_all_moments(x, pdf, model_params=None):
221
221
  return moments
222
222
  '''
223
223
 
224
+
224
225
  @catch_exception
225
226
  def get_all_moments(x, pdf, model_params=None):
226
227
  # Precompute dx for integration
227
228
  dx = np.diff(x, prepend=x[0])
228
229
 
229
230
  # Raw Moments (μ_k = E[X^k])
230
- raw_moments = {
231
- 'raw_0': np.trapz(pdf, x), # Zeroth (~1)
232
- 'raw_1': np.trapz(x * pdf, x), # First (mean)
233
- 'raw_2': np.trapz(x**2 * pdf, x), # Second
234
- 'raw_3': np.trapz(x**3 * pdf, x), # Third
235
- 'raw_4': np.trapz(x**4 * pdf, x), # Fourth
236
- 'raw_5': np.trapz(x**5 * pdf, x), # Fifth
237
- 'raw_6': np.trapz(x**6 * pdf, x), # Sixth
238
- }
239
-
240
- mean = raw_moments['raw_1']
231
+ raw_0 = np.trapz(pdf, x) # Zeroth (~1)
232
+ raw_1 = np.trapz(x * pdf, x) # First (mean)
233
+ raw_2 = np.trapz(x**2 * pdf, x) # Second
234
+ raw_3 = np.trapz(x**3 * pdf, x) # Third
235
+ raw_4 = np.trapz(x**4 * pdf, x) # Fourth
236
+ raw_5 = np.trapz(x**5 * pdf, x) # Fifth
237
+ raw_6 = np.trapz(x**6 * pdf, x) # Sixth
238
+
239
+ mean = raw_1
241
240
  variance = np.trapz((x - mean)**2 * pdf, x) # m_2
242
241
  std_dev = np.sqrt(variance)
243
242
 
244
243
  # Central Moments (m_k = E[(X - μ)^k])
245
- central_moments = {
246
- 'cent_0': raw_moments['raw_0'], # Zeroth (~1)
247
- 'cent_1': np.trapz((x - mean) * pdf, x), # First (~0)
248
- 'cent_2': variance, # Second (variance)
249
- 'cent_3': np.trapz((x - mean)**3 * pdf, x), # Third
250
- 'cent_4': np.trapz((x - mean)**4 * pdf, x), # Fourth
251
- 'cent_5': np.trapz((x - mean)**5 * pdf, x), # Fifth
252
- 'cent_6': np.trapz((x - mean)**6 * pdf, x), # Sixth
253
- }
244
+ cent_0 = raw_0 # Zeroth (~1)
245
+ cent_1 = np.trapz((x - mean) * pdf, x) # First (~0)
246
+ cent_2 = variance # Second (variance)
247
+ cent_3 = np.trapz((x - mean)**3 * pdf, x) # Third
248
+ cent_4 = np.trapz((x - mean)**4 * pdf, x) # Fourth
249
+ cent_5 = np.trapz((x - mean)**5 * pdf, x) # Fifth
250
+ cent_6 = np.trapz((x - mean)**6 * pdf, x) # Sixth
254
251
 
255
252
  # Standardized Moments (m̄_k = E[((X - μ)/σ)^k])
256
253
  z = (x - mean) / std_dev
257
- standardized_moments = {
258
- 'std_0': np.trapz(pdf, x), # Zeroth (~1)
259
- 'std_1': np.trapz(z * pdf, x), # First (~0)
260
- 'std_2': np.trapz(z**2 * pdf, x), # Second (~1)
261
- 'std_3': np.trapz(z**3 * pdf, x), # Skewness
262
- 'std_4': np.trapz(z**4 * pdf, x), # Kurtosis
263
- 'std_5': np.trapz(z**5 * pdf, x), # Fifth
264
- 'std_6': np.trapz(z**6 * pdf, x), # Sixth
265
- }
254
+ std_0 = np.trapz(pdf, x) # Zeroth (~1)
255
+ std_1 = np.trapz(z * pdf, x) # First (~0)
256
+ std_2 = np.trapz(z**2 * pdf, x) # Second (~1)
257
+ std_3 = np.trapz(z**3 * pdf, x) # Skewness
258
+ std_4 = np.trapz(z**4 * pdf, x) # Kurtosis
259
+ std_5 = np.trapz(z**5 * pdf, x) # Fifth
260
+ std_6 = np.trapz(z**6 * pdf, x) # Sixth
266
261
 
267
262
  # Extra statistics
268
263
  cdf = np.cumsum(pdf * dx)
269
264
  median = x[np.searchsorted(cdf, 0.5)] # Median
270
- mode = x[np.argmax(pdf)] # Mode
271
- excess_kurtosis = standardized_moments['std_4'] - 3
265
+ excess_kurtosis = std_4 - 3
272
266
  q25 = x[np.searchsorted(cdf, 0.25)] # 25th percentile
273
267
  q75 = x[np.searchsorted(cdf, 0.75)] # 75th percentile
274
268
  iqr = q75 - q25
@@ -284,25 +278,44 @@ def get_all_moments(x, pdf, model_params=None):
284
278
  o3n = np.sum(pdf[(z <= -2) & (z > -3)] * dx[(z <= -2) & (z > -3)])
285
279
  o4n = np.sum(pdf[z <= -3] * dx[z <= -3])
286
280
 
287
- # Combine results
281
+ # Combine results as flat columns
288
282
  moments = {
289
- 'raw_moments': raw_moments,
290
- 'central_moments': central_moments,
291
- 'standardized_moments': standardized_moments,
292
- 'mean': mean,
293
- 'variance': variance,
294
- 'std_dev': std_dev,
283
+ 'raw_0': raw_0,
284
+ 'raw_1': raw_1,
285
+ 'raw_2': raw_2,
286
+ 'raw_3': raw_3,
287
+ 'raw_4': raw_4,
288
+ 'raw_5': raw_5,
289
+ 'raw_6': raw_6,
290
+ 'cent_0': cent_0,
291
+ 'cent_1': cent_1,
292
+ 'cent_2': cent_2,
293
+ 'cent_3': cent_3,
294
+ 'cent_4': cent_4,
295
+ 'cent_5': cent_5,
296
+ 'cent_6': cent_6,
297
+ 'std_0': std_0,
298
+ 'std_1': std_1,
299
+ 'std_2': std_2,
300
+ 'std_3': std_3,
301
+ 'std_4': std_4,
302
+ 'std_5': std_5,
303
+ 'std_6': std_6,
295
304
  'median': median,
296
- 'mode': mode,
305
+ 'std_dev': std_dev,
297
306
  'excess_kurtosis': excess_kurtosis,
298
307
  'q25': q25,
299
308
  'q75': q75,
300
309
  'iqr': iqr,
301
310
  'entropy': entropy,
302
- 'z_score_areas': {
303
- 'o1p': o1p, 'o2p': o2p, 'o3p': o3p, 'o4p': o4p,
304
- 'o1n': o1n, 'o2n': o2n, 'o3n': o3n, 'o4n': o4n
305
- }
311
+ 'o1p': o1p,
312
+ 'o2p': o2p,
313
+ 'o3p': o3p,
314
+ 'o4p': o4p,
315
+ 'o1n': o1n,
316
+ 'o2n': o2n,
317
+ 'o3n': o3n,
318
+ 'o4n': o4n
306
319
  }
307
320
 
308
321
  if model_params is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: voly
3
- Version: 0.0.141
3
+ Version: 0.0.142
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -9,11 +9,11 @@ voly/core/data.py,sha256=pDeuYhP0GX4RbtlqByvsE3rfHcIkix0BU5MLW8sKIeI,8935
9
9
  voly/core/fit.py,sha256=Tb9eeG7e_2dQTcqt6aqEwFrZdy6jR9rSNqe6tzOdVhQ,9245
10
10
  voly/core/hd.py,sha256=K2X0isAchumuRPcc5RSEkMOR5sOeb_I3twwqAZYYL1A,16809
11
11
  voly/core/interpolate.py,sha256=JkK172-FXyhesW3hY4pEeuJWG3Bugq7QZXbeKoRpLuo,5305
12
- voly/core/rnd.py,sha256=kF_TUxlfFHI9WF3JAh6mS-mggia0zogPdY01yvuYoxM,13589
12
+ voly/core/rnd.py,sha256=masjK4WrVb925gPGboD8iDAaEN7FY7S4OHYthHPtA3o,13613
13
13
  voly/utils/__init__.py,sha256=E05mWatyC-PDOsCxQV1p5Xi1IgpOomxrNURyCx_gB-w,200
14
14
  voly/utils/logger.py,sha256=4-_2bVJmq17Q0d7Rd2mPg1AeR8gxv6EPvcmBDMFWcSM,1744
15
- voly-0.0.141.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
16
- voly-0.0.141.dist-info/METADATA,sha256=UC3R8Dldao7KZLPGHwtU6JCj0lYgzeQ7hmCZGZELlYc,4115
17
- voly-0.0.141.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
18
- voly-0.0.141.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
19
- voly-0.0.141.dist-info/RECORD,,
15
+ voly-0.0.142.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
16
+ voly-0.0.142.dist-info/METADATA,sha256=BLz0X2tkaiZqfL5cYXcihLfbrZra3AQRrRXPXrNkS5w,4115
17
+ voly-0.0.142.dist-info/WHEEL,sha256=DK49LOLCYiurdXXOXwGJm6U4DkHkg4lcxjhqwRa0CP4,91
18
+ voly-0.0.142.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
19
+ voly-0.0.142.dist-info/RECORD,,
File without changes