PYield 0.16.1__tar.gz → 0.16.2__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 (38) hide show
  1. {pyield-0.16.1 → pyield-0.16.2}/PKG-INFO +1 -1
  2. pyield-0.16.2/pyield/__about__.py +1 -0
  3. {pyield-0.16.1 → pyield-0.16.2}/pyield/interpolator.py +8 -4
  4. {pyield-0.16.1 → pyield-0.16.2}/pyproject.toml +1 -1
  5. pyield-0.16.1/pyield/__about__.py +0 -1
  6. {pyield-0.16.1 → pyield-0.16.2}/LICENSE +0 -0
  7. {pyield-0.16.1 → pyield-0.16.2}/README.md +0 -0
  8. {pyield-0.16.1 → pyield-0.16.2}/pyield/__init__.py +0 -0
  9. {pyield-0.16.1 → pyield-0.16.2}/pyield/bday.py +0 -0
  10. {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/__init__.py +0 -0
  11. {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/bond_tools.py +0 -0
  12. {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/lft.py +0 -0
  13. {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/ltn.py +0 -0
  14. {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/ntnb.py +0 -0
  15. {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/ntnf.py +0 -0
  16. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/__init__.py +0 -0
  17. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/anbima.py +0 -0
  18. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/data_cache.py +0 -0
  19. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/di.py +0 -0
  20. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/__init__.py +0 -0
  21. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/common.py +0 -0
  22. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/historical.py +0 -0
  23. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/intraday.py +0 -0
  24. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/xml.py +0 -0
  25. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/indicators.py +0 -0
  26. {pyield-0.16.1 → pyield-0.16.2}/pyield/data/projections.py +0 -0
  27. {pyield-0.16.1 → pyield-0.16.2}/pyield/date_converter.py +0 -0
  28. {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/__init__.py +0 -0
  29. {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/br_holidays_new.txt +0 -0
  30. {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/br_holidays_old.txt +0 -0
  31. {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/holidays_manager.py +0 -0
  32. {pyield-0.16.1 → pyield-0.16.2}/pyield/py.typed +0 -0
  33. {pyield-0.16.1 → pyield-0.16.2}/tests/__init__.py +0 -0
  34. {pyield-0.16.1 → pyield-0.16.2}/tests/data/SPRD231222.zip +0 -0
  35. {pyield-0.16.1 → pyield-0.16.2}/tests/data/SPRD240426.zip +0 -0
  36. {pyield-0.16.1 → pyield-0.16.2}/tests/test_bday.py +0 -0
  37. {pyield-0.16.1 → pyield-0.16.2}/tests/test_futures.py +0 -0
  38. {pyield-0.16.1 → pyield-0.16.2}/tests/test_futures_xml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PYield
3
- Version: 0.16.1
3
+ Version: 0.16.2
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>
@@ -0,0 +1 @@
1
+ __version__ = "0.16.2"
@@ -11,6 +11,7 @@ class Interpolator:
11
11
  method: Literal["flat_forward", "linear"],
12
12
  known_bdays: pd.Series | list,
13
13
  known_rates: pd.Series | list,
14
+ extrapolate: bool = False,
14
15
  ):
15
16
  """
16
17
  Initialize the Interpolator with given atributes.
@@ -19,6 +20,7 @@ class Interpolator:
19
20
  method (Literal["flat_forward", "linear"]): Interpolation method.
20
21
  known_bdays (pd.Series | pd.Index | list): Series of known business days.
21
22
  known_rates (pd.Series | pd.Index | list): Series of known interest rates.
23
+ extrapolate (bool, optional): Whether to extrapolate beyond the known data.
22
24
 
23
25
  Raises:
24
26
  ValueError: If known_bdays and known_rates do not have the same length.
@@ -43,6 +45,7 @@ class Interpolator:
43
45
  self.method = method
44
46
  self.known_bdays = known_bdays
45
47
  self.known_rates = known_rates
48
+ self.extrapolate = extrapolate
46
49
  self._set_known_bdays_and_rates()
47
50
 
48
51
  def _set_known_bdays_and_rates(self) -> None:
@@ -105,17 +108,18 @@ class Interpolator:
105
108
  # Check for edge cases
106
109
  if bday < self._known_bdays[0]:
107
110
  return self._known_rates[0]
108
- elif bday > self._known_bdays[-1]:
109
- return self._known_rates[-1]
110
111
  elif bday in self._known_bdays:
111
112
  return self._known_rates[self._known_bdays.index(bday)]
113
+ elif bday > self._known_bdays[-1]:
114
+ if self.extrapolate:
115
+ return self._known_rates[-1]
116
+ else:
117
+ return float("NaN")
112
118
 
113
119
  if self.method == "flat_forward":
114
120
  return self._flat_forward(bday)
115
121
  elif self.method == "linear":
116
122
  return self._linear(bday)
117
- else:
118
- raise ValueError(f"Unknown interpolation method: {self.method}.")
119
123
 
120
124
  def __call__(self, bday: int) -> float:
121
125
  """
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "types-requests",
33
33
  ]
34
34
  dynamic = []
35
- version = "0.16.1"
35
+ version = "0.16.2"
36
36
 
37
37
  [project.license]
38
38
  file = "LICENSE"
@@ -1 +0,0 @@
1
- __version__ = "0.16.1"
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
File without changes