PYield 0.8.4__tar.gz → 0.8.5__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.8.4 → pyield-0.8.5}/PKG-INFO +1 -1
- pyield-0.8.5/pyield/__about__.py +1 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/anbima.py +23 -13
- {pyield-0.8.4 → pyield-0.8.5}/pyproject.toml +1 -1
- pyield-0.8.4/pyield/__about__.py +0 -1
- {pyield-0.8.4 → pyield-0.8.5}/LICENSE +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/README.md +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/__init__.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/bday.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/data_access.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/date_validator.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/__init__.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/common.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/historical.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/intraday.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/xml.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/__init__.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/core.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/indicators.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/interpolator.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/ntnb.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/projections.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/py.typed +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/pyield/spreads.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/tests/__init__.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/tests/test_bday.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/tests/test_futures.py +0 -0
- {pyield-0.8.4 → pyield-0.8.5}/tests/test_futures_xml.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.8.5"
|
|
@@ -4,20 +4,25 @@ import pandas as pd
|
|
|
4
4
|
import requests
|
|
5
5
|
|
|
6
6
|
# URL Constants
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
ANBIMA_URL = "https://www.anbima.com.br/informacoes/merc-sec/arqs/"
|
|
8
|
+
# URL example: https://www.anbima.com.br/informacoes/merc-sec/arqs/ms240614.txt
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
def _get_file_content(reference_date: pd.Timestamp,
|
|
12
|
-
headers = headers or {} # Default empty headers
|
|
11
|
+
def _get_file_content(reference_date: pd.Timestamp, remote_access: dict = None) -> str:
|
|
13
12
|
url_date = reference_date.strftime("%y%m%d")
|
|
14
|
-
|
|
15
|
-
# Non member url example: https://www.anbima.com.br/informacoes/merc-sec/arqs/ms240614.txt
|
|
16
|
-
non_member_url = f"{ANBIMA_NON_MEMBER_URL}ms{url_date}.txt"
|
|
13
|
+
filename = f"ms{url_date}.txt"
|
|
17
14
|
|
|
18
15
|
# Tries to access the member URL first
|
|
19
16
|
try:
|
|
20
|
-
|
|
17
|
+
if remote_access:
|
|
18
|
+
anbima_url = f'{remote_access["anbima_url"]}/merc_sec/arqs/'
|
|
19
|
+
headers = remote_access["headers_dict"]
|
|
20
|
+
else:
|
|
21
|
+
anbima_url = "http://www.anbima.associados.rtm/merc_sec/arqs/"
|
|
22
|
+
headers = None
|
|
23
|
+
|
|
24
|
+
file_url = f"{anbima_url}{filename}"
|
|
25
|
+
response = requests.get(file_url, headers=headers, timeout=5)
|
|
21
26
|
# Checks if the response was successful (status code 200)
|
|
22
27
|
response.raise_for_status()
|
|
23
28
|
return response.text
|
|
@@ -27,7 +32,8 @@ def _get_file_content(reference_date: pd.Timestamp, headers: dict = None) -> str
|
|
|
27
32
|
|
|
28
33
|
# If the member URL fails, tries to access the non-member URL
|
|
29
34
|
try:
|
|
30
|
-
|
|
35
|
+
file_url = f"{ANBIMA_URL}{filename}"
|
|
36
|
+
response = requests.get(file_url, timeout=5)
|
|
31
37
|
response.raise_for_status() # Checks if the second attempt was successful
|
|
32
38
|
return response.text
|
|
33
39
|
except requests.exceptions.RequestException:
|
|
@@ -88,7 +94,9 @@ def _process_raw_df(df_raw: pd.DataFrame) -> pd.DataFrame:
|
|
|
88
94
|
return df.sort_values(["BondType", "MaturityDate"], ignore_index=True)
|
|
89
95
|
|
|
90
96
|
|
|
91
|
-
def fetch_data(
|
|
97
|
+
def fetch_data(
|
|
98
|
+
reference_date: pd.Timestamp, remote_access: dict = None
|
|
99
|
+
) -> pd.DataFrame:
|
|
92
100
|
"""
|
|
93
101
|
Fetches indicative treasury rates from ANBIMA for a specified reference date.
|
|
94
102
|
|
|
@@ -103,7 +111,7 @@ def fetch_data(reference_date: pd.Timestamp, headers: dict = None) -> pd.DataFra
|
|
|
103
111
|
given reference date.
|
|
104
112
|
|
|
105
113
|
"""
|
|
106
|
-
file_content = _get_file_content(reference_date,
|
|
114
|
+
file_content = _get_file_content(reference_date, remote_access)
|
|
107
115
|
|
|
108
116
|
if file_content == "":
|
|
109
117
|
date_str = reference_date.strftime("%d-%m-%Y")
|
|
@@ -114,7 +122,9 @@ def fetch_data(reference_date: pd.Timestamp, headers: dict = None) -> pd.DataFra
|
|
|
114
122
|
return _process_raw_df(df)
|
|
115
123
|
|
|
116
124
|
|
|
117
|
-
def fetch_rates(
|
|
125
|
+
def fetch_rates(
|
|
126
|
+
reference_date: pd.Timestamp, remote_access: dict = None
|
|
127
|
+
) -> pd.DataFrame:
|
|
118
128
|
"""
|
|
119
129
|
Fetches indicative treasury rates from ANBIMA for a specified reference date.
|
|
120
130
|
|
|
@@ -129,5 +139,5 @@ def fetch_rates(reference_date: pd.Timestamp, headers: dict = None) -> pd.DataFr
|
|
|
129
139
|
given reference date.
|
|
130
140
|
|
|
131
141
|
"""
|
|
132
|
-
df = fetch_data(reference_date,
|
|
142
|
+
df = fetch_data(reference_date, remote_access)
|
|
133
143
|
return df[["BondType", "MaturityDate", "IndicativeRate"]].copy()
|
pyield-0.8.4/pyield/__about__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.8.4"
|
|
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
|