PYield 0.9.6__tar.gz → 0.9.7__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.9.6 → pyield-0.9.7}/PKG-INFO +16 -2
- {pyield-0.9.6 → pyield-0.9.7}/README.md +15 -1
- pyield-0.9.7/pyield/__about__.py +1 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/date_validator.py +19 -5
- {pyield-0.9.6 → pyield-0.9.7}/pyield/interpolator.py +2 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyproject.toml +1 -1
- pyield-0.9.6/pyield/__about__.py +0 -1
- {pyield-0.9.6 → pyield-0.9.7}/LICENSE +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/__init__.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/bday.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/__init__.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/anbima.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/futures/__init__.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/futures/common.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/futures/historical.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/futures/intraday.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/futures/xml.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/indicators.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/fetchers/projections.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/holidays/__init__.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/ntnb.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/py.typed +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/pyield/spreads.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/tests/__init__.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/tests/test_bday.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/tests/test_futures.py +0 -0
- {pyield-0.9.6 → pyield-0.9.7}/tests/test_futures_xml.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PYield
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.7
|
|
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>
|
|
@@ -42,7 +42,7 @@ Requires-Dist: requests>=2.31.0
|
|
|
42
42
|
Description-Content-Type: text/markdown
|
|
43
43
|
|
|
44
44
|
[](https://pypi.python.org/pypi/pyield)
|
|
45
|
-
[](https://python.org "Go to Python homepage")
|
|
46
46
|
[](#license)
|
|
47
47
|
|
|
48
48
|
# PYield: Brazilian Fixed Income Toolkit
|
|
@@ -68,6 +68,20 @@ pip install pyield
|
|
|
68
68
|
|
|
69
69
|
## How to use PYield
|
|
70
70
|
|
|
71
|
+
### Important Note on Date Formats
|
|
72
|
+
When using date strings in PYield functions, please ensure that the **date format is day-first** (e.g., "31-05-2024"). This format was chosen to be consistent with the Brazilian date convention.
|
|
73
|
+
|
|
74
|
+
For production code, it is recommended to parse date strings with `pandas.to_datetime` using an **explicit format** to avoid ambiguity and ensure consistency.
|
|
75
|
+
|
|
76
|
+
For example:
|
|
77
|
+
```python
|
|
78
|
+
import pandas as pd
|
|
79
|
+
|
|
80
|
+
# Converting a date string to a pandas Timestamp with a specific format
|
|
81
|
+
date = pd.to_datetime("2024/31/05", format="%Y/%d/%m")
|
|
82
|
+
date = pd.to_datetime("05-31-2024", format="%m-%d-%Y")
|
|
83
|
+
```
|
|
84
|
+
|
|
71
85
|
### Business Days Tools (Brazilian holidays are automatically considered)
|
|
72
86
|
```python
|
|
73
87
|
>>> import pyield as yd
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[](https://pypi.python.org/pypi/pyield)
|
|
2
|
-
[](https://python.org "Go to Python homepage")
|
|
3
3
|
[](#license)
|
|
4
4
|
|
|
5
5
|
# PYield: Brazilian Fixed Income Toolkit
|
|
@@ -25,6 +25,20 @@ pip install pyield
|
|
|
25
25
|
|
|
26
26
|
## How to use PYield
|
|
27
27
|
|
|
28
|
+
### Important Note on Date Formats
|
|
29
|
+
When using date strings in PYield functions, please ensure that the **date format is day-first** (e.g., "31-05-2024"). This format was chosen to be consistent with the Brazilian date convention.
|
|
30
|
+
|
|
31
|
+
For production code, it is recommended to parse date strings with `pandas.to_datetime` using an **explicit format** to avoid ambiguity and ensure consistency.
|
|
32
|
+
|
|
33
|
+
For example:
|
|
34
|
+
```python
|
|
35
|
+
import pandas as pd
|
|
36
|
+
|
|
37
|
+
# Converting a date string to a pandas Timestamp with a specific format
|
|
38
|
+
date = pd.to_datetime("2024/31/05", format="%Y/%d/%m")
|
|
39
|
+
date = pd.to_datetime("05-31-2024", format="%m-%d-%Y")
|
|
40
|
+
```
|
|
41
|
+
|
|
28
42
|
### Business Days Tools (Brazilian holidays are automatically considered)
|
|
29
43
|
```python
|
|
30
44
|
>>> import pyield as yd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.9.7"
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
2
4
|
import pandas as pd
|
|
3
5
|
|
|
4
6
|
from . import bday
|
|
5
7
|
|
|
6
8
|
|
|
7
|
-
def normalize_date(
|
|
9
|
+
def normalize_date(
|
|
10
|
+
input_date: str | pd.Timestamp | np.datetime64 | None = None,
|
|
11
|
+
) -> pd.Timestamp:
|
|
8
12
|
"""
|
|
9
|
-
Normalizes the given date to ensure it is a
|
|
10
|
-
|
|
13
|
+
Normalizes the given date to ensure it is a business day at midnight. If no date is
|
|
14
|
+
provided, it defaults to the last business day available.
|
|
11
15
|
|
|
12
16
|
Args:
|
|
13
|
-
reference_date (str | pd.Timestamp | None): The date to
|
|
14
|
-
|
|
17
|
+
reference_date (str | pd.Timestamp | np.datetime64 | None): The date to
|
|
18
|
+
normalize. If None, it defaults to the last business day. If str, it should be
|
|
19
|
+
with day first format (e.g. "31-05-2024").
|
|
15
20
|
|
|
16
21
|
Returns:
|
|
17
22
|
pd.Timestamp: A normalized pandas Timestamp.
|
|
@@ -29,7 +34,16 @@ def normalize_date(input_date: str | pd.Timestamp | None = None) -> pd.Timestamp
|
|
|
29
34
|
>>> normalize_date("31-05-2024")
|
|
30
35
|
>>> normalize_date(pd.Timestamp("2023-04-01 15:30"))
|
|
31
36
|
"""
|
|
37
|
+
|
|
38
|
+
def starts_with_year(date_str: str) -> bool:
|
|
39
|
+
"""Check if the date string starts with a four-digit year."""
|
|
40
|
+
return bool(re.match(r"^\d{4}-", date_str))
|
|
41
|
+
|
|
32
42
|
if isinstance(input_date, str):
|
|
43
|
+
if starts_with_year(input_date):
|
|
44
|
+
raise ValueError(
|
|
45
|
+
f"Invalid date format: {input_date}. Day first format is required (e.g. '31-05-2024')." # noqa
|
|
46
|
+
)
|
|
33
47
|
# Convert string date to Timestamp and normalize to midnight
|
|
34
48
|
normalized_date = pd.to_datetime(input_date, dayfirst=True).normalize()
|
|
35
49
|
elif isinstance(input_date, pd.Timestamp):
|
pyield-0.9.6/pyield/__about__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.9.6"
|
|
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
|