PYield 0.11.2__tar.gz → 0.11.4__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.2 → pyield-0.11.4}/PKG-INFO +1 -1
- pyield-0.11.4/pyield/__about__.py +1 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/anbima.py +28 -16
- {pyield-0.11.2 → pyield-0.11.4}/pyproject.toml +1 -1
- pyield-0.11.2/pyield/__about__.py +0 -1
- {pyield-0.11.2 → pyield-0.11.4}/LICENSE +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/README.md +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/bday.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/bonds/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/bonds/lft.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/bonds/ltn.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/bonds/ntnb.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/bonds/ntnf.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/bonds/utils.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/date_converter.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/futures_data/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/futures_data/common.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/futures_data/historical.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/futures_data/intraday.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/futures_data/xml.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/indicators.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/fetchers/projections.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/holidays/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/interpolator.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/pyield/py.typed +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/tests/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/tests/test_bday.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/tests/test_futures.py +0 -0
- {pyield-0.11.2 → pyield-0.11.4}/tests/test_futures_xml.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.11.4"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import io
|
|
2
2
|
import os
|
|
3
|
+
import zipfile as zp
|
|
3
4
|
|
|
4
5
|
import pandas as pd
|
|
5
6
|
import requests
|
|
@@ -10,13 +11,19 @@ from .. import date_converter as dc
|
|
|
10
11
|
ANBIMA_URL = "https://www.anbima.com.br/informacoes/merc-sec/arqs/"
|
|
11
12
|
# URL example: https://www.anbima.com.br/informacoes/merc-sec/arqs/ms240614.txt
|
|
12
13
|
RATES_URL = (
|
|
13
|
-
"https://raw.githubusercontent.com/crdcj/
|
|
14
|
+
"https://raw.githubusercontent.com/crdcj/pyield-data/main/anbima_rates.csv.gz"
|
|
14
15
|
)
|
|
15
16
|
|
|
17
|
+
# Before 13/05/2014 the file was zipped and the endpoint ended with ".exe"
|
|
18
|
+
FORMAT_CHANGE_DATE = pd.to_datetime("13-05-2014", dayfirst=True)
|
|
19
|
+
|
|
16
20
|
|
|
17
21
|
def _get_file_content(reference_date: pd.Timestamp) -> str:
|
|
18
22
|
url_date = reference_date.strftime("%y%m%d")
|
|
19
|
-
|
|
23
|
+
if reference_date < FORMAT_CHANGE_DATE:
|
|
24
|
+
filename = f"ms{url_date}.exe"
|
|
25
|
+
else:
|
|
26
|
+
filename = f"ms{url_date}.txt"
|
|
20
27
|
|
|
21
28
|
# Tries to access the member URL first
|
|
22
29
|
try:
|
|
@@ -29,23 +36,28 @@ def _get_file_content(reference_date: pd.Timestamp) -> str:
|
|
|
29
36
|
anbima_headers = None
|
|
30
37
|
|
|
31
38
|
file_url = f"{anbima_member_url}{filename}"
|
|
32
|
-
|
|
39
|
+
r = requests.get(file_url, headers=anbima_headers, timeout=5)
|
|
33
40
|
# Checks if the response was successful (status code 200)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
r.raise_for_status()
|
|
42
|
+
|
|
43
|
+
if reference_date < FORMAT_CHANGE_DATE:
|
|
44
|
+
zip_file = zp.ZipFile(io.BytesIO(r.content))
|
|
45
|
+
file_content = zip_file.read(zip_file.namelist()[0]).decode("latin-1")
|
|
46
|
+
else:
|
|
47
|
+
file_content = r.text
|
|
39
48
|
|
|
40
|
-
# If the member URL fails, tries to access the non-member URL
|
|
41
|
-
try:
|
|
42
|
-
file_url = f"{ANBIMA_URL}{filename}"
|
|
43
|
-
response = requests.get(file_url, timeout=5)
|
|
44
|
-
response.raise_for_status() # Checks if the second attempt was successful
|
|
45
|
-
return response.text
|
|
46
49
|
except requests.exceptions.RequestException:
|
|
47
|
-
#
|
|
48
|
-
|
|
50
|
+
# If the member URL fails, tries to access the non-member URL
|
|
51
|
+
try:
|
|
52
|
+
file_url = f"{ANBIMA_URL}{filename}"
|
|
53
|
+
r = requests.get(file_url, timeout=5)
|
|
54
|
+
r.raise_for_status() # Checks if the second attempt was successful
|
|
55
|
+
file_content = r.text
|
|
56
|
+
except requests.exceptions.RequestException:
|
|
57
|
+
# Both URLs failed
|
|
58
|
+
file_content = ""
|
|
59
|
+
|
|
60
|
+
return file_content
|
|
49
61
|
|
|
50
62
|
|
|
51
63
|
def _read_raw_df(file_content: str) -> pd.DataFrame:
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.11.2"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|