PYield 0.30.3__tar.gz → 0.30.6__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.30.3 → pyield-0.30.6}/PKG-INFO +1 -1
- pyield-0.30.6/pyield/__about__.py +1 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/di.py +31 -19
- {pyield-0.30.3 → pyield-0.30.6}/pyield/tpf/tools.py +2 -2
- pyield-0.30.3/pyield/__about__.py +0 -1
- {pyield-0.30.3 → pyield-0.30.6}/.gitignore +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/LICENSE +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/README.md +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/anbima/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/anbima/ettj.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/anbima/ima.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/anbima/imaq.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/anbima/ipca.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/anbima/tpf.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/di_over.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/futures/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/futures/common.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/futures/historical.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/futures/intraday.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/b3/futures/xml.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bc/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bc/auction.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bc/bcdata.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bc/ptax.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bc/repo.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bc/trade.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bc/vna.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/bday.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/conftest.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/data_cache.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/date_converter.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/forwards.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/holidays/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/holidays/brholidays.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/ibge/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/ibge/ipca.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/interpolator.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/py.typed +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/retry.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/tpf/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/tpf/lft.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/tpf/ltn.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/tpf/ntnb.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyield/tpf/ntnf.py +0 -0
- {pyield-0.30.3 → pyield-0.30.6}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.30.6"
|
|
@@ -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
|
"""
|
|
@@ -17,8 +21,7 @@ class DIFutures:
|
|
|
17
21
|
|
|
18
22
|
Args:
|
|
19
23
|
date (DateScalar | None): The trade date to retrieve the
|
|
20
|
-
DI contract data. If None,
|
|
21
|
-
used.
|
|
24
|
+
DI contract data. If None, an empty DataFrame is returned.
|
|
22
25
|
month_start (bool): If True, adjusts the expirations to the start of the month.
|
|
23
26
|
pre_filter (bool): If True, filters the DI contracts to match only
|
|
24
27
|
expirations with existing prefixed TN bond maturities (LTN and NTN-F).
|
|
@@ -100,19 +103,25 @@ class DIFutures:
|
|
|
100
103
|
|
|
101
104
|
def _update_df(self) -> pd.DataFrame:
|
|
102
105
|
"""Retrieve DI contract DataFrame for the initialized trade date."""
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
if self._date is None:
|
|
107
|
+
logger.info("No date specified. Returning empty DataFrame.")
|
|
108
|
+
return pd.DataFrame()
|
|
109
|
+
# Return an empty DataFrame if the trade date is a holiday
|
|
110
|
+
if not bday.is_business_day(self._date):
|
|
111
|
+
logger.warning("Specified date is not a business day.")
|
|
112
|
+
logger.warning("Returning empty DataFrame.")
|
|
113
|
+
return pd.DataFrame()
|
|
114
|
+
|
|
115
|
+
# Get historical data
|
|
116
|
+
df = get_di_dataset().query("TradeDate == @self._date").reset_index(drop=True)
|
|
117
|
+
|
|
118
|
+
if df.empty:
|
|
119
|
+
logger.info("No historical data found. Trying real-time data.")
|
|
120
|
+
df = b3.futures(contract_code="DI1", date=self._date)
|
|
114
121
|
|
|
115
122
|
if df.empty:
|
|
123
|
+
logger.warning("No DI Futures data found for the specified date.")
|
|
124
|
+
logger.warning("Returning empty DataFrame.")
|
|
116
125
|
return pd.DataFrame()
|
|
117
126
|
|
|
118
127
|
if "DaysToExpiration" in df.columns:
|
|
@@ -182,7 +191,9 @@ class DIFutures:
|
|
|
182
191
|
- SettlementRate: The zero rate (interest rate) for each expiration.
|
|
183
192
|
- ForwardRate: The fwd rate calculated between successive expirations.
|
|
184
193
|
"""
|
|
194
|
+
# Use a local copy of the DI DataFrame
|
|
185
195
|
df = self.df
|
|
196
|
+
|
|
186
197
|
if df.empty:
|
|
187
198
|
return pd.DataFrame()
|
|
188
199
|
|
|
@@ -352,9 +363,10 @@ class DIFutures:
|
|
|
352
363
|
def date(self, value: DateScalar | None):
|
|
353
364
|
if value:
|
|
354
365
|
self._date = dc.convert_input_dates(value)
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
366
|
+
bz_today = pd.Timestamp.today(tz="America/Sao_Paulo")
|
|
367
|
+
bz_today = bz_today.normalize().tz_localize(None)
|
|
368
|
+
if self._date > bz_today:
|
|
369
|
+
raise ValueError("Trade date cannot be in the future.")
|
|
358
370
|
self._dirty = True
|
|
359
371
|
|
|
360
372
|
@property
|
|
@@ -373,7 +385,7 @@ class DIFutures:
|
|
|
373
385
|
|
|
374
386
|
@month_start.setter
|
|
375
387
|
def month_start(self, value: bool):
|
|
376
|
-
self._month_start = value
|
|
388
|
+
self._month_start = bool(value)
|
|
377
389
|
self._dirty = True
|
|
378
390
|
|
|
379
391
|
@property
|
|
@@ -392,7 +404,7 @@ class DIFutures:
|
|
|
392
404
|
|
|
393
405
|
@pre_filter.setter
|
|
394
406
|
def pre_filter(self, value: bool):
|
|
395
|
-
self._pre_filter = value
|
|
407
|
+
self._pre_filter = bool(value)
|
|
396
408
|
self._dirty = True
|
|
397
409
|
|
|
398
410
|
@property
|
|
@@ -401,5 +413,5 @@ class DIFutures:
|
|
|
401
413
|
|
|
402
414
|
@all_columns.setter
|
|
403
415
|
def all_columns(self, value: bool):
|
|
404
|
-
self._all_columns = value
|
|
416
|
+
self._all_columns = bool(value)
|
|
405
417
|
self._dirty = True
|
|
@@ -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
|
|
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
|
|
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
|