PYield 0.13.2__tar.gz → 0.13.4__tar.gz

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.
Files changed (37) hide show
  1. {pyield-0.13.2 → pyield-0.13.4}/PKG-INFO +1 -3
  2. pyield-0.13.4/pyield/__about__.py +1 -0
  3. {pyield-0.13.2 → pyield-0.13.4}/pyield/bonds/ntnf.py +23 -8
  4. {pyield-0.13.2 → pyield-0.13.4}/pyproject.toml +2 -3
  5. pyield-0.13.2/pyield/__about__.py +0 -1
  6. {pyield-0.13.2 → pyield-0.13.4}/LICENSE +0 -0
  7. {pyield-0.13.2 → pyield-0.13.4}/README.md +0 -0
  8. {pyield-0.13.2 → pyield-0.13.4}/pyield/__init__.py +0 -0
  9. {pyield-0.13.2 → pyield-0.13.4}/pyield/bday.py +0 -0
  10. {pyield-0.13.2 → pyield-0.13.4}/pyield/bonds/__init__.py +0 -0
  11. {pyield-0.13.2 → pyield-0.13.4}/pyield/bonds/lft.py +0 -0
  12. {pyield-0.13.2 → pyield-0.13.4}/pyield/bonds/ltn.py +0 -0
  13. {pyield-0.13.2 → pyield-0.13.4}/pyield/bonds/ntnb.py +0 -0
  14. {pyield-0.13.2 → pyield-0.13.4}/pyield/bonds/utils.py +0 -0
  15. {pyield-0.13.2 → pyield-0.13.4}/pyield/date_converter.py +0 -0
  16. {pyield-0.13.2 → pyield-0.13.4}/pyield/di.py +0 -0
  17. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/__init__.py +0 -0
  18. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/anbima.py +0 -0
  19. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/futures_data/__init__.py +0 -0
  20. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/futures_data/common.py +0 -0
  21. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/futures_data/historical.py +0 -0
  22. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/futures_data/intraday.py +0 -0
  23. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/futures_data/xml.py +0 -0
  24. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/indicators.py +0 -0
  25. {pyield-0.13.2 → pyield-0.13.4}/pyield/fetchers/projections.py +0 -0
  26. {pyield-0.13.2 → pyield-0.13.4}/pyield/holidays/__init__.py +0 -0
  27. {pyield-0.13.2 → pyield-0.13.4}/pyield/holidays/br_holidays_new.txt +0 -0
  28. {pyield-0.13.2 → pyield-0.13.4}/pyield/holidays/br_holidays_old.txt +0 -0
  29. {pyield-0.13.2 → pyield-0.13.4}/pyield/holidays/holidays_manager.py +0 -0
  30. {pyield-0.13.2 → pyield-0.13.4}/pyield/interpolator.py +0 -0
  31. {pyield-0.13.2 → pyield-0.13.4}/pyield/py.typed +0 -0
  32. {pyield-0.13.2 → pyield-0.13.4}/tests/__init__.py +0 -0
  33. {pyield-0.13.2 → pyield-0.13.4}/tests/data/SPRD231222.zip +0 -0
  34. {pyield-0.13.2 → pyield-0.13.4}/tests/data/SPRD240426.zip +0 -0
  35. {pyield-0.13.2 → pyield-0.13.4}/tests/test_bday.py +0 -0
  36. {pyield-0.13.2 → pyield-0.13.4}/tests/test_futures.py +0 -0
  37. {pyield-0.13.2 → pyield-0.13.4}/tests/test_futures_xml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PYield
3
- Version: 0.13.2
3
+ Version: 0.13.4
4
4
  Summary: A Python library for analysis of fixed income instruments in Brazil
5
5
  Keywords: fixed-income, brazil, finance, analysis, bonds
6
6
  Author-Email: Carlos Carvalho <cr.cj@outlook.com>
@@ -36,9 +36,7 @@ Requires-Dist: pandas>=2.0.0
36
36
  Requires-Dist: numpy
37
37
  Requires-Dist: beautifulsoup4
38
38
  Requires-Dist: html5lib
39
- Requires-Dist: lxml
40
39
  Requires-Dist: python-calamine>=0.2.0
41
- Requires-Dist: scipy
42
40
  Requires-Dist: requests>=2.31.0
43
41
  Requires-Dist: pyarrow
44
42
  Description-Content-Type: text/markdown
@@ -0,0 +1 @@
1
+ __version__ = "0.13.4"
@@ -1,6 +1,5 @@
1
1
  import numpy as np
2
2
  import pandas as pd
3
- from scipy.optimize import brentq
4
3
 
5
4
  from .. import bday, di
6
5
  from .. import date_converter as dc
@@ -377,21 +376,37 @@ def di_net_spread( # noqa
377
376
  # Calculate the difference between the bond's price and its disc. cash flows
378
377
  return (bond_cash_flows / (1 + di_interp + p) ** byears).sum() - bond_price
379
378
 
379
+ # Bisection method to find the root
380
+ def bisection_method(func, a, b, tol=1e-8, maxiter=100):
381
+ fa, fb = func(a), func(b)
382
+ if fa * fb > 0:
383
+ raise ValueError("Function does not change sign in the interval.")
384
+
385
+ for _ in range(maxiter):
386
+ midpoint = (a + b) / 2
387
+ fmid = func(midpoint)
388
+ if np.abs(fmid) < tol or (b - a) / 2 < tol:
389
+ return midpoint
390
+ if fmid * fa < 0:
391
+ b, fb = midpoint, fmid
392
+ else:
393
+ a, fa = midpoint, fmid
394
+
395
+ return (a + b) / 2
396
+
380
397
  try:
381
- if initial_guess:
382
- # Search interval is 50 bps above and below the initial guess
398
+ if initial_guess is not None:
383
399
  a = initial_guess - 50 / 10_000 # 50 bps below the initial guess
384
400
  b = initial_guess + 50 / 10_000 # 50 bps above the initial guess
385
401
  else:
386
- # Search interval is from -0.01 to 0.01 (i.e., -100 to 100 bps)
387
- a = -0.01
388
- b = 0.01
402
+ a = -0.01 # Initial guess of -100 bps
403
+ b = 0.01 # Initial guess of 100 bps
389
404
 
390
405
  # Find the spread (p) that zeroes the price difference
391
- p_solution = brentq(price_difference, a, b, maxiter=100)
406
+ p_solution = bisection_method(price_difference, a, b)
392
407
  # Convert the solution to basis points (bps) and round to two decimal places
393
408
  p_solution = round((p_solution * 10_000), 2)
394
- except (ValueError, RuntimeError):
409
+ except ValueError:
395
410
  # If no solution is found, return NaN
396
411
  p_solution = float("nan")
397
412
 
@@ -27,14 +27,12 @@ dependencies = [
27
27
  "numpy",
28
28
  "beautifulsoup4",
29
29
  "html5lib",
30
- "lxml",
31
30
  "python-calamine>=0.2.0",
32
- "scipy",
33
31
  "requests>=2.31.0",
34
32
  "pyarrow",
35
33
  ]
36
34
  dynamic = []
37
- version = "0.13.2"
35
+ version = "0.13.4"
38
36
 
39
37
  [project.license]
40
38
  file = "LICENSE"
@@ -57,6 +55,7 @@ dev = [
57
55
  "mkdocs",
58
56
  "mkdocs-material",
59
57
  "mkdocstrings[python]",
58
+ "lxml",
60
59
  ]
61
60
 
62
61
  [tool.ruff]
@@ -1 +0,0 @@
1
- __version__ = "0.13.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes