PYield 0.37.3__tar.gz → 0.37.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.37.3 → pyield-0.37.4}/PKG-INFO +1 -1
- pyield-0.37.4/pyield/__about__.py +1 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/anbima/tpf.py +4 -3
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/di1.py +40 -13
- pyield-0.37.3/pyield/__about__.py +0 -1
- {pyield-0.37.3 → pyield-0.37.4}/.gitignore +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/LICENSE +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/README.md +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/anbima/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/anbima/ettj.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/anbima/ima.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/anbima/imaq.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/anbima/ipca.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/di_over.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/futures/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/futures/common.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/futures/historical.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/futures/intraday.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/b3/futures/xml.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/auction.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/ptax_api.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/rates.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/repo.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/trades_intraday.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/trades_monthly.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bc/vna.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/bday.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/conftest.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/data_cache.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/date_converter.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/fwd.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/holidays/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/holidays/brholidays.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/ibge/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/ibge/ipca.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/interpolator.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/py.typed +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/retry.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/__init__.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/benchmark.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/lft.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/ltn.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/ntnb.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/ntnc.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/ntnf.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/pre.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyield/tn/tools.py +0 -0
- {pyield-0.37.3 → pyield-0.37.4}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.37.4"
|
|
@@ -168,11 +168,12 @@ def _add_usd_dv01(df: pd.DataFrame) -> pd.DataFrame:
|
|
|
168
168
|
return df
|
|
169
169
|
|
|
170
170
|
|
|
171
|
-
def _add_di_rate(df: pd.DataFrame
|
|
171
|
+
def _add_di_rate(df: pd.DataFrame) -> pd.DataFrame:
|
|
172
172
|
"""Add the DI rate column to the DataFrame."""
|
|
173
173
|
# INSERIR OS DADOS DO DI INTERPOLADO ###
|
|
174
|
+
reference_date = df["ReferenceDate"].iloc[0]
|
|
174
175
|
df["DIRate"] = di1.interpolate_rates(
|
|
175
|
-
dates=
|
|
176
|
+
dates=reference_date,
|
|
176
177
|
expirations=df["MaturityDate"],
|
|
177
178
|
extrapolate=True,
|
|
178
179
|
)
|
|
@@ -251,7 +252,7 @@ def _fetch_tpf_data(date: pd.Timestamp) -> pd.DataFrame:
|
|
|
251
252
|
df = _process_raw_df(df)
|
|
252
253
|
df = _add_dv01(df)
|
|
253
254
|
df = _add_usd_dv01(df)
|
|
254
|
-
df = _add_di_rate(df
|
|
255
|
+
df = _add_di_rate(df)
|
|
255
256
|
df = _reorder_columns(df)
|
|
256
257
|
|
|
257
258
|
return df.sort_values(["BondType", "MaturityDate"]).reset_index(drop=True)
|
|
@@ -14,6 +14,41 @@ logger = logging.getLogger(__name__)
|
|
|
14
14
|
TIMEZONE_BZ = ZoneInfo("America/Sao_Paulo")
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
def _get_data(dates: pd.Series) -> pd.DataFrame:
|
|
18
|
+
"""Busca dados de DI, incluindo dados intraday para o dia corrente se necessário."""
|
|
19
|
+
# 1. Busca inicial no cache com as datas solicitadas pelo usuário.
|
|
20
|
+
df_cached = (
|
|
21
|
+
get_cached_dataset("di1").query("TradeDate in @dates").reset_index(drop=True)
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
today = dt.now(TIMEZONE_BZ).date()
|
|
25
|
+
last_bday = bday.last_business_day().date()
|
|
26
|
+
|
|
27
|
+
# 2. Lógica para buscar dados intraday.
|
|
28
|
+
# Isso é necessário quando o usuário solicita os dados do dia corrente
|
|
29
|
+
# e eles ainda não foram persistidos no cache (processo noturno).
|
|
30
|
+
if (
|
|
31
|
+
# Condição 1: O dia de hoje foi explicitamente solicitado.
|
|
32
|
+
today in dates.values
|
|
33
|
+
# Condição 2: E ainda não está no cache.
|
|
34
|
+
and today not in df_cached["TradeDate"].values
|
|
35
|
+
# Condição 3: E hoje é o último dia útil.
|
|
36
|
+
and today == last_bday
|
|
37
|
+
):
|
|
38
|
+
try:
|
|
39
|
+
df_intraday = b3.futures(contract_code="DI1", date=today)
|
|
40
|
+
if not df_intraday.empty:
|
|
41
|
+
logger.info("Dados intraday de DI inseridos com sucesso.")
|
|
42
|
+
return pd.concat([df_cached, df_intraday]).reset_index(drop=True)
|
|
43
|
+
else:
|
|
44
|
+
logger.warning(f"Nenhum dado intraday de DI encontrado para {today}.")
|
|
45
|
+
except Exception as e:
|
|
46
|
+
logger.error(f"Falha ao buscar dados intraday para {today}: {e}")
|
|
47
|
+
|
|
48
|
+
# 3. Se a lógica intraday não for acionada ou falhar, retorna apenas dados do cache.
|
|
49
|
+
return df_cached
|
|
50
|
+
|
|
51
|
+
|
|
17
52
|
def data(
|
|
18
53
|
dates: DateScalar | DateArray,
|
|
19
54
|
month_start: bool = False,
|
|
@@ -57,22 +92,14 @@ def data(
|
|
|
57
92
|
"""
|
|
58
93
|
dates = dc.convert_input_dates(dates)
|
|
59
94
|
# Force dates to be a Series for consistency
|
|
60
|
-
|
|
95
|
+
if isinstance(dates, pd.Timestamp):
|
|
96
|
+
dates = pd.Series([dates]).astype("date32[pyarrow]")
|
|
97
|
+
|
|
61
98
|
# Remove duplicates and sort dates
|
|
62
99
|
dates = dates.drop_duplicates().sort_values().reset_index(drop=True)
|
|
63
|
-
|
|
64
|
-
df = get_cached_dataset("di1").query("TradeDate in @dates").reset_index(drop=True)
|
|
65
|
-
|
|
66
|
-
today = dt.now(TIMEZONE_BZ).date()
|
|
67
|
-
last_bday = bday.last_business_day()
|
|
68
|
-
is_trading_day = today == last_bday.date()
|
|
69
|
-
if is_trading_day and last_bday in df["TradeDate"]:
|
|
70
|
-
logger.info("Trying to get DI Futures data for today.")
|
|
71
|
-
df_intraday = b3.futures(contract_code="DI1", date=last_bday)
|
|
72
|
-
df = pd.concat([df, df_intraday]).reset_index(drop=True)
|
|
73
|
-
|
|
100
|
+
df = _get_data(dates)
|
|
74
101
|
if df.empty:
|
|
75
|
-
logger.warning("No
|
|
102
|
+
logger.warning("No DI1 data found for the specified dates.")
|
|
76
103
|
logger.warning("Returning empty DataFrame.")
|
|
77
104
|
return pd.DataFrame()
|
|
78
105
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.37.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|