PYield 0.9.2__tar.gz → 0.9.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.
Files changed (32) hide show
  1. {pyield-0.9.2 → pyield-0.9.4}/PKG-INFO +1 -1
  2. pyield-0.9.4/pyield/__about__.py +1 -0
  3. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/anbima.py +11 -15
  4. {pyield-0.9.2 → pyield-0.9.4}/pyproject.toml +1 -1
  5. pyield-0.9.2/pyield/__about__.py +0 -1
  6. {pyield-0.9.2 → pyield-0.9.4}/LICENSE +0 -0
  7. {pyield-0.9.2 → pyield-0.9.4}/README.md +0 -0
  8. {pyield-0.9.2 → pyield-0.9.4}/pyield/__init__.py +0 -0
  9. {pyield-0.9.2 → pyield-0.9.4}/pyield/bday.py +0 -0
  10. {pyield-0.9.2 → pyield-0.9.4}/pyield/date_validator.py +0 -0
  11. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/__init__.py +0 -0
  12. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/futures/__init__.py +0 -0
  13. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/futures/common.py +0 -0
  14. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/futures/historical.py +0 -0
  15. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/futures/intraday.py +0 -0
  16. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/futures/xml.py +0 -0
  17. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/indicators.py +0 -0
  18. {pyield-0.9.2 → pyield-0.9.4}/pyield/fetchers/projections.py +0 -0
  19. {pyield-0.9.2 → pyield-0.9.4}/pyield/holidays/__init__.py +0 -0
  20. {pyield-0.9.2 → pyield-0.9.4}/pyield/holidays/br_holidays_new.txt +0 -0
  21. {pyield-0.9.2 → pyield-0.9.4}/pyield/holidays/br_holidays_old.txt +0 -0
  22. {pyield-0.9.2 → pyield-0.9.4}/pyield/holidays/holidays_manager.py +0 -0
  23. {pyield-0.9.2 → pyield-0.9.4}/pyield/interpolators.py +0 -0
  24. {pyield-0.9.2 → pyield-0.9.4}/pyield/ntnb.py +0 -0
  25. {pyield-0.9.2 → pyield-0.9.4}/pyield/py.typed +0 -0
  26. {pyield-0.9.2 → pyield-0.9.4}/pyield/spreads.py +0 -0
  27. {pyield-0.9.2 → pyield-0.9.4}/tests/__init__.py +0 -0
  28. {pyield-0.9.2 → pyield-0.9.4}/tests/data/SPRD231222.zip +0 -0
  29. {pyield-0.9.2 → pyield-0.9.4}/tests/data/SPRD240426.zip +0 -0
  30. {pyield-0.9.2 → pyield-0.9.4}/tests/test_bday.py +0 -0
  31. {pyield-0.9.2 → pyield-0.9.4}/tests/test_futures.py +0 -0
  32. {pyield-0.9.2 → pyield-0.9.4}/tests/test_futures_xml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PYield
3
- Version: 0.9.2
3
+ Version: 0.9.4
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.9.4"
@@ -1,4 +1,5 @@
1
1
  import io
2
+ import os
2
3
 
3
4
  import pandas as pd
4
5
  import requests
@@ -10,24 +11,22 @@ ANBIMA_URL = "https://www.anbima.com.br/informacoes/merc-sec/arqs/"
10
11
  # URL example: https://www.anbima.com.br/informacoes/merc-sec/arqs/ms240614.txt
11
12
 
12
13
 
13
- def _get_file_content(
14
- reference_date: pd.Timestamp,
15
- remote_access: dict | None = None,
16
- ) -> str:
14
+ def _get_file_content(reference_date: pd.Timestamp) -> str:
17
15
  url_date = reference_date.strftime("%y%m%d")
18
16
  filename = f"ms{url_date}.txt"
19
17
 
20
18
  # Tries to access the member URL first
21
19
  try:
22
- if remote_access:
23
- anbima_url = f'{remote_access["anbima_url"]}/merc_sec/arqs/'
24
- headers = remote_access["headers_dict"]
20
+ anbima_base_url = os.getenv("ANBIMA_BASE_URL")
21
+ if anbima_base_url:
22
+ anbima_member_url = f"{anbima_base_url}/merc_sec/arqs/"
23
+ anbima_headers = {"private-token": os.getenv("ANBIMA_TOKEN")}
25
24
  else:
26
- anbima_url = "http://www.anbima.associados.rtm/merc_sec/arqs/"
27
- headers = None
25
+ anbima_member_url = "http://www.anbima.associados.rtm/merc_sec/arqs/"
26
+ anbima_headers = None
28
27
 
29
- file_url = f"{anbima_url}{filename}"
30
- response = requests.get(file_url, headers=headers, timeout=5)
28
+ file_url = f"{anbima_member_url}{filename}"
29
+ response = requests.get(file_url, headers=anbima_headers, timeout=5)
31
30
  # Checks if the response was successful (status code 200)
32
31
  response.raise_for_status()
33
32
  return response.text
@@ -93,7 +92,6 @@ def _process_raw_df(df_raw: pd.DataFrame) -> pd.DataFrame:
93
92
  def anbima(
94
93
  reference_date: str | pd.Timestamp | None = None,
95
94
  bond_type: str | list[str] | None = None,
96
- remote_access: dict | None = None,
97
95
  ) -> pd.DataFrame:
98
96
  """
99
97
  Fetches indicative treasury rates from ANBIMA for a specified reference date.
@@ -106,8 +104,6 @@ def anbima(
106
104
  fetch the indicative rates. If a string is provided, it should be in the
107
105
  format 'dd-mm-yyyy'. Defaults last business day if None.
108
106
  bond_type (str, optional): The type of bond to filter by. Defaults to None.
109
- remote_access (dict, optional): Dictionary containing remote access parameters.
110
- Defaults to None.
111
107
 
112
108
  Returns:
113
109
  pd.DataFrame: A DataFrame containing the processed indicative rates for the
@@ -125,7 +121,7 @@ def anbima(
125
121
  """
126
122
  # Normalize the reference date
127
123
  normalized_date = dv.normalize_date(reference_date)
128
- file_content = _get_file_content(normalized_date, remote_access)
124
+ file_content = _get_file_content(normalized_date)
129
125
 
130
126
  if not file_content:
131
127
  date_str = normalized_date.strftime("%d-%m-%Y")
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "requests>=2.31.0",
33
33
  ]
34
34
  dynamic = []
35
- version = "0.9.2"
35
+ version = "0.9.4"
36
36
 
37
37
  [project.license]
38
38
  file = "LICENSE"
@@ -1 +0,0 @@
1
- __version__ = "0.9.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