PYield 0.20.1__tar.gz → 0.20.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.20.1 → pyield-0.20.2}/PKG-INFO +1 -1
- pyield-0.20.2/pyield/__about__.py +1 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/b3_futures/__init__.py +13 -1
- {pyield-0.20.1 → pyield-0.20.2}/pyield/b3_futures/common.py +3 -3
- {pyield-0.20.1 → pyield-0.20.2}/pyield/b3_futures/historical.py +1 -1
- {pyield-0.20.1 → pyield-0.20.2}/pyield/date_converter.py +17 -17
- {pyield-0.20.1 → pyield-0.20.2}/pyield/projections.py +1 -5
- {pyield-0.20.1 → pyield-0.20.2}/pyproject.toml +1 -1
- pyield-0.20.1/pyield/__about__.py +0 -1
- {pyield-0.20.1 → pyield-0.20.2}/LICENSE +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/README.md +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/__init__.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/anbima.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/b3_futures/intraday.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/b3_futures/xml.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/bday.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/bonds/__init__.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/bonds/bond_tools.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/bonds/lft.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/bonds/ltn.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/bonds/ntnb.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/bonds/ntnf.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/conftest.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/data_cache.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/di.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/holidays/__init__.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/holidays/brholidays.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/indicators.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/interpolator.py +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/py.typed +0 -0
- {pyield-0.20.1 → pyield-0.20.2}/pyield/tools.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.20.2"
|
|
@@ -41,7 +41,19 @@ def futures(
|
|
|
41
41
|
|
|
42
42
|
Examples:
|
|
43
43
|
>>> futures("DI1", "31-05-2024")
|
|
44
|
-
|
|
44
|
+
TradeDate TickerSymbol ... CloseBidRate CloseRate
|
|
45
|
+
0 2024-05-31 DI1M24 ... 0.10404 0.10404
|
|
46
|
+
1 2024-05-31 DI1N24 ... 0.1039 0.10386
|
|
47
|
+
2 2024-05-31 DI1Q24 ... 0.10374 0.10374
|
|
48
|
+
3 2024-05-31 DI1U24 ... 0.10365 0.10355
|
|
49
|
+
...
|
|
50
|
+
>>> futures("DAP", "31-05-2024")
|
|
51
|
+
TradeDate TickerSymbol ... CloseBidRate CloseRate
|
|
52
|
+
0 2024-05-31 DAPM24 ... <NA> <NA>
|
|
53
|
+
1 2024-05-31 DAPN24 ... <NA> <NA>
|
|
54
|
+
2 2024-05-31 DAPQ24 ... <NA> 0.0885
|
|
55
|
+
3 2024-05-31 DAPU24 ... <NA> 0.0865
|
|
56
|
+
...
|
|
45
57
|
"""
|
|
46
58
|
contract_code = contract_code.upper()
|
|
47
59
|
if contract_code not in SUPPORTED_FUTURES:
|
|
@@ -23,13 +23,13 @@ def get_expiration_date(expiration_code: str, expiration_day: int = 1) -> pd.Tim
|
|
|
23
23
|
|
|
24
24
|
Examples:
|
|
25
25
|
>>> get_expiration_date("F23")
|
|
26
|
-
|
|
26
|
+
Timestamp('2023-01-02 00:00:00')
|
|
27
27
|
|
|
28
28
|
>>> get_expiration_date("Z33")
|
|
29
|
-
|
|
29
|
+
Timestamp('2033-12-01 00:00:00')
|
|
30
30
|
|
|
31
31
|
>>> get_expiration_date("A99")
|
|
32
|
-
|
|
32
|
+
NaT
|
|
33
33
|
|
|
34
34
|
Notes:
|
|
35
35
|
The expiration date is calculated based on the format change introduced by B3 on
|
|
@@ -37,7 +37,7 @@ def get_old_expiration_date(
|
|
|
37
37
|
|
|
38
38
|
Examples:
|
|
39
39
|
>>> get_old_expiration_date("JAN3", pd.Timestamp("2001-05-21"))
|
|
40
|
-
|
|
40
|
+
Timestamp('2003-01-02 00:00:00')
|
|
41
41
|
|
|
42
42
|
Notes:
|
|
43
43
|
- In 22-05-2006, B3 changed the format of the DI contract codes. Before that
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import datetime as dt
|
|
2
|
-
import re
|
|
3
2
|
from typing import overload
|
|
4
3
|
|
|
5
4
|
import numpy as np
|
|
6
5
|
import pandas as pd
|
|
7
6
|
|
|
8
7
|
type ScalarDateTypes = str | np.datetime64 | pd.Timestamp | dt.datetime | dt.date
|
|
9
|
-
type
|
|
10
|
-
type ArrayDateTypes = PandasArrayDateTypes | np.ndarray | list | tuple
|
|
8
|
+
type ArrayDateTypes = pd.Series | pd.DatetimeIndex | np.ndarray | list | tuple
|
|
11
9
|
|
|
12
10
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
def validate_date_format(date_str):
|
|
12
|
+
# Primeiro tenta com hífen (-)
|
|
13
|
+
for fmt in ["%d-%m-%Y", "%d/%m/%Y"]:
|
|
14
|
+
try:
|
|
15
|
+
dt.datetime.strptime(date_str, fmt)
|
|
16
|
+
return
|
|
17
|
+
except ValueError:
|
|
18
|
+
continue
|
|
19
|
+
raise ValueError(
|
|
20
|
+
f"Invalid format: {date_str}. Day first is required (e.g. '31-05-2024')."
|
|
21
|
+
)
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
@overload
|
|
@@ -36,25 +35,26 @@ def convert_input_dates(
|
|
|
36
35
|
raise ValueError("'dates' cannot be None.")
|
|
37
36
|
|
|
38
37
|
case str():
|
|
39
|
-
|
|
38
|
+
validate_date_format(dates)
|
|
40
39
|
return pd.to_datetime(dates, dayfirst=True)
|
|
41
40
|
|
|
42
41
|
case dt.datetime() | dt.date() | np.datetime64() | pd.Timestamp():
|
|
43
42
|
return pd.Timestamp(dates).normalize()
|
|
44
43
|
|
|
45
|
-
case pd.Series() |
|
|
44
|
+
case pd.Series() | np.ndarray() | list() | tuple():
|
|
46
45
|
result = pd.Series(dates)
|
|
47
46
|
|
|
48
47
|
if result.empty:
|
|
49
48
|
raise ValueError("'dates' cannot be an empty Array.")
|
|
50
49
|
|
|
51
50
|
if pd.api.types.is_string_dtype(result):
|
|
52
|
-
|
|
51
|
+
# Check first element to validate date format
|
|
52
|
+
validate_date_format(result[0])
|
|
53
53
|
|
|
54
54
|
return pd.to_datetime(result, dayfirst=True).astype("datetime64[ns]")
|
|
55
55
|
|
|
56
56
|
case pd.DatetimeIndex():
|
|
57
|
-
return pd.Series(
|
|
57
|
+
return pd.Series(dates).astype("datetime64[ns]")
|
|
58
58
|
|
|
59
59
|
case _:
|
|
60
60
|
raise ValueError("Invalid input type for 'dates'.")
|
|
@@ -38,11 +38,7 @@ def projection(projection_code: Literal["IPCA_CM"]) -> IndicatorProjection:
|
|
|
38
38
|
|
|
39
39
|
Example:
|
|
40
40
|
>>> projection("IPCA_CM")
|
|
41
|
-
IndicatorProjection(
|
|
42
|
-
reference_period=Period('2024-09', 'M'),
|
|
43
|
-
projected_value=0.0046,
|
|
44
|
-
last_updated=Timestamp('2024-09-27 18:42:00')
|
|
45
|
-
)
|
|
41
|
+
IndicatorProjection(reference_period=Period(...), projected_value=..., ...)
|
|
46
42
|
|
|
47
43
|
"""
|
|
48
44
|
proj_type = str(projection_code).upper()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.20.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
|