PYield 0.30.4__tar.gz → 0.30.7__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.4 → pyield-0.30.7}/PKG-INFO +1 -1
- pyield-0.30.7/pyield/__about__.py +1 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/di.py +17 -12
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bc/__init__.py +2 -2
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bc/bcdata.py +2 -1
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bc/ptax.py +44 -18
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bc/trade.py +9 -10
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bc/vna.py +2 -1
- {pyield-0.30.4 → pyield-0.30.7}/pyield/interpolator.py +5 -3
- pyield-0.30.4/pyield/__about__.py +0 -1
- {pyield-0.30.4 → pyield-0.30.7}/.gitignore +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/LICENSE +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/README.md +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/__init__.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/anbima/__init__.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/anbima/ettj.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/anbima/ima.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/anbima/imaq.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/anbima/ipca.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/anbima/tpf.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/__init__.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/di_over.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/futures/__init__.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/futures/common.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/futures/historical.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/futures/intraday.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/b3/futures/xml.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bc/auction.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bc/repo.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/bday.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/conftest.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/data_cache.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/date_converter.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/forwards.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/holidays/__init__.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/holidays/brholidays.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/ibge/__init__.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/ibge/ipca.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/py.typed +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/retry.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/tpf/__init__.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/tpf/lft.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/tpf/ltn.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/tpf/ntnb.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/tpf/ntnf.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyield/tpf/tools.py +0 -0
- {pyield-0.30.4 → pyield-0.30.7}/pyproject.toml +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.30.7"
|
|
@@ -21,8 +21,7 @@ class DIFutures:
|
|
|
21
21
|
|
|
22
22
|
Args:
|
|
23
23
|
date (DateScalar | None): The trade date to retrieve the
|
|
24
|
-
DI contract data. If None,
|
|
25
|
-
used.
|
|
24
|
+
DI contract data. If None, an empty DataFrame is returned.
|
|
26
25
|
month_start (bool): If True, adjusts the expirations to the start of the month.
|
|
27
26
|
pre_filter (bool): If True, filters the DI contracts to match only
|
|
28
27
|
expirations with existing prefixed TN bond maturities (LTN and NTN-F).
|
|
@@ -65,7 +64,7 @@ class DIFutures:
|
|
|
65
64
|
|
|
66
65
|
def __init__(
|
|
67
66
|
self,
|
|
68
|
-
date: DateScalar,
|
|
67
|
+
date: DateScalar | None = None,
|
|
69
68
|
month_start: bool = False,
|
|
70
69
|
pre_filter: bool = False,
|
|
71
70
|
all_columns: bool = True,
|
|
@@ -104,6 +103,9 @@ class DIFutures:
|
|
|
104
103
|
|
|
105
104
|
def _update_df(self) -> pd.DataFrame:
|
|
106
105
|
"""Retrieve DI contract DataFrame for the initialized trade date."""
|
|
106
|
+
if self._date is None:
|
|
107
|
+
logger.info("No date specified. Returning empty DataFrame.")
|
|
108
|
+
return pd.DataFrame()
|
|
107
109
|
# Return an empty DataFrame if the trade date is a holiday
|
|
108
110
|
if not bday.is_business_day(self._date):
|
|
109
111
|
logger.warning("Specified date is not a business day.")
|
|
@@ -189,7 +191,9 @@ class DIFutures:
|
|
|
189
191
|
- SettlementRate: The zero rate (interest rate) for each expiration.
|
|
190
192
|
- ForwardRate: The fwd rate calculated between successive expirations.
|
|
191
193
|
"""
|
|
194
|
+
# Use a local copy of the DI DataFrame
|
|
192
195
|
df = self.df
|
|
196
|
+
|
|
193
197
|
if df.empty:
|
|
194
198
|
return pd.DataFrame()
|
|
195
199
|
|
|
@@ -356,12 +360,13 @@ class DIFutures:
|
|
|
356
360
|
return self._date
|
|
357
361
|
|
|
358
362
|
@date.setter
|
|
359
|
-
def date(self, value: DateScalar):
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
363
|
+
def date(self, value: DateScalar | None):
|
|
364
|
+
if value:
|
|
365
|
+
self._date = dc.convert_input_dates(value)
|
|
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.")
|
|
365
370
|
self._dirty = True
|
|
366
371
|
|
|
367
372
|
@property
|
|
@@ -380,7 +385,7 @@ class DIFutures:
|
|
|
380
385
|
|
|
381
386
|
@month_start.setter
|
|
382
387
|
def month_start(self, value: bool):
|
|
383
|
-
self._month_start = value
|
|
388
|
+
self._month_start = bool(value)
|
|
384
389
|
self._dirty = True
|
|
385
390
|
|
|
386
391
|
@property
|
|
@@ -399,7 +404,7 @@ class DIFutures:
|
|
|
399
404
|
|
|
400
405
|
@pre_filter.setter
|
|
401
406
|
def pre_filter(self, value: bool):
|
|
402
|
-
self._pre_filter = value
|
|
407
|
+
self._pre_filter = bool(value)
|
|
403
408
|
self._dirty = True
|
|
404
409
|
|
|
405
410
|
@property
|
|
@@ -408,5 +413,5 @@ class DIFutures:
|
|
|
408
413
|
|
|
409
414
|
@all_columns.setter
|
|
410
415
|
def all_columns(self, value: bool):
|
|
411
|
-
self._all_columns = value
|
|
416
|
+
self._all_columns = bool(value)
|
|
412
417
|
self._dirty = True
|
|
@@ -9,7 +9,7 @@ from pyield.bc.bcdata import (
|
|
|
9
9
|
)
|
|
10
10
|
from pyield.bc.ptax import ptax_series
|
|
11
11
|
from pyield.bc.repo import repos
|
|
12
|
-
from pyield.bc.trade import
|
|
12
|
+
from pyield.bc.trade import tpf_trades
|
|
13
13
|
from pyield.bc.vna import vna_lft
|
|
14
14
|
|
|
15
15
|
__all__ = [
|
|
@@ -18,7 +18,7 @@ __all__ = [
|
|
|
18
18
|
"di_over_series",
|
|
19
19
|
"ptax_series",
|
|
20
20
|
"repos",
|
|
21
|
-
"
|
|
21
|
+
"tpf_trades",
|
|
22
22
|
"selic_over",
|
|
23
23
|
"selic_over_series",
|
|
24
24
|
"selic_target",
|
|
@@ -207,7 +207,8 @@ def selic_target_series(
|
|
|
207
207
|
or empty DataFrame if data is not available
|
|
208
208
|
|
|
209
209
|
Examples:
|
|
210
|
-
>>>
|
|
210
|
+
>>> from pyield import bc
|
|
211
|
+
>>> bc.selic_target_series("31-05-2024", "31-05-2024")
|
|
211
212
|
Date Value
|
|
212
213
|
0 2024-05-31 0.105
|
|
213
214
|
"""
|
|
@@ -88,27 +88,40 @@ def ptax_series(
|
|
|
88
88
|
- Unidade: R$
|
|
89
89
|
|
|
90
90
|
Documentação da API do BCB:
|
|
91
|
+
|
|
91
92
|
https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/documentacao
|
|
93
|
+
|
|
92
94
|
Exemplo de chamada à API:
|
|
93
|
-
https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarPeriodo(dataInicial=@dataInicial,dataFinalCotacao=@dataFinalCotacao)?
|
|
94
|
-
@dataInicial='08-01-2025'&@dataFinalCotacao='08-05-2025'&$format=text/csv
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
https://olinda.bcb.gov.br/olinda/servico/PTAX/versao/v1/odata/CotacaoDolarPeriodo(dataInicial=@dataInicial,dataFinalCotacao=@dataFinalCotacao)?@dataInicial='08-01-2025'&@dataFinalCotacao='08-05-2025'&$format=text/csv
|
|
97
|
+
|
|
98
|
+
Consultas de Período:
|
|
99
|
+
|
|
97
100
|
- Para consultar dados de um intervalo, forneça as datas de `start` e `end`.
|
|
98
|
-
Exemplo:
|
|
101
|
+
Exemplo:
|
|
102
|
+
|
|
103
|
+
`ptax_series(start='2024-10-20', end='2024-10-27')`
|
|
104
|
+
|
|
99
105
|
- Se apenas `start` for fornecido, a API do BC retornará dados a partir
|
|
100
|
-
da data de `start`
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
106
|
+
da data de `start` até a data mais recente disponível. Exemplo:
|
|
107
|
+
|
|
108
|
+
`ptax_series(start='2024-10-20')`
|
|
109
|
+
|
|
110
|
+
- Se apenas `end` for fornecido, a API do BC retornará dados desde a data mais
|
|
111
|
+
antiga disponível até a data de `end`. Exemplo:
|
|
112
|
+
|
|
113
|
+
`ptax_series(end='2024-10-27')`
|
|
114
|
+
|
|
115
|
+
Série Histórica Completa:
|
|
105
116
|
|
|
106
|
-
**Série Histórica Completa:**
|
|
107
117
|
- Para recuperar a série histórica completa de leilões (desde 28.11.1984
|
|
108
118
|
até o último dia útil), chame a função sem fornecer os parâmetros `start` e `end`.
|
|
109
|
-
Exemplo:
|
|
119
|
+
Exemplo:
|
|
120
|
+
|
|
121
|
+
`ptax_series()`
|
|
110
122
|
|
|
111
123
|
Busca dados de cotações de dólar PTAX (taxa de câmbio) para o período:
|
|
124
|
+
|
|
112
125
|
- Se `start` for fornecido e `end` não, a função retorna dados de `start` até o fim.
|
|
113
126
|
- Se `end` for fornecido e `start` não, a API retorna dados do início até `end`.
|
|
114
127
|
- Se ambos `start` e `end` forem omitidos, a API retorna a série histórica completa.
|
|
@@ -130,6 +143,15 @@ def ptax_series(
|
|
|
130
143
|
Se não houver dados disponíveis para o período especificado, um DataFrame vazio
|
|
131
144
|
será retornado.
|
|
132
145
|
|
|
146
|
+
Examples:
|
|
147
|
+
>>> from pyield import bc
|
|
148
|
+
>>> df = yd.bc.ptax_series(start="01-01-2025", end="05-01-2025")
|
|
149
|
+
>>> selected_columns = ["Date", "BuyRate", "SellRate", "MidRate"]
|
|
150
|
+
>>> df[selected_columns]
|
|
151
|
+
Date BuyRate SellRate MidRate
|
|
152
|
+
0 2025-01-02 6.208 6.2086 6.2083
|
|
153
|
+
1 2025-01-03 6.1557 6.1563 6.156
|
|
154
|
+
|
|
133
155
|
Notes:
|
|
134
156
|
Disponível desde 28.11.1984, refere-se às taxas administradas até março de 1990
|
|
135
157
|
e às taxas livres a partir de então (Resolução 1690, de 18.3.1990). As taxas
|
|
@@ -143,15 +165,19 @@ def ptax_series(
|
|
|
143
165
|
o boletim de fechamento PTAX corresponde à média aritmética das taxas dos
|
|
144
166
|
boletins do dia.
|
|
145
167
|
|
|
146
|
-
O DataFrame possui as seguintes colunas:
|
|
147
|
-
- Date: Data da cotação.
|
|
148
|
-
- Time: Hora da cotação.
|
|
149
|
-
- DateTime: Data e hora da cotação.
|
|
150
|
-
- BuyRate: Taxa de compra.
|
|
151
|
-
- SellRate: Taxa de venda.
|
|
152
|
-
- MidRate: Taxa média entre a taxa de compra e venda.
|
|
153
168
|
- Primeira data disponível: 28.11.1984
|
|
154
169
|
- Última data disponível: data atual
|
|
170
|
+
|
|
171
|
+
O DataFrame possui as seguintes colunas:
|
|
172
|
+
|
|
173
|
+
- Date: Data da cotação.
|
|
174
|
+
- Time: Hora da cotação.
|
|
175
|
+
- DateTime: Data e hora da cotação.
|
|
176
|
+
- BuyRate: Taxa de compra.
|
|
177
|
+
- SellRate: Taxa de venda.
|
|
178
|
+
- MidRate: Taxa média entre a taxa de compra e venda.
|
|
179
|
+
|
|
180
|
+
|
|
155
181
|
"""
|
|
156
182
|
if start:
|
|
157
183
|
start = dc.convert_input_dates(start)
|
|
@@ -61,20 +61,19 @@ def _fetch_data_from_url(file_url: str) -> pd.DataFrame:
|
|
|
61
61
|
return df
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def
|
|
65
|
-
"""Fetches secondary
|
|
66
|
-
registered
|
|
64
|
+
def tpf_trades(target_date: DateScalar) -> pd.DataFrame:
|
|
65
|
+
"""Fetches monthly secondary trading data for the 'títulos públicos federais' (TPF)
|
|
66
|
+
registered in the Brazilian Central Bank (BCB) system.
|
|
67
67
|
|
|
68
68
|
Downloads the monthly bond trading data from the Brazilian Central Bank (BCB)
|
|
69
69
|
website for the month corresponding to the provided date. The data is downloaded as
|
|
70
|
-
a ZIP file, extracted, and loaded into a Pandas DataFrame.
|
|
71
|
-
|
|
72
|
-
('SettlementDate').
|
|
70
|
+
a ZIP file, extracted, and loaded into a Pandas DataFrame. The data contains all
|
|
71
|
+
trades executed during the month, separated by each 'SettlementDate'.
|
|
73
72
|
|
|
74
73
|
Args:
|
|
75
|
-
target_date (DateScalar): The date for which
|
|
76
|
-
This can be
|
|
77
|
-
|
|
74
|
+
target_date (DateScalar): The date for which the monthly trading data will be
|
|
75
|
+
fetched. This date can be a string, datetime, or pandas Timestamp object.
|
|
76
|
+
It will be converted to a pandas Timestamp object. Only the year and month
|
|
78
77
|
of this date will be used to download the corresponding monthly file.
|
|
79
78
|
|
|
80
79
|
Returns:
|
|
@@ -97,7 +96,7 @@ def sec(target_date: DateScalar) -> pd.DataFrame:
|
|
|
97
96
|
|
|
98
97
|
Examples:
|
|
99
98
|
>>> from pyield import bc
|
|
100
|
-
>>> df = bc.
|
|
99
|
+
>>> df = bc.tpf_trades("07-01-2025") # Returns all trades for January 2025
|
|
101
100
|
"""
|
|
102
101
|
url = _build_download_url(target_date)
|
|
103
102
|
df = _fetch_data_from_url(url)
|
|
@@ -129,8 +129,10 @@ class Interpolator:
|
|
|
129
129
|
return self.interpolate(bday)
|
|
130
130
|
|
|
131
131
|
def __repr__(self) -> str:
|
|
132
|
-
"""
|
|
133
|
-
Textual representation, used in terminal or scripts.
|
|
134
|
-
"""
|
|
132
|
+
"""Textual representation, used in terminal or scripts."""
|
|
135
133
|
|
|
136
134
|
return repr(self._df)
|
|
135
|
+
|
|
136
|
+
def __len__(self) -> int:
|
|
137
|
+
"""Returns the number of known business days."""
|
|
138
|
+
return len(self._df)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.30.4"
|
|
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
|