PYield 0.13.0__tar.gz → 0.13.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.13.0 → pyield-0.13.2}/PKG-INFO +1 -1
- pyield-0.13.2/pyield/__about__.py +1 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/bonds/lft.py +11 -9
- {pyield-0.13.0 → pyield-0.13.2}/pyield/bonds/ltn.py +11 -9
- {pyield-0.13.0 → pyield-0.13.2}/pyield/bonds/ntnb.py +33 -26
- {pyield-0.13.0 → pyield-0.13.2}/pyield/bonds/ntnf.py +43 -67
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/anbima.py +6 -50
- {pyield-0.13.0 → pyield-0.13.2}/pyproject.toml +1 -1
- pyield-0.13.0/pyield/__about__.py +0 -1
- {pyield-0.13.0 → pyield-0.13.2}/LICENSE +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/README.md +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/__init__.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/bday.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/bonds/__init__.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/bonds/utils.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/date_converter.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/di.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/__init__.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/futures_data/__init__.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/futures_data/common.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/futures_data/historical.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/futures_data/intraday.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/futures_data/xml.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/indicators.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/fetchers/projections.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/holidays/__init__.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/interpolator.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/pyield/py.typed +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/tests/__init__.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/tests/test_bday.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/tests/test_futures.py +0 -0
- {pyield-0.13.0 → pyield-0.13.2}/tests/test_futures_xml.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.13.2"
|
|
@@ -19,30 +19,32 @@ def anbima_data(reference_date: str | pd.Timestamp) -> pd.DataFrame:
|
|
|
19
19
|
return an.anbima_data(reference_date, "LFT")
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def
|
|
22
|
+
def indicative_rates(reference_date: str | pd.Timestamp) -> pd.Series:
|
|
23
23
|
"""
|
|
24
|
-
Fetch
|
|
24
|
+
Fetch the bond indicative rates for the given reference date.
|
|
25
25
|
|
|
26
26
|
Args:
|
|
27
27
|
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
28
28
|
|
|
29
29
|
Returns:
|
|
30
|
-
pd.Series: A Series containing the rates indexed by maturity date.
|
|
30
|
+
pd.Series: A Series containing the bond rates indexed by maturity date.
|
|
31
31
|
"""
|
|
32
|
-
|
|
32
|
+
df = an.anbima_rates(reference_date, "LFT")
|
|
33
|
+
return df.set_index("MaturityDate")["IndicativeRate"]
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
def
|
|
36
|
+
def maturities(reference_date: str | pd.Timestamp) -> list[pd.Timestamp]:
|
|
36
37
|
"""
|
|
37
|
-
Fetch
|
|
38
|
+
Fetch the bond maturities available for the given reference date.
|
|
38
39
|
|
|
39
40
|
Args:
|
|
40
|
-
|
|
41
|
+
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
41
42
|
|
|
42
43
|
Returns:
|
|
43
|
-
pd.
|
|
44
|
+
list[pd.Timestamp]: A list of bond maturities available for the reference date.
|
|
44
45
|
"""
|
|
45
|
-
|
|
46
|
+
rates = indicative_rates(reference_date)
|
|
47
|
+
return rates.index.to_list()
|
|
46
48
|
|
|
47
49
|
|
|
48
50
|
def quotation(
|
|
@@ -21,30 +21,32 @@ def anbima_data(reference_date: str | pd.Timestamp) -> pd.DataFrame:
|
|
|
21
21
|
return an.anbima_data(reference_date, "LTN")
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
def
|
|
24
|
+
def indicative_rates(reference_date: str | pd.Timestamp) -> pd.Series:
|
|
25
25
|
"""
|
|
26
|
-
Fetch
|
|
26
|
+
Fetch the bond indicative rates for the given reference date.
|
|
27
27
|
|
|
28
28
|
Args:
|
|
29
29
|
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
30
30
|
|
|
31
31
|
Returns:
|
|
32
|
-
pd.Series: A Series containing the rates indexed by maturity date.
|
|
32
|
+
pd.Series: A Series containing the bond rates indexed by maturity date.
|
|
33
33
|
"""
|
|
34
|
-
|
|
34
|
+
df = an.anbima_rates(reference_date, "LTN")
|
|
35
|
+
return df.set_index("MaturityDate")["IndicativeRate"]
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
def
|
|
38
|
+
def maturities(reference_date: str | pd.Timestamp) -> list[pd.Timestamp]:
|
|
38
39
|
"""
|
|
39
|
-
Fetch
|
|
40
|
+
Fetch the bond maturities available for the given reference date.
|
|
40
41
|
|
|
41
42
|
Args:
|
|
42
|
-
|
|
43
|
+
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
43
44
|
|
|
44
45
|
Returns:
|
|
45
|
-
pd.
|
|
46
|
+
list[pd.Timestamp]: A list of bond maturities available for the reference date.
|
|
46
47
|
"""
|
|
47
|
-
|
|
48
|
+
rates = indicative_rates(reference_date)
|
|
49
|
+
return rates.index.to_list()
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
def price(
|
|
@@ -34,36 +34,39 @@ def anbima_data(reference_date: str | pd.Timestamp) -> pd.DataFrame:
|
|
|
34
34
|
return an.anbima_data(reference_date, "NTN-B")
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def
|
|
37
|
+
def indicative_rates(reference_date: str | pd.Timestamp) -> pd.Series:
|
|
38
38
|
"""
|
|
39
|
-
Fetch
|
|
39
|
+
Fetch the bond indicative rates for the given reference date.
|
|
40
40
|
|
|
41
41
|
Args:
|
|
42
42
|
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
43
43
|
|
|
44
44
|
Returns:
|
|
45
|
-
pd.Series: A Series containing the rates indexed by maturity date.
|
|
45
|
+
pd.Series: A Series containing the bond rates indexed by maturity date.
|
|
46
46
|
"""
|
|
47
|
-
|
|
47
|
+
df = an.anbima_rates(reference_date, "NTN-B")
|
|
48
|
+
return df.set_index("MaturityDate")["IndicativeRate"]
|
|
48
49
|
|
|
49
50
|
|
|
50
|
-
def
|
|
51
|
+
def maturities(reference_date: str | pd.Timestamp) -> list[pd.Timestamp]:
|
|
51
52
|
"""
|
|
52
|
-
Fetch
|
|
53
|
+
Fetch the bond maturities available for the given reference date.
|
|
53
54
|
|
|
54
55
|
Args:
|
|
55
|
-
|
|
56
|
+
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
56
57
|
|
|
57
58
|
Returns:
|
|
58
|
-
pd.
|
|
59
|
+
list[pd.Timestamp]: A list of bond maturities available for the reference
|
|
60
|
+
date.
|
|
59
61
|
"""
|
|
60
|
-
|
|
62
|
+
rates = indicative_rates(reference_date)
|
|
63
|
+
return rates.index.to_list()
|
|
61
64
|
|
|
62
65
|
|
|
63
66
|
def _coupon_dates_map(
|
|
64
67
|
start: str | pd.Timestamp,
|
|
65
68
|
end: str | pd.Timestamp,
|
|
66
|
-
) -> pd.
|
|
69
|
+
) -> list[pd.Timestamp]:
|
|
67
70
|
"""
|
|
68
71
|
Generate a map of all possible coupon dates between the start and end dates.
|
|
69
72
|
The dates are inclusive. Coupon payments are made on the 15th of February, May,
|
|
@@ -85,20 +88,21 @@ def _coupon_dates_map(
|
|
|
85
88
|
first_coupon_date = pd.Timestamp(f"{reference_year}-02-01")
|
|
86
89
|
|
|
87
90
|
# Generate coupon dates
|
|
88
|
-
|
|
91
|
+
coupon_dates = pd.date_range(start=first_coupon_date, end=end, freq="3MS")
|
|
89
92
|
|
|
90
93
|
# Offset dates by 14 in order to have day 15 of the month
|
|
91
|
-
|
|
94
|
+
coupon_dates += pd.Timedelta(days=14)
|
|
92
95
|
|
|
93
96
|
# First coupon date must be after the reference date
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
coupon_dates = coupon_dates[coupon_dates >= start]
|
|
98
|
+
coupon_dates = pd.Series(coupon_dates).reset_index(drop=True)
|
|
99
|
+
return coupon_dates.to_list()
|
|
96
100
|
|
|
97
101
|
|
|
98
102
|
def coupon_dates(
|
|
99
|
-
|
|
103
|
+
settlement: str | pd.Timestamp,
|
|
100
104
|
maturity: str | pd.Timestamp,
|
|
101
|
-
) -> pd.
|
|
105
|
+
) -> list[pd.Timestamp]:
|
|
102
106
|
"""
|
|
103
107
|
Generate all remaining coupon dates between a given date and the maturity date.
|
|
104
108
|
The dates are inclusive. Coupon payments are made on the 15th of February, May,
|
|
@@ -106,18 +110,20 @@ def coupon_dates(
|
|
|
106
110
|
bond is determined by its maturity date.
|
|
107
111
|
|
|
108
112
|
Args:
|
|
109
|
-
|
|
113
|
+
settlement (str | pd.Timestamp): The settlement date (exlusive) to
|
|
114
|
+
start generating coupon dates.
|
|
110
115
|
maturity_date (str | pd.Timestamp): The maturity date.
|
|
111
116
|
|
|
112
117
|
Returns:
|
|
113
|
-
list[pd.Timestamp]: List of coupon dates between start and maturity dates
|
|
118
|
+
list[pd.Timestamp]: List of coupon dates between start and maturity dates
|
|
119
|
+
sorted in ascending order.
|
|
114
120
|
"""
|
|
115
121
|
# Validate and normalize dates
|
|
116
|
-
|
|
122
|
+
settlement = dc.convert_date(settlement)
|
|
117
123
|
maturity = dc.convert_date(maturity)
|
|
118
124
|
|
|
119
125
|
# Check if maturity date is after the start date
|
|
120
|
-
if maturity <
|
|
126
|
+
if maturity < settlement:
|
|
121
127
|
raise ValueError("Maturity date must be after the start date.")
|
|
122
128
|
|
|
123
129
|
# Check if the maturity date is a valid NTN-B maturity date
|
|
@@ -125,16 +131,17 @@ def coupon_dates(
|
|
|
125
131
|
raise ValueError("NTN-B maturity must be 15/02, 15/05, 15/08, or 15/11.")
|
|
126
132
|
|
|
127
133
|
# Initialize loop variables
|
|
128
|
-
|
|
134
|
+
coupon_dates = maturity
|
|
129
135
|
cp_dates = []
|
|
130
136
|
|
|
131
137
|
# Iterate backwards from the maturity date to the settlement date
|
|
132
|
-
while
|
|
133
|
-
cp_dates.append(
|
|
138
|
+
while coupon_dates > settlement:
|
|
139
|
+
cp_dates.append(coupon_dates)
|
|
134
140
|
# Move the coupon date back 6 months
|
|
135
|
-
|
|
141
|
+
coupon_dates -= pd.DateOffset(months=6)
|
|
136
142
|
|
|
137
|
-
|
|
143
|
+
cp_dates = pd.Series(cp_dates).sort_values(ignore_index=True)
|
|
144
|
+
return cp_dates.to_list()
|
|
138
145
|
|
|
139
146
|
|
|
140
147
|
def quotation(
|
|
@@ -173,7 +180,7 @@ def quotation(
|
|
|
173
180
|
maturity = dc.convert_date(maturity)
|
|
174
181
|
|
|
175
182
|
# Get the coupon dates between the settlement and maturity dates
|
|
176
|
-
payment_dates = coupon_dates(settlement, maturity)
|
|
183
|
+
payment_dates = pd.Series(coupon_dates(settlement, maturity))
|
|
177
184
|
|
|
178
185
|
# Coupon payment dates must be after the settlement date
|
|
179
186
|
payment_dates = payment_dates[payment_dates > settlement]
|
|
@@ -23,6 +23,48 @@ FINAL_PMT = 1048.80885
|
|
|
23
23
|
di_data = di.DIData()
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
def maturities(reference_date: str | pd.Timestamp) -> list[pd.Timestamp]:
|
|
27
|
+
"""
|
|
28
|
+
Fetch the NTN-F bond maturities available for the given reference date.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
list[pd.Timestamp]: A list of NTN-F bond maturities available for the reference
|
|
35
|
+
date.
|
|
36
|
+
"""
|
|
37
|
+
rates = indicative_rates(reference_date)
|
|
38
|
+
return rates.index.to_list()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def anbima_data(reference_date: str | pd.Timestamp) -> pd.DataFrame:
|
|
42
|
+
"""
|
|
43
|
+
Fetch NTN-F Anbima data for the given reference date.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
pd.DataFrame: A DataFrame containing the Anbima data for the reference date.
|
|
50
|
+
"""
|
|
51
|
+
return an.anbima_data(reference_date, "NTN-F")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def indicative_rates(reference_date: str | pd.Timestamp) -> pd.Series:
|
|
55
|
+
"""
|
|
56
|
+
Fetch the bond indicative rates for the given reference date.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
pd.Series: A Series containing the bond rates indexed by maturity date.
|
|
63
|
+
"""
|
|
64
|
+
df = an.anbima_rates(reference_date, "NTN-F")
|
|
65
|
+
return df.set_index("MaturityDate")["IndicativeRate"]
|
|
66
|
+
|
|
67
|
+
|
|
26
68
|
def check_maturity_date(maturity: pd.Timestamp) -> None:
|
|
27
69
|
"""
|
|
28
70
|
Check if the maturity date is a valid NTN-F maturity date.
|
|
@@ -40,7 +82,7 @@ def check_maturity_date(maturity: pd.Timestamp) -> None:
|
|
|
40
82
|
def coupon_dates(
|
|
41
83
|
settlement: str | pd.Timestamp,
|
|
42
84
|
maturity: str | pd.Timestamp,
|
|
43
|
-
) -> pd.
|
|
85
|
+
) -> list[pd.Timestamp]:
|
|
44
86
|
"""
|
|
45
87
|
Generate all remaining coupon dates between a settlement date and a maturity date.
|
|
46
88
|
The dates are exclusive for the settlement date and inclusive for the maturity date.
|
|
@@ -155,72 +197,6 @@ def price(
|
|
|
155
197
|
return ut.truncate(dcf.sum(), 6)
|
|
156
198
|
|
|
157
199
|
|
|
158
|
-
def maturities(reference_date: str | pd.Timestamp) -> list[pd.Timestamp]:
|
|
159
|
-
"""
|
|
160
|
-
Fetch the NTN-F bond maturities available for the given reference date.
|
|
161
|
-
|
|
162
|
-
Args:
|
|
163
|
-
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
164
|
-
|
|
165
|
-
Returns:
|
|
166
|
-
list[pd.Timestamp]: A list of NTN-F bond maturities available for the reference
|
|
167
|
-
date.
|
|
168
|
-
"""
|
|
169
|
-
rates = an.get_anbima_rates(reference_date, "NTN-F")
|
|
170
|
-
return rates.index.to_list()
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
def anbima_data(reference_date: str | pd.Timestamp) -> pd.DataFrame:
|
|
174
|
-
"""
|
|
175
|
-
Fetch NTN-F Anbima data for the given reference date.
|
|
176
|
-
|
|
177
|
-
Args:
|
|
178
|
-
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
179
|
-
|
|
180
|
-
Returns:
|
|
181
|
-
pd.DataFrame: A DataFrame containing the Anbima data for the reference date.
|
|
182
|
-
"""
|
|
183
|
-
return an.anbima_data(reference_date, "NTN-F")
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def indicative_rates(
|
|
187
|
-
reference_date: str | pd.Timestamp,
|
|
188
|
-
maturity: str | pd.Timestamp | None = None,
|
|
189
|
-
) -> pd.Series | float:
|
|
190
|
-
"""
|
|
191
|
-
Fetch NTN-F Anbima indicative rates for the given reference date. If a maturity date
|
|
192
|
-
is provided, the function returns the rate for the given maturity date.
|
|
193
|
-
|
|
194
|
-
Args:
|
|
195
|
-
reference_date (str | pd.Timestamp): The reference date for fetching the data.
|
|
196
|
-
maturity_date (str | pd.Timestamp, optional): The maturity date of the bond.
|
|
197
|
-
|
|
198
|
-
Returns:
|
|
199
|
-
pd.Series: A Series containing the rates indexed by maturity date.
|
|
200
|
-
"""
|
|
201
|
-
rates = an.get_anbima_rates(reference_date, "NTN-F")
|
|
202
|
-
if maturity:
|
|
203
|
-
maturity = dc.convert_date(maturity)
|
|
204
|
-
if maturity in rates.index:
|
|
205
|
-
return float(rates[maturity])
|
|
206
|
-
else:
|
|
207
|
-
return float("nan")
|
|
208
|
-
return rates
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
def anbima_historical_rates(maturity_date: str | pd.Timestamp) -> pd.Series:
|
|
212
|
-
"""
|
|
213
|
-
Fetch historical NTN-F Anbima indicative rates for the given maturity date.
|
|
214
|
-
|
|
215
|
-
Args:
|
|
216
|
-
maturity_date (str | pd.Timestamp): The maturity date of the bond.
|
|
217
|
-
|
|
218
|
-
Returns:
|
|
219
|
-
pd.Series: A Series containing the rates for the given maturity date.
|
|
220
|
-
"""
|
|
221
|
-
return an.get_anbima_historical_rates("NTN-F", maturity_date)
|
|
222
|
-
|
|
223
|
-
|
|
224
200
|
def _calculate_coupons_pv(
|
|
225
201
|
bootstrap_df: pd.DataFrame,
|
|
226
202
|
settlement: pd.Timestamp,
|
|
@@ -190,8 +190,8 @@ class RatesData:
|
|
|
190
190
|
) -> pd.DataFrame:
|
|
191
191
|
cls._check_for_updates()
|
|
192
192
|
df = cls._df.copy()
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
reference_date = dc.convert_date(reference_date)
|
|
194
|
+
df.query("ReferenceDate == @reference_date", inplace=True)
|
|
195
195
|
if bond_type is not None:
|
|
196
196
|
df.query("BondType == @bond_type", inplace=True)
|
|
197
197
|
|
|
@@ -199,7 +199,7 @@ class RatesData:
|
|
|
199
199
|
|
|
200
200
|
|
|
201
201
|
def anbima_rates(
|
|
202
|
-
reference_date: str | pd.Timestamp
|
|
202
|
+
reference_date: str | pd.Timestamp,
|
|
203
203
|
bond_type: str | None = None,
|
|
204
204
|
) -> pd.DataFrame:
|
|
205
205
|
"""
|
|
@@ -221,53 +221,9 @@ def anbima_rates(
|
|
|
221
221
|
|
|
222
222
|
Examples:
|
|
223
223
|
# Fetch ANBIMA rates for all bonds in a specific reference date
|
|
224
|
-
>>>
|
|
224
|
+
>>> anbima_rates("18-06-2024")
|
|
225
225
|
# Fetch ANBIMA data for NTN-B bonds in a specific reference date
|
|
226
|
-
>>>
|
|
226
|
+
>>> anbima_rates("NTN-B", "18-06-2024")
|
|
227
227
|
"""
|
|
228
|
-
if reference_date is not None:
|
|
229
|
-
reference_date = dc.convert_date(reference_date)
|
|
230
|
-
return RatesData.rates(reference_date, bond_type)
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
def get_anbima_rates(
|
|
234
|
-
reference_date: str | pd.Timestamp,
|
|
235
|
-
bond_type: str,
|
|
236
|
-
) -> pd.Series:
|
|
237
|
-
df = anbima_rates(reference_date, bond_type)
|
|
238
|
-
df.drop(columns=["BondType"], inplace=True)
|
|
239
|
-
# Set MaturityDate as index
|
|
240
|
-
df = df.set_index("MaturityDate")
|
|
241
|
-
# Return as Series
|
|
242
|
-
return df["IndicativeRate"]
|
|
243
|
-
|
|
244
228
|
|
|
245
|
-
|
|
246
|
-
bond_type: str,
|
|
247
|
-
maturity_date: str | pd.Timestamp,
|
|
248
|
-
) -> pd.Series:
|
|
249
|
-
# Normalize maturity date
|
|
250
|
-
maturity_date = dc.convert_date(maturity_date)
|
|
251
|
-
|
|
252
|
-
# Get historical rates for the given bond type
|
|
253
|
-
df = anbima_rates(bond_type=bond_type)
|
|
254
|
-
|
|
255
|
-
# Filter rates for the specified maturity date
|
|
256
|
-
df.query("MaturityDate == @maturity_date", inplace=True)
|
|
257
|
-
|
|
258
|
-
# Drop unnecessary columns and sort by reference date
|
|
259
|
-
df.drop(columns=["BondType", "MaturityDate"], inplace=True)
|
|
260
|
-
df.sort_values(["ReferenceDate"], ignore_index=True, inplace=True)
|
|
261
|
-
|
|
262
|
-
# Set ReferenceDate as index
|
|
263
|
-
df = df.set_index("ReferenceDate")
|
|
264
|
-
|
|
265
|
-
# Set the indicative rate as the Series to return
|
|
266
|
-
rates = df["IndicativeRate"]
|
|
267
|
-
|
|
268
|
-
# Raise an error if no rates are found
|
|
269
|
-
if rates.empty:
|
|
270
|
-
maturity = maturity_date.strftime("%d-%m-%Y")
|
|
271
|
-
raise ValueError(f"No rates found for {bond_type} with maturity {maturity}.")
|
|
272
|
-
|
|
273
|
-
return rates
|
|
229
|
+
return RatesData.rates(reference_date, bond_type)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.13.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|