PYield 0.17.0__tar.gz → 0.17.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.17.0 → pyield-0.17.2}/PKG-INFO +1 -1
- pyield-0.17.2/pyield/__about__.py +1 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/ntnb.py +1 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/di.py +12 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/interpolator.py +1 -1
- {pyield-0.17.0 → pyield-0.17.2}/pyproject.toml +1 -1
- pyield-0.17.0/pyield/__about__.py +0 -1
- {pyield-0.17.0 → pyield-0.17.2}/LICENSE +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/README.md +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/__init__.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/bday.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/__init__.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/bond_tools.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/lft.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/ltn.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/ntnf.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/__init__.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/anbima.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/data_cache.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/__init__.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/common.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/historical.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/intraday.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/xml.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/indicators.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/data/projections.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/date_converter.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/__init__.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.17.0 → pyield-0.17.2}/pyield/py.typed +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.17.2"
|
|
@@ -93,6 +93,7 @@ def rate(
|
|
|
93
93
|
trade_date: str | pd.Timestamp,
|
|
94
94
|
expiration: str | pd.Timestamp,
|
|
95
95
|
interpolate: bool = True,
|
|
96
|
+
extrapolate: bool = False,
|
|
96
97
|
) -> float:
|
|
97
98
|
"""Retrieve the DI rate for a specified trade date and expiration date.
|
|
98
99
|
|
|
@@ -106,6 +107,8 @@ def rate(
|
|
|
106
107
|
expiration (str | pd.Timestamp): The expiration date for the DI contract.
|
|
107
108
|
interpolate (bool): If True, interpolates the rate for the provided expiration
|
|
108
109
|
date.
|
|
110
|
+
extrapolate (bool): If True, extrapolates the rate for expiration dates beyond
|
|
111
|
+
the available data.
|
|
109
112
|
|
|
110
113
|
Returns:
|
|
111
114
|
float: The DI rate for the specified trade date and expiration date, or NaN
|
|
@@ -116,6 +119,10 @@ def rate(
|
|
|
116
119
|
# Adjust expiration date to the nearest business day
|
|
117
120
|
expiration = bday.offset(expiration, 0)
|
|
118
121
|
|
|
122
|
+
# Return an error if interpolation is not allowed and extrapolation is required
|
|
123
|
+
if not interpolate and extrapolate:
|
|
124
|
+
raise ValueError("Extrapolation is not allowed without interpolation.")
|
|
125
|
+
|
|
119
126
|
# Retrieve the data for the given trade date
|
|
120
127
|
df = data(trade_date)
|
|
121
128
|
|
|
@@ -134,11 +141,16 @@ def rate(
|
|
|
134
141
|
# Return the rate if an exact match is found
|
|
135
142
|
return float(df_exp["SettlementRate"].iloc[0])
|
|
136
143
|
|
|
144
|
+
if not interpolate:
|
|
145
|
+
# Return NaN if no exact match is found and interpolation is not allowed
|
|
146
|
+
return float("NaN")
|
|
147
|
+
|
|
137
148
|
# Perform flat forward interpolation if required
|
|
138
149
|
ff_interpolator = interpolator.Interpolator(
|
|
139
150
|
method="flat_forward",
|
|
140
151
|
known_bdays=bday.count(trade_date, df["ExpirationDate"]),
|
|
141
152
|
known_rates=df["SettlementRate"],
|
|
153
|
+
extrapolate=extrapolate,
|
|
142
154
|
)
|
|
143
155
|
|
|
144
156
|
# Return the interpolated rate for the calculated business days
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.17.0"
|
|
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
|