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.
Files changed (36) hide show
  1. {pyield-0.11.2 → pyield-0.11.3}/PKG-INFO +1 -1
  2. pyield-0.11.3/pyield/__about__.py +1 -0
  3. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/anbima.py +24 -9
  4. {pyield-0.11.2 → pyield-0.11.3}/pyproject.toml +1 -1
  5. pyield-0.11.2/pyield/__about__.py +0 -1
  6. {pyield-0.11.2 → pyield-0.11.3}/LICENSE +0 -0
  7. {pyield-0.11.2 → pyield-0.11.3}/README.md +0 -0
  8. {pyield-0.11.2 → pyield-0.11.3}/pyield/__init__.py +0 -0
  9. {pyield-0.11.2 → pyield-0.11.3}/pyield/bday.py +0 -0
  10. {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/__init__.py +0 -0
  11. {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/lft.py +0 -0
  12. {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/ltn.py +0 -0
  13. {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/ntnb.py +0 -0
  14. {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/ntnf.py +0 -0
  15. {pyield-0.11.2 → pyield-0.11.3}/pyield/bonds/utils.py +0 -0
  16. {pyield-0.11.2 → pyield-0.11.3}/pyield/date_converter.py +0 -0
  17. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/__init__.py +0 -0
  18. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/__init__.py +0 -0
  19. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/common.py +0 -0
  20. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/historical.py +0 -0
  21. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/intraday.py +0 -0
  22. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/futures_data/xml.py +0 -0
  23. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/indicators.py +0 -0
  24. {pyield-0.11.2 → pyield-0.11.3}/pyield/fetchers/projections.py +0 -0
  25. {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/__init__.py +0 -0
  26. {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/br_holidays_new.txt +0 -0
  27. {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/br_holidays_old.txt +0 -0
  28. {pyield-0.11.2 → pyield-0.11.3}/pyield/holidays/holidays_manager.py +0 -0
  29. {pyield-0.11.2 → pyield-0.11.3}/pyield/interpolator.py +0 -0
  30. {pyield-0.11.2 → pyield-0.11.3}/pyield/py.typed +0 -0
  31. {pyield-0.11.2 → pyield-0.11.3}/tests/__init__.py +0 -0
  32. {pyield-0.11.2 → pyield-0.11.3}/tests/data/SPRD231222.zip +0 -0
  33. {pyield-0.11.2 → pyield-0.11.3}/tests/data/SPRD240426.zip +0 -0
  34. {pyield-0.11.2 → pyield-0.11.3}/tests/test_bday.py +0 -0
  35. {pyield-0.11.2 → pyield-0.11.3}/tests/test_futures.py +0 -0
  36. {pyield-0.11.2 → pyield-0.11.3}/tests/test_futures_xml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PYield
3
- Version: 0.11.2
3
+ Version: 0.11.3
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>
@@ -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/PYield/main/data/anbima_rates.csv.gz"
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
- filename = f"ms{url_date}.txt"
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
- response = requests.get(file_url, headers=anbima_headers, timeout=5)
39
+ r = requests.get(file_url, headers=anbima_headers, timeout=5)
33
40
  # Checks if the response was successful (status code 200)
34
- response.raise_for_status()
35
- return response.text
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
- response = requests.get(file_url, timeout=5)
44
- response.raise_for_status() # Checks if the second attempt was successful
45
- return response.text
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
- return ""
61
+ file_content = ""
62
+
63
+ return file_content
49
64
 
50
65
 
51
66
  def _read_raw_df(file_content: str) -> pd.DataFrame:
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "requests>=2.31.0",
33
33
  ]
34
34
  dynamic = []
35
- version = "0.11.2"
35
+ version = "0.11.3"
36
36
 
37
37
  [project.license]
38
38
  file = "LICENSE"
@@ -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