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.
Files changed (32) hide show
  1. {pyield-0.17.0 → pyield-0.17.2}/PKG-INFO +1 -1
  2. pyield-0.17.2/pyield/__about__.py +1 -0
  3. {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/ntnb.py +1 -0
  4. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/di.py +12 -0
  5. {pyield-0.17.0 → pyield-0.17.2}/pyield/interpolator.py +1 -1
  6. {pyield-0.17.0 → pyield-0.17.2}/pyproject.toml +1 -1
  7. pyield-0.17.0/pyield/__about__.py +0 -1
  8. {pyield-0.17.0 → pyield-0.17.2}/LICENSE +0 -0
  9. {pyield-0.17.0 → pyield-0.17.2}/README.md +0 -0
  10. {pyield-0.17.0 → pyield-0.17.2}/pyield/__init__.py +0 -0
  11. {pyield-0.17.0 → pyield-0.17.2}/pyield/bday.py +0 -0
  12. {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/__init__.py +0 -0
  13. {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/bond_tools.py +0 -0
  14. {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/lft.py +0 -0
  15. {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/ltn.py +0 -0
  16. {pyield-0.17.0 → pyield-0.17.2}/pyield/bonds/ntnf.py +0 -0
  17. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/__init__.py +0 -0
  18. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/anbima.py +0 -0
  19. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/data_cache.py +0 -0
  20. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/__init__.py +0 -0
  21. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/common.py +0 -0
  22. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/historical.py +0 -0
  23. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/intraday.py +0 -0
  24. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/futures_data/xml.py +0 -0
  25. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/indicators.py +0 -0
  26. {pyield-0.17.0 → pyield-0.17.2}/pyield/data/projections.py +0 -0
  27. {pyield-0.17.0 → pyield-0.17.2}/pyield/date_converter.py +0 -0
  28. {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/__init__.py +0 -0
  29. {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/br_holidays_new.txt +0 -0
  30. {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/br_holidays_old.txt +0 -0
  31. {pyield-0.17.0 → pyield-0.17.2}/pyield/holidays/holidays_manager.py +0 -0
  32. {pyield-0.17.0 → pyield-0.17.2}/pyield/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PYield
3
- Version: 0.17.0
3
+ Version: 0.17.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.17.2"
@@ -415,6 +415,7 @@ def bei_rates(
415
415
  method="flat_forward",
416
416
  known_bdays=bday.count(settlement, nominal_maturities),
417
417
  known_rates=nominal_rates,
418
+ extrapolate=True,
418
419
  )
419
420
 
420
421
  df["NIR"] = df["BDays"].apply(nir_interplator).astype("Float64")
@@ -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
@@ -11,7 +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 = True,
14
+ extrapolate: bool = False,
15
15
  ):
16
16
  """
17
17
  Initialize the Interpolator with given atributes.
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "types-requests",
33
33
  ]
34
34
  dynamic = []
35
- version = "0.17.0"
35
+ version = "0.17.2"
36
36
 
37
37
  [project.license]
38
38
  file = "LICENSE"
@@ -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