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.
Files changed (32) hide show
  1. {pyield-0.8.4 → pyield-0.8.5}/PKG-INFO +1 -1
  2. pyield-0.8.5/pyield/__about__.py +1 -0
  3. {pyield-0.8.4 → pyield-0.8.5}/pyield/anbima.py +23 -13
  4. {pyield-0.8.4 → pyield-0.8.5}/pyproject.toml +1 -1
  5. pyield-0.8.4/pyield/__about__.py +0 -1
  6. {pyield-0.8.4 → pyield-0.8.5}/LICENSE +0 -0
  7. {pyield-0.8.4 → pyield-0.8.5}/README.md +0 -0
  8. {pyield-0.8.4 → pyield-0.8.5}/pyield/__init__.py +0 -0
  9. {pyield-0.8.4 → pyield-0.8.5}/pyield/bday.py +0 -0
  10. {pyield-0.8.4 → pyield-0.8.5}/pyield/data_access.py +0 -0
  11. {pyield-0.8.4 → pyield-0.8.5}/pyield/date_validator.py +0 -0
  12. {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/__init__.py +0 -0
  13. {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/common.py +0 -0
  14. {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/historical.py +0 -0
  15. {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/intraday.py +0 -0
  16. {pyield-0.8.4 → pyield-0.8.5}/pyield/futures/xml.py +0 -0
  17. {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/__init__.py +0 -0
  18. {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/br_holidays_new.txt +0 -0
  19. {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/br_holidays_old.txt +0 -0
  20. {pyield-0.8.4 → pyield-0.8.5}/pyield/holidays/core.py +0 -0
  21. {pyield-0.8.4 → pyield-0.8.5}/pyield/indicators.py +0 -0
  22. {pyield-0.8.4 → pyield-0.8.5}/pyield/interpolator.py +0 -0
  23. {pyield-0.8.4 → pyield-0.8.5}/pyield/ntnb.py +0 -0
  24. {pyield-0.8.4 → pyield-0.8.5}/pyield/projections.py +0 -0
  25. {pyield-0.8.4 → pyield-0.8.5}/pyield/py.typed +0 -0
  26. {pyield-0.8.4 → pyield-0.8.5}/pyield/spreads.py +0 -0
  27. {pyield-0.8.4 → pyield-0.8.5}/tests/__init__.py +0 -0
  28. {pyield-0.8.4 → pyield-0.8.5}/tests/data/SPRD231222.zip +0 -0
  29. {pyield-0.8.4 → pyield-0.8.5}/tests/data/SPRD240426.zip +0 -0
  30. {pyield-0.8.4 → pyield-0.8.5}/tests/test_bday.py +0 -0
  31. {pyield-0.8.4 → pyield-0.8.5}/tests/test_futures.py +0 -0
  32. {pyield-0.8.4 → pyield-0.8.5}/tests/test_futures_xml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PYield
3
- Version: 0.8.4
3
+ Version: 0.8.5
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.8.5"
@@ -4,20 +4,25 @@ import pandas as pd
4
4
  import requests
5
5
 
6
6
  # URL Constants
7
- ANBIMA_NON_MEMBER_URL = "https://www.anbima.com.br/informacoes/merc-sec/arqs/"
8
- ANBIMA_MEMBER_URL = "http://www.anbima.associados.rtm/merc_sec/arqs/"
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, headers: dict = None) -> str:
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
- member_url = f"{ANBIMA_MEMBER_URL}ms{url_date}.txt"
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
- response = requests.get(member_url, headers=headers, timeout=5)
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
- response = requests.get(non_member_url, timeout=5)
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(reference_date: pd.Timestamp, headers: dict = None) -> pd.DataFrame:
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, headers)
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(reference_date: pd.Timestamp, headers: dict = None) -> pd.DataFrame:
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, headers)
142
+ df = fetch_data(reference_date, remote_access)
133
143
  return df[["BondType", "MaturityDate", "IndicativeRate"]].copy()
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "requests>=2.31.0",
33
33
  ]
34
34
  dynamic = []
35
- version = "0.8.4"
35
+ version = "0.8.5"
36
36
 
37
37
  [project.license]
38
38
  file = "LICENSE"
@@ -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