voly 0.0.109__py3-none-any.whl → 0.0.111__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/formulas.py CHANGED
@@ -368,17 +368,19 @@ def pdf_to_calls(pdf_K, s, K, r, t):
368
368
  # Step 1: Recover the second derivative
369
369
  c2_recovered = pdf_K_normalized / np.exp(r * t)
370
370
 
371
- # Step 2: Double integration using NumPy
372
- # First integration (c2 -> c1)
371
+ # Step 2: Use Simpson's rule for smoother first derivatives recovery
373
372
  c1_recovered = np.zeros_like(K)
374
373
  for i in range(1, len(K)):
375
- c1_recovered[i] = c1_recovered[i - 1] + 0.5 * (c2_recovered[i] + c2_recovered[i - 1]) * (K[i] - K[i - 1])
374
+ h = K[i] - K[i - 1]
375
+ c1_recovered[i] = c1_recovered[i - 1] + (h / 6) * (
376
+ c2_recovered[i - 1] + 4 * c2_recovered[(i - 1 + i) // 2] + c2_recovered[i])
376
377
 
377
- # Second integration (c1 -> c)
378
+ # Step 3: Second integration with Simpson's rule to recover original calls
378
379
  c_recovered_base = np.zeros_like(K)
379
380
  for i in range(1, len(K)):
380
- c_recovered_base[i] = c_recovered_base[i - 1] + 0.5 * (c1_recovered[i] + c1_recovered[i - 1]) * (
381
- K[i] - K[i - 1])
381
+ h = K[i] - K[i - 1]
382
+ c1_mid = (c1_recovered[i - 1] + c1_recovered[i]) / 2 # Midpoint approximation
383
+ c_recovered_base[i] = c_recovered_base[i - 1] + (h / 6) * (c1_recovered[i - 1] + 4 * c1_mid + c1_recovered[i])
382
384
 
383
385
  # Determine the integration constants based on boundary conditions
384
386
  # Find the lowest strike (deep ITM) and highest strike (deep OTM)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: voly
3
- Version: 0.0.109
3
+ Version: 0.0.111
4
4
  Summary: Options & volatility research package
5
5
  Author-email: Manu de Cara <manu.de.cara@gmail.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  voly/__init__.py,sha256=8xyDk7rFCn_MOD5hxuv5cxxKZvBVRiSIM7TgaMPpwpw,211
2
2
  voly/client.py,sha256=FOH1E_zTCnDZhGLab9dzpqMQ5-fkW0MFeV0o1dBMx0w,12424
3
3
  voly/exceptions.py,sha256=PBsbn1vNMvKcCJwwJ4lBO6glD85jo1h2qiEmD7ArAjs,92
4
- voly/formulas.py,sha256=1Kjo6j7dMzjyfym-Cfk67qP4sS-lKQpkj0YNAoBOGe0,13351
4
+ voly/formulas.py,sha256=wyisgDdhaQe3oB1wnGLSywsT-O5N4-ZqE9RzabumBlc,13549
5
5
  voly/models.py,sha256=BF-O7BjGf0BLMpw4rCtfwW7s8_f4iyUZdUY6q1dVxLs,3363
6
6
  voly/core/__init__.py,sha256=bu6fS2I1Pj9fPPnl-zY3L7NqrZSY5Zy6NY2uMUvdhKs,183
7
7
  voly/core/charts.py,sha256=E21OZB5lTY4YL2flgaFJ6s5g3_ExtAQT2zryZZxLPyM,12735
@@ -12,8 +12,8 @@ voly/core/interpolate.py,sha256=JkK172-FXyhesW3hY4pEeuJWG3Bugq7QZXbeKoRpLuo,5305
12
12
  voly/core/rnd.py,sha256=VKM8ojLBziB9nxOEsKO5z_9Z1BSOVNxg0OQPx-Sp80I,10094
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.109.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
16
- voly-0.0.109.dist-info/METADATA,sha256=jXlpZC7l_ML8dLiSKlsX8AOwVqawgHnxGUfYwC2rK5Q,4115
17
- voly-0.0.109.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
18
- voly-0.0.109.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
19
- voly-0.0.109.dist-info/RECORD,,
15
+ voly-0.0.111.dist-info/licenses/LICENSE,sha256=wcHIVbE12jfcBOai_wqBKY6xvNQU5E909xL1zZNq_2Q,1065
16
+ voly-0.0.111.dist-info/METADATA,sha256=h0fKhYmCzNciUiONxuR-wn08zxC3U89TlOYHwoekhjQ,4115
17
+ voly-0.0.111.dist-info/WHEEL,sha256=tTnHoFhvKQHCh4jz3yCn0WPTYIy7wXx3CJtJ7SJGV7c,91
18
+ voly-0.0.111.dist-info/top_level.txt,sha256=ZfLw2sSxF-LrKAkgGjOmeTcw6_gD-30zvtdEY5W4B7c,5
19
+ voly-0.0.111.dist-info/RECORD,,
File without changes