PYield 0.11.2__tar.gz → 0.11.3__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.3}/PKG-INFO +1 -1
- pyield-0.11.3/pyield/__about__.py +1 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/anbima.py +24 -9
- {pyield-0.11.2 → pyield-0.11.3}/pyproject.toml +1 -1
- pyield-0.11.2/pyield/__about__.py +0 -1
- {pyield-0.11.2 → pyield-0.11.3}/LICENSE +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/README.md +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/bday.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/lft.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/ltn.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/ntnb.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/ntnf.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/utils.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/date_converter.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/common.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/historical.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/intraday.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/xml.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/indicators.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/projections.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/interpolator.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/pyield/py.typed +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/tests/__init__.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/tests/data/SPRD231222.zip +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/tests/data/SPRD240426.zip +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/tests/test_bday.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/tests/test_futures.py +0 -0
- {pyield-0.11.2 → pyield-0.11.3}/tests/test_futures_xml.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.11.3"
|
|
@@ -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,10 +36,16 @@ 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
|
-
|
|
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
|
|
48
|
+
|
|
36
49
|
except requests.exceptions.RequestException:
|
|
37
50
|
# Blind attempt to access the member URL
|
|
38
51
|
pass
|
|
@@ -40,12 +53,14 @@ def _get_file_content(reference_date: pd.Timestamp) -> str:
|
|
|
40
53
|
# If the member URL fails, tries to access the non-member URL
|
|
41
54
|
try:
|
|
42
55
|
file_url = f"{ANBIMA_URL}{filename}"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
r = requests.get(file_url, timeout=5)
|
|
57
|
+
r.raise_for_status() # Checks if the second attempt was successful
|
|
58
|
+
file_content = r.text
|
|
46
59
|
except requests.exceptions.RequestException:
|
|
47
60
|
# Both URLs failed
|
|
48
|
-
|
|
61
|
+
file_content = ""
|
|
62
|
+
|
|
63
|
+
return file_content
|
|
49
64
|
|
|
50
65
|
|
|
51
66
|
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
|