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.
- {pyield-0.30.3 → pyield-0.30.4}/PKG-INFO +1 -1
- pyield-0.30.4/pyield/__about__.py +1 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/di.py +25 -18
- {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/tools.py +2 -2
- pyield-0.30.3/pyield/__about__.py +0 -1
- {pyield-0.30.3 → pyield-0.30.4}/.gitignore +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/LICENSE +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/README.md +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/ettj.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/ima.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/imaq.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/ipca.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/anbima/tpf.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/di_over.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/common.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/historical.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/intraday.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/b3/futures/xml.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/auction.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/bcdata.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/ptax.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/repo.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/trade.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bc/vna.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/bday.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/conftest.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/data_cache.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/date_converter.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/forwards.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/holidays/brholidays.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/ibge/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/ibge/ipca.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/interpolator.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/py.typed +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/retry.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/__init__.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/lft.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/ltn.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/ntnb.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyield/tpf/ntnf.py +0 -0
- {pyield-0.30.3 → pyield-0.30.4}/pyproject.toml +0 -0
|
@@ -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
|
|
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
|
-
|
|
104
|
-
if
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
|
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
|