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.
- {pyield-0.16.1 → pyield-0.16.2}/PKG-INFO +1 -1
- pyield-0.16.2/pyield/__about__.py +1 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/interpolator.py +8 -4
- {pyield-0.16.1 → pyield-0.16.2}/pyproject.toml +1 -1
- pyield-0.16.1/pyield/__about__.py +0 -1
- {pyield-0.16.1 → pyield-0.16.2}/LICENSE +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/README.md +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/__init__.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/bday.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/__init__.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/bond_tools.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/lft.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/ltn.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/ntnb.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/bonds/ntnf.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/__init__.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/anbima.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/data_cache.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/di.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/__init__.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/common.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/historical.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/intraday.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/futures_data/xml.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/indicators.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/data/projections.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/date_converter.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/__init__.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/pyield/py.typed +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/tests/__init__.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/tests/test_bday.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/tests/test_futures.py +0 -0
- {pyield-0.16.1 → pyield-0.16.2}/tests/test_futures_xml.py +0 -0
|
@@ -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
|
"""
|
|
@@ -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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|