PYield 0.30.3__tar.gz → 0.30.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 (49) hide show
  1. {pyield-0.30.3 → pyield-0.30.4}/PKG-INFO +1 -1
  2. pyield-0.30.4/pyield/__about__.py +1 -0
  3. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/di.py +25 -18
  4. {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/tools.py +2 -2
  5. pyield-0.30.3/pyield/__about__.py +0 -1
  6. {pyield-0.30.3 → pyield-0.30.4}/.gitignore +0 -0
  7. {pyield-0.30.3 → pyield-0.30.4}/LICENSE +0 -0
  8. {pyield-0.30.3 → pyield-0.30.4}/README.md +0 -0
  9. {pyield-0.30.3 → pyield-0.30.4}/pyield/__init__.py +0 -0
  10. {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/__init__.py +0 -0
  11. {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/ettj.py +0 -0
  12. {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/ima.py +0 -0
  13. {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/imaq.py +0 -0
  14. {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/ipca.py +0 -0
  15. {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/tpf.py +0 -0
  16. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/__init__.py +0 -0
  17. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/di_over.py +0 -0
  18. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/__init__.py +0 -0
  19. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/common.py +0 -0
  20. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/historical.py +0 -0
  21. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/intraday.py +0 -0
  22. {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/xml.py +0 -0
  23. {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/__init__.py +0 -0
  24. {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/auction.py +0 -0
  25. {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/bcdata.py +0 -0
  26. {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/ptax.py +0 -0
  27. {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/repo.py +0 -0
  28. {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/trade.py +0 -0
  29. {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/vna.py +0 -0
  30. {pyield-0.30.3 → pyield-0.30.4}/pyield/bday.py +0 -0
  31. {pyield-0.30.3 → pyield-0.30.4}/pyield/conftest.py +0 -0
  32. {pyield-0.30.3 → pyield-0.30.4}/pyield/data_cache.py +0 -0
  33. {pyield-0.30.3 → pyield-0.30.4}/pyield/date_converter.py +0 -0
  34. {pyield-0.30.3 → pyield-0.30.4}/pyield/forwards.py +0 -0
  35. {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/__init__.py +0 -0
  36. {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/br_holidays_new.txt +0 -0
  37. {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/br_holidays_old.txt +0 -0
  38. {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/brholidays.py +0 -0
  39. {pyield-0.30.3 → pyield-0.30.4}/pyield/ibge/__init__.py +0 -0
  40. {pyield-0.30.3 → pyield-0.30.4}/pyield/ibge/ipca.py +0 -0
  41. {pyield-0.30.3 → pyield-0.30.4}/pyield/interpolator.py +0 -0
  42. {pyield-0.30.3 → pyield-0.30.4}/pyield/py.typed +0 -0
  43. {pyield-0.30.3 → pyield-0.30.4}/pyield/retry.py +0 -0
  44. {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/__init__.py +0 -0
  45. {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/lft.py +0 -0
  46. {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/ltn.py +0 -0
  47. {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/ntnb.py +0 -0
  48. {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/ntnf.py +0 -0
  49. {pyield-0.30.3 → pyield-0.30.4}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PYield
3
- Version: 0.30.3
3
+ Version: 0.30.4
4
4
  Summary: A Python library for analysis of fixed income instruments in Brazil
5
5
  Project-URL: Source, https://github.com/crdcj/PYield
6
6
  Author-email: Carlos Carvalho <cr.cj@outlook.com>
@@ -0,0 +1 @@
1
+ __version__ = "0.30.4"
@@ -1,3 +1,5 @@
1
+ import logging
2
+
1
3
  import pandas as pd
2
4
 
3
5
  import pyield.date_converter as dc
@@ -6,6 +8,8 @@ from pyield import b3, bday, interpolator
6
8
  from pyield.data_cache import get_anbima_dataset, get_di_dataset
7
9
  from pyield.date_converter import DateArray, DateScalar
8
10
 
11
+ logger = logging.getLogger(__name__)
12
+
9
13
 
10
14
  class DIFutures:
11
15
  """
@@ -61,7 +65,7 @@ class DIFutures:
61
65
 
62
66
  def __init__(
63
67
  self,
64
- date: DateScalar | None = None,
68
+ date: DateScalar,
65
69
  month_start: bool = False,
66
70
  pre_filter: bool = False,
67
71
  all_columns: bool = True,
@@ -100,19 +104,22 @@ class DIFutures:
100
104
 
101
105
  def _update_df(self) -> pd.DataFrame:
102
106
  """Retrieve DI contract DataFrame for the initialized trade date."""
103
- bz_today = pd.Timestamp.today(tz="America/Sao_Paulo").normalize()
104
- if bz_today == self.date:
105
- # Try to get intraday data
106
- df = b3.futures(contract_code="DI1", date=bz_today)
107
- else:
108
- # Get historical data
109
- df = (
110
- get_di_dataset()
111
- .query("TradeDate == @self._date")
112
- .reset_index(drop=True)
113
- )
107
+ # Return an empty DataFrame if the trade date is a holiday
108
+ if not bday.is_business_day(self._date):
109
+ logger.warning("Specified date is not a business day.")
110
+ logger.warning("Returning empty DataFrame.")
111
+ return pd.DataFrame()
112
+
113
+ # Get historical data
114
+ df = get_di_dataset().query("TradeDate == @self._date").reset_index(drop=True)
115
+
116
+ if df.empty:
117
+ logger.info("No historical data found. Trying real-time data.")
118
+ df = b3.futures(contract_code="DI1", date=self._date)
114
119
 
115
120
  if df.empty:
121
+ logger.warning("No DI Futures data found for the specified date.")
122
+ logger.warning("Returning empty DataFrame.")
116
123
  return pd.DataFrame()
117
124
 
118
125
  if "DaysToExpiration" in df.columns:
@@ -349,12 +356,12 @@ class DIFutures:
349
356
  return self._date
350
357
 
351
358
  @date.setter
352
- def date(self, value: DateScalar | None):
353
- if value:
354
- self._date = dc.convert_input_dates(value)
355
- else:
356
- self._date = self.historical_dates.max()
357
-
359
+ def date(self, value: DateScalar):
360
+ self._date = dc.convert_input_dates(value)
361
+ bz_today = pd.Timestamp.today(tz="America/Sao_Paulo")
362
+ bz_today = bz_today.normalize().tz_localize(None)
363
+ if self._date > bz_today:
364
+ raise ValueError("Trade date cannot be in the future.")
358
365
  self._dirty = True
359
366
 
360
367
  @property
@@ -79,8 +79,8 @@ def pre_spreads(date: DateScalar) -> pd.DataFrame:
79
79
  converted_date = dc.convert_input_dates(date)
80
80
  di = DIFutures(date=converted_date, month_start=True)
81
81
  df_di = di.df
82
- if "SettlementRate" not in df_di.columns:
83
- raise ValueError("DI rates data is missing the 'SettlementRate' column.")
82
+ if "SettlementRate" not in df_di.columns or df_di.empty:
83
+ raise ValueError("DI data is missing the 'SettlementRate' column or is empty.")
84
84
 
85
85
  df_di = df_di[["ExpirationDate", "SettlementRate"]].copy()
86
86
 
@@ -1 +0,0 @@
1
- __version__ = "0.30.3"
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
File without changes
File without changes