PYield 0.11.0__tar.gz → 0.11.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.11.0 → pyield-0.11.2}/PKG-INFO +1 -1
- pyield-0.11.2/pyield/__about__.py +1 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/bday.py +32 -37
- {pyield-0.11.0 → pyield-0.11.2}/pyield/bonds/lft.py +1 -1
- {pyield-0.11.0 → pyield-0.11.2}/pyield/bonds/ltn.py +1 -1
- {pyield-0.11.0 → pyield-0.11.2}/pyield/bonds/ntnb.py +1 -1
- {pyield-0.11.0 → pyield-0.11.2}/pyield/bonds/ntnf.py +1 -1
- {pyield-0.11.0 → pyield-0.11.2}/pyield/bonds/utils.py +18 -2
- {pyield-0.11.0 → pyield-0.11.2}/pyield/date_converter.py +14 -3
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/anbima.py +14 -14
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/futures_data/__init__.py +3 -3
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/indicators.py +1 -1
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/projections.py +3 -7
- {pyield-0.11.0 → pyield-0.11.2}/pyproject.toml +1 -1
- pyield-0.11.0/pyield/__about__.py +0 -1
- {pyield-0.11.0 → pyield-0.11.2}/LICENSE +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/README.md +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/__init__.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/bonds/__init__.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/__init__.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/futures_data/common.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/futures_data/historical.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/futures_data/intraday.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/fetchers/futures_data/xml.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/holidays/__init__.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/interpolator.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/pyield/py.typed +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/tests/__init__.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/tests/test_bday.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/tests/test_futures.py +0 -0
- {pyield-0.11.0 → pyield-0.11.2}/tests/test_futures_xml.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.11.2"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import datetime as dt
|
|
2
2
|
from typing import Literal, overload
|
|
3
3
|
|
|
4
4
|
import numpy as np
|
|
@@ -6,7 +6,7 @@ import pandas as pd
|
|
|
6
6
|
|
|
7
7
|
from . import holidays
|
|
8
8
|
|
|
9
|
-
SingleDateTypes = str | np.datetime64 | pd.Timestamp | datetime
|
|
9
|
+
SingleDateTypes = str | np.datetime64 | pd.Timestamp | dt.datetime | dt.date
|
|
10
10
|
SeriesDateTypes = list | tuple | np.ndarray | pd.Series | pd.Index | pd.DatetimeIndex
|
|
11
11
|
|
|
12
12
|
TO_SERIES_TYPES = (list, tuple, np.ndarray, pd.Series, pd.Index, pd.DatetimeIndex)
|
|
@@ -36,7 +36,7 @@ def _normalize_input_dates(
|
|
|
36
36
|
return pd.to_datetime(dates, dayfirst=True).normalize()
|
|
37
37
|
elif isinstance(dates, pd.Timestamp):
|
|
38
38
|
return dates.normalize()
|
|
39
|
-
elif isinstance(dates, (np.datetime64 | datetime)):
|
|
39
|
+
elif isinstance(dates, (np.datetime64 | dt.datetime | dt.date)):
|
|
40
40
|
return pd.Timestamp(dates).normalize()
|
|
41
41
|
elif isinstance(dates, TO_SERIES_TYPES):
|
|
42
42
|
result = pd.to_datetime(dates, dayfirst=True)
|
|
@@ -65,7 +65,7 @@ def _convert_to_numpy_date(
|
|
|
65
65
|
|
|
66
66
|
@overload
|
|
67
67
|
def offset(
|
|
68
|
-
dates: SingleDateTypes
|
|
68
|
+
dates: SingleDateTypes,
|
|
69
69
|
offset: int = 0,
|
|
70
70
|
roll: Literal["forward", "backward"] = "forward",
|
|
71
71
|
holiday_list: Literal["old", "new", "infer"] = "infer",
|
|
@@ -82,7 +82,7 @@ def offset(
|
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
def offset(
|
|
85
|
-
dates: SingleDateTypes | SeriesDateTypes
|
|
85
|
+
dates: SingleDateTypes | SeriesDateTypes,
|
|
86
86
|
offset: int = 0,
|
|
87
87
|
roll: Literal["forward", "backward"] = "forward",
|
|
88
88
|
holiday_list: Literal["old", "new", "infer"] = "infer",
|
|
@@ -95,7 +95,7 @@ def offset(
|
|
|
95
95
|
types and holiday adjustments.
|
|
96
96
|
|
|
97
97
|
Args:
|
|
98
|
-
dates (SingleDateTypes | SeriesDateTypes
|
|
98
|
+
dates (SingleDateTypes | SeriesDateTypes):
|
|
99
99
|
The date(s) to offset. Can be a single date in various formats (string,
|
|
100
100
|
`datetime`, `Timestamp`, etc.) or a collection of dates (list, tuple,
|
|
101
101
|
`Series`, etc.). If None, the current date is used.
|
|
@@ -161,8 +161,8 @@ def offset(
|
|
|
161
161
|
|
|
162
162
|
@overload
|
|
163
163
|
def count(
|
|
164
|
-
start: SingleDateTypes
|
|
165
|
-
end: SingleDateTypes
|
|
164
|
+
start: SingleDateTypes,
|
|
165
|
+
end: SingleDateTypes,
|
|
166
166
|
holiday_list: Literal["old", "new", "infer"] = "infer",
|
|
167
167
|
) -> int: ...
|
|
168
168
|
|
|
@@ -170,14 +170,14 @@ def count(
|
|
|
170
170
|
@overload
|
|
171
171
|
def count(
|
|
172
172
|
start: SeriesDateTypes,
|
|
173
|
-
end: SingleDateTypes
|
|
173
|
+
end: SingleDateTypes,
|
|
174
174
|
holiday_list: Literal["old", "new", "infer"] = "infer",
|
|
175
175
|
) -> pd.Series: ...
|
|
176
176
|
|
|
177
177
|
|
|
178
178
|
@overload
|
|
179
179
|
def count(
|
|
180
|
-
start: SingleDateTypes
|
|
180
|
+
start: SingleDateTypes,
|
|
181
181
|
end: SeriesDateTypes,
|
|
182
182
|
holiday_list: Literal["old", "new", "infer"] = "infer",
|
|
183
183
|
) -> pd.Series: ...
|
|
@@ -192,23 +192,23 @@ def count(
|
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
def count(
|
|
195
|
-
start: SingleDateTypes | SeriesDateTypes
|
|
196
|
-
end: SingleDateTypes | SeriesDateTypes
|
|
195
|
+
start: SingleDateTypes | SeriesDateTypes,
|
|
196
|
+
end: SingleDateTypes | SeriesDateTypes,
|
|
197
197
|
holiday_list: Literal["old", "new", "infer"] = "infer",
|
|
198
198
|
) -> int | pd.Series:
|
|
199
199
|
"""
|
|
200
|
-
Counts the number of business days between a `start` and `end`
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
Counts the number of business days between a `start` date (inclusive) and an `end`
|
|
201
|
+
date (exclusive). The function can handle single dates, arrays of dates and
|
|
202
|
+
mixed inputs, returning either a single integer or a series of integers depending
|
|
203
|
+
on the inputs. It accounts for specified holidays, effectively excluding them from
|
|
204
|
+
the business day count.
|
|
205
205
|
|
|
206
206
|
Args:
|
|
207
|
-
start (SingleDateTypes | SeriesDateTypes
|
|
208
|
-
for counting.
|
|
207
|
+
start (SingleDateTypes | SeriesDateTypes): The start date(s)
|
|
208
|
+
for counting. If None, the current date is used.
|
|
209
209
|
end (SingleDateTypes | SeriesDateTypes| None, optional): The end date(s) for
|
|
210
|
-
counting, which are excluded from the count themselves.
|
|
211
|
-
|
|
210
|
+
counting, which are excluded from the count themselves. If None, the current
|
|
211
|
+
date is used.
|
|
212
212
|
holiday_list (Literal["old", "new", "infer"], optional):
|
|
213
213
|
Specifies which set of holidays to consider in the count. 'old' or 'new'
|
|
214
214
|
refer to predefined holiday lists, while 'infer' automatically selects the
|
|
@@ -232,9 +232,7 @@ def count(
|
|
|
232
232
|
Examples:
|
|
233
233
|
>>> bday.count("2023-12-15", "2024-01-01")
|
|
234
234
|
10
|
|
235
|
-
>>> start =
|
|
236
|
-
>>> end = pd.to_datetime(["2023-01-31", "2023-03-01"])
|
|
237
|
-
>>> bday.count(start, end)
|
|
235
|
+
>>> bday.count(start="01-01-2023", end=["31-01-2023", "01-03-2023"])
|
|
238
236
|
pd.Series([22, 40], dtype='int64')
|
|
239
237
|
"""
|
|
240
238
|
normalized_start = _normalize_input_dates(start)
|
|
@@ -270,11 +268,11 @@ def generate(
|
|
|
270
268
|
|
|
271
269
|
Args:
|
|
272
270
|
start (SingleDateTypes | None, optional):
|
|
273
|
-
The start date for generating business days.
|
|
274
|
-
|
|
275
|
-
end (
|
|
276
|
-
The end date for generating business days.
|
|
277
|
-
|
|
271
|
+
The start date for generating business days. If None, the current date is
|
|
272
|
+
used. Defaults to None.
|
|
273
|
+
end (SingleDateTypes | None, optional):
|
|
274
|
+
The end date for generating business days. If None, the current date is
|
|
275
|
+
used. Defaults to None.
|
|
278
276
|
inclusive (Literal["both", "neither", "left", "right"], optional):
|
|
279
277
|
Determines which of the start and end dates are included in the result.
|
|
280
278
|
Valid options are 'both', 'neither', 'left', 'right'. Defaults to 'both'.
|
|
@@ -282,16 +280,13 @@ def generate(
|
|
|
282
280
|
Specifies the list of holidays to consider. 'old' or 'new' refer to
|
|
283
281
|
predefined lists, 'infer' selects the list based on the most recent date in
|
|
284
282
|
the range. Defaults to "infer".
|
|
285
|
-
**kwargs:
|
|
286
|
-
Additional keyword arguments passed to `pandas.bdate_range` for
|
|
287
|
-
customization.
|
|
288
283
|
|
|
289
284
|
Returns:
|
|
290
285
|
pd.Series: A Series representing a range of business days between the specified
|
|
291
286
|
start and end dates, considering the specified holidays.
|
|
292
287
|
|
|
293
288
|
Examples:
|
|
294
|
-
>>> bday.generate(start="
|
|
289
|
+
>>> bday.generate(start="22-12-2023", end="02-01-2024")
|
|
295
290
|
pd.Series(['2023-12-22', '2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29',
|
|
296
291
|
'2024-01-02'], dtype='datetime64[ns]')
|
|
297
292
|
|
|
@@ -324,16 +319,16 @@ def is_business_day(date: SingleDateTypes | None = None) -> bool:
|
|
|
324
319
|
Checks if the input date is a business day.
|
|
325
320
|
|
|
326
321
|
Args:
|
|
327
|
-
date (
|
|
328
|
-
|
|
322
|
+
date (SingleDateTypes | None, optional): The date to check.
|
|
323
|
+
If None, the current date is used. Defaults to None.
|
|
329
324
|
|
|
330
325
|
Returns:
|
|
331
326
|
bool: True if the input date is a business day, False otherwise.
|
|
332
327
|
|
|
333
328
|
Examples:
|
|
334
|
-
>>>
|
|
329
|
+
>>> bday.is_business_day("25-12-2023") # Christmas
|
|
335
330
|
False
|
|
336
|
-
>>>
|
|
331
|
+
>>> bday.is_business_day() # Check if today is a business day
|
|
337
332
|
True
|
|
338
333
|
"""
|
|
339
334
|
normalized_date = _normalize_input_dates(date)
|
|
@@ -37,7 +37,7 @@ def anbima_historical_rates(maturity_date: str | pd.Timestamp) -> pd.Series:
|
|
|
37
37
|
Fetch historical LFT Anbima indicative rates for the given maturity date.
|
|
38
38
|
|
|
39
39
|
Args:
|
|
40
|
-
maturity_date (str | pd.Timestamp): The maturity date
|
|
40
|
+
maturity_date (str | pd.Timestamp): The maturity date of the bond.
|
|
41
41
|
|
|
42
42
|
Returns:
|
|
43
43
|
pd.Series: A Series containing the rates indexed by reference date.
|
|
@@ -39,7 +39,7 @@ def anbima_historical_rates(maturity_date: str | pd.Timestamp) -> pd.Series:
|
|
|
39
39
|
Fetch historical LTN Anbima indicative rates for the given maturity date.
|
|
40
40
|
|
|
41
41
|
Args:
|
|
42
|
-
maturity_date (str | pd.Timestamp): The maturity date
|
|
42
|
+
maturity_date (str | pd.Timestamp): The maturity date of the bond.
|
|
43
43
|
|
|
44
44
|
Returns:
|
|
45
45
|
pd.Series: A Series containing the rates for the given maturity date.
|
|
@@ -51,7 +51,7 @@ def anbima_historical_rates(maturity_date: str | pd.Timestamp) -> pd.Series:
|
|
|
51
51
|
Fetch historical NTN-B Anbima indicative rates for the given maturity date.
|
|
52
52
|
|
|
53
53
|
Args:
|
|
54
|
-
maturity_date (str | pd.Timestamp): The maturity date
|
|
54
|
+
maturity_date (str | pd.Timestamp): The maturity date of the bond.
|
|
55
55
|
|
|
56
56
|
Returns:
|
|
57
57
|
pd.Series: A Series containing the rates for the given maturity date.
|
|
@@ -188,7 +188,7 @@ def anbima_historical_rates(maturity_date: str | pd.Timestamp) -> pd.Series:
|
|
|
188
188
|
Fetch historical NTN-F Anbima indicative rates for the given maturity date.
|
|
189
189
|
|
|
190
190
|
Args:
|
|
191
|
-
maturity_date (str | pd.Timestamp): The maturity date
|
|
191
|
+
maturity_date (str | pd.Timestamp): The maturity date of the bond.
|
|
192
192
|
|
|
193
193
|
Returns:
|
|
194
194
|
pd.Series: A Series containing the rates for the given maturity date.
|
|
@@ -113,12 +113,28 @@ def get_anbima_historical_rates(
|
|
|
113
113
|
bond_type: str,
|
|
114
114
|
maturity_date: str | pd.Timestamp,
|
|
115
115
|
) -> pd.Series:
|
|
116
|
+
# Normalize maturity date
|
|
116
117
|
maturity_date = dc.convert_date(maturity_date)
|
|
118
|
+
|
|
119
|
+
# Get historical rates for the given bond type
|
|
117
120
|
df = ft.anbima_rates(bond_type=bond_type)
|
|
121
|
+
|
|
122
|
+
# Filter rates for the specified maturity date
|
|
118
123
|
df.query("MaturityDate == @maturity_date", inplace=True)
|
|
124
|
+
|
|
125
|
+
# Drop unnecessary columns and sort by reference date
|
|
119
126
|
df.drop(columns=["BondType", "MaturityDate"], inplace=True)
|
|
120
127
|
df.sort_values(["ReferenceDate"], ignore_index=True, inplace=True)
|
|
128
|
+
|
|
121
129
|
# Set ReferenceDate as index
|
|
122
130
|
df = df.set_index("ReferenceDate")
|
|
123
|
-
|
|
124
|
-
return
|
|
131
|
+
|
|
132
|
+
# Set the indicative rate as the Series to return
|
|
133
|
+
rates = df["IndicativeRate"]
|
|
134
|
+
|
|
135
|
+
# Raise an error if no rates are found
|
|
136
|
+
if rates.empty:
|
|
137
|
+
maturity = maturity_date.strftime("%d-%m-%Y")
|
|
138
|
+
raise ValueError(f"No rates found for {bond_type} with maturity {maturity}.")
|
|
139
|
+
|
|
140
|
+
return rates
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import datetime as dt
|
|
1
2
|
import re
|
|
2
3
|
|
|
3
4
|
import numpy as np
|
|
@@ -12,13 +13,15 @@ def _starts_with_year(date_str: str) -> bool:
|
|
|
12
13
|
return bool(re.match(r"^\d{4}-", date_str))
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
def convert_date(
|
|
16
|
+
def convert_date(
|
|
17
|
+
input_date: str | pd.Timestamp | np.datetime64 | dt.date | dt.datetime,
|
|
18
|
+
) -> pd.Timestamp:
|
|
16
19
|
"""
|
|
17
20
|
Convert a date to pandas Timestamp adjusted to midnight.
|
|
18
21
|
|
|
19
22
|
Args:
|
|
20
|
-
reference_date (str | pd.Timestamp | np.datetime64
|
|
21
|
-
|
|
23
|
+
reference_date (str | pd.Timestamp | np.datetime64): The date to convert.
|
|
24
|
+
If str, it should be with day first format (e.g. "31-05-2024").
|
|
22
25
|
|
|
23
26
|
Returns:
|
|
24
27
|
pd.Timestamp: A normalized pandas Timestamp.
|
|
@@ -35,6 +38,8 @@ def convert_date(input_date: str | pd.Timestamp | np.datetime64) -> pd.Timestamp
|
|
|
35
38
|
Timestamp('2024-05-31 00:00:00')
|
|
36
39
|
"""
|
|
37
40
|
match input_date:
|
|
41
|
+
case None:
|
|
42
|
+
raise ValueError("Date cannot be None.")
|
|
38
43
|
case str():
|
|
39
44
|
if _starts_with_year(input_date):
|
|
40
45
|
raise ValueError(
|
|
@@ -48,6 +53,12 @@ def convert_date(input_date: str | pd.Timestamp | np.datetime64) -> pd.Timestamp
|
|
|
48
53
|
case np.datetime64():
|
|
49
54
|
# Convert numpy datetime to pandas Timestamp
|
|
50
55
|
output_date = pd.Timestamp(input_date)
|
|
56
|
+
case dt.date():
|
|
57
|
+
# Convert datetime.date to pandas Timestamp
|
|
58
|
+
output_date = pd.Timestamp(input_date)
|
|
59
|
+
case dt.datetime():
|
|
60
|
+
# Convert datetime.datetime to pandas Timestamp
|
|
61
|
+
output_date = pd.Timestamp(input_date)
|
|
51
62
|
case _:
|
|
52
63
|
raise ValueError(f"Date format not recognized: {input_date}")
|
|
53
64
|
# Normalize the final date to midnight
|
|
@@ -104,20 +104,19 @@ def anbima_data(
|
|
|
104
104
|
ANBIMA, processing them into a structured pandas DataFrame.
|
|
105
105
|
|
|
106
106
|
Args:
|
|
107
|
-
reference_date (str | pd.Timestamp
|
|
108
|
-
|
|
109
|
-
format 'dd-mm-yyyy'.
|
|
107
|
+
reference_date (str | pd.Timestamp): The date for which to fetch the indicative
|
|
108
|
+
rates. If a string is provided, it should be in the format 'dd-mm-yyyy'.
|
|
110
109
|
bond_type (str, optional): The type of bond to filter by. Defaults to None.
|
|
111
110
|
|
|
112
111
|
Returns:
|
|
113
|
-
pd.DataFrame: A DataFrame containing the processed
|
|
112
|
+
pd.DataFrame: A DataFrame containing the processed ANBIMA data for the
|
|
114
113
|
given reference date.
|
|
115
114
|
|
|
116
115
|
Examples:
|
|
117
116
|
# Fetch ANBIMA data for all bonds in a specific reference date
|
|
118
|
-
>>>
|
|
117
|
+
>>> anbima_data("18-06-2024")
|
|
119
118
|
# Fetch ANBIMA data for NTN-B bonds in a specific reference date
|
|
120
|
-
>>>
|
|
119
|
+
>>> anbima_data("18-06-2024", "NTN-B")
|
|
121
120
|
"""
|
|
122
121
|
# Normalize the reference date
|
|
123
122
|
normalized_date = dc.convert_date(reference_date)
|
|
@@ -148,7 +147,7 @@ class RatesData:
|
|
|
148
147
|
cls._df = pd.read_csv(
|
|
149
148
|
RATES_URL, parse_dates=["ReferenceDate", "MaturityDate"]
|
|
150
149
|
)
|
|
151
|
-
cls._df["IndicativeRate"]
|
|
150
|
+
cls._df["IndicativeRate"] = (cls._df["IndicativeRate"] / 100).round(6)
|
|
152
151
|
|
|
153
152
|
@classmethod
|
|
154
153
|
def _get_dataframe(cls):
|
|
@@ -175,16 +174,17 @@ def anbima_rates(
|
|
|
175
174
|
bond_type: str | None = None,
|
|
176
175
|
) -> pd.DataFrame:
|
|
177
176
|
"""
|
|
178
|
-
|
|
177
|
+
Gets ANBIMA indicative rates for a specified reference date and bond type.
|
|
179
178
|
|
|
180
|
-
This function retrieves the indicative rates for Brazilian treasury
|
|
181
|
-
|
|
179
|
+
This function retrieves the ANBIMA indicative rates for Brazilian treasury
|
|
180
|
+
securities, processing them into a structured pandas DataFrame.
|
|
182
181
|
|
|
183
182
|
Args:
|
|
184
|
-
reference_date (str | pd.Timestamp
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
bond_type (str, optional): The type of bond to filter by.
|
|
183
|
+
reference_date (str | pd.Timestamp): The date for which to filter the indicative
|
|
184
|
+
rates. If a string is provided, it should be in the format 'dd-mm-yyyy'.
|
|
185
|
+
If None, the function returns all available rates. Defaults to None.
|
|
186
|
+
bond_type (str, optional): The type of bond to filter by. If None, the function
|
|
187
|
+
returns all bond types available. Defaults to None.
|
|
188
188
|
|
|
189
189
|
Returns:
|
|
190
190
|
pd.DataFrame: A DataFrame containing the processed indicative rates for the
|
|
@@ -25,7 +25,7 @@ def futures(
|
|
|
25
25
|
- "WDO": Mini U.S. Dollar Futures from B3.
|
|
26
26
|
- "IND": Ibovespa Futures from B3.
|
|
27
27
|
- "WIN": Mini Ibovespa Futures from B3.
|
|
28
|
-
reference_date (str |
|
|
28
|
+
reference_date (str | pd.Timestamp): The date for which to fetch the data.
|
|
29
29
|
If the reference date is a string, it should be in 'DD-MM-YYYY' format.
|
|
30
30
|
|
|
31
31
|
Returns:
|
|
@@ -36,8 +36,8 @@ def futures(
|
|
|
36
36
|
ValueError: If the futures contract code is not recognized or supported.
|
|
37
37
|
|
|
38
38
|
Examples:
|
|
39
|
-
>>>
|
|
40
|
-
>>>
|
|
39
|
+
>>> futures("DI1", "31-05-2024")
|
|
40
|
+
>>> futures("DDI", "31-05-2024")
|
|
41
41
|
"""
|
|
42
42
|
contract_code = contract_code.upper()
|
|
43
43
|
if contract_code not in SUPPORTED_FUTURES:
|
|
@@ -31,7 +31,7 @@ def ipca_monthly_rate(reference_date: pd.Timestamp) -> float | None:
|
|
|
31
31
|
reference date.
|
|
32
32
|
|
|
33
33
|
Args:
|
|
34
|
-
reference_date (str | pd.Timestamp
|
|
34
|
+
reference_date (str | pd.Timestamp): The reference date for which data
|
|
35
35
|
is fetched. If a string is passed, it should be in 'DD-MM-YYYY' format.
|
|
36
36
|
|
|
37
37
|
Returns:
|
|
@@ -75,15 +75,11 @@ def ipca_current_month() -> IndicatorProjection:
|
|
|
75
75
|
# Extract projection update date and time from the first row
|
|
76
76
|
update_str = str(data[0][0])
|
|
77
77
|
last_update_str = update_str.split("Atualização:")[-1].strip()
|
|
78
|
-
last_updated = pd.to_datetime(last_update_str, format="%d/%m/%Y - %H:%M h")
|
|
79
78
|
|
|
80
|
-
# Find the
|
|
79
|
+
# Find the text containing the IPCA projection and extract its data
|
|
81
80
|
ipca_data = next(line for line in data if "IPCA1" in line)
|
|
82
81
|
ipca_text = str(ipca_data[-1])
|
|
83
82
|
|
|
84
|
-
# Convert the last element of the IPCA data row to float for the projection value
|
|
85
|
-
ipca_value = round(float(ipca_text) / 100, 4)
|
|
86
|
-
|
|
87
83
|
# Extract and format the reference month
|
|
88
84
|
projection_text = str(ipca_data[1])
|
|
89
85
|
month_str = projection_text.split("(")[-1].split(")")[0]
|
|
@@ -93,8 +89,8 @@ def ipca_current_month() -> IndicatorProjection:
|
|
|
93
89
|
locale.setlocale(locale.LC_TIME, "") # Reset locale to default
|
|
94
90
|
|
|
95
91
|
return IndicatorProjection(
|
|
96
|
-
last_updated=
|
|
92
|
+
last_updated=pd.to_datetime(last_update_str, format="%d/%m/%Y - %H:%M h"),
|
|
97
93
|
reference_month_ts=ipca_month_ts,
|
|
98
94
|
reference_month_br=ipca_month_br,
|
|
99
|
-
projected_value=
|
|
95
|
+
projected_value=round(float(ipca_text) / 100, 4),
|
|
100
96
|
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.11.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
|