pyield 0.55.1__tar.gz → 0.55.2__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.55.1 → pyield-0.55.2}/PKG-INFO +1 -1
- {pyield-0.55.1 → pyield-0.55.2}/pyield/selic/copom.py +5 -5
- {pyield-0.55.1 → pyield-0.55.2}/pyield/selic/cpm.py +2 -2
- {pyield-0.55.1 → pyield-0.55.2}/pyield/selic/probabilities.py +11 -7
- pyield-0.55.2/pyield/tpf/vna/__init__.py +5 -0
- pyield-0.55.1/pyield/tpf/vna/_utils.py → pyield-0.55.2/pyield/tpf/vna/calculo.py +27 -2
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/vna/ntnb.py +6 -5
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/vna/ntnc.py +6 -5
- {pyield-0.55.1 → pyield-0.55.2}/pyproject.toml +1 -1
- {pyield-0.55.1 → pyield-0.55.2}/pyproject.toml.orig +1 -1
- pyield-0.55.1/pyield/tpf/vna/__init__.py +0 -1
- {pyield-0.55.1 → pyield-0.55.2}/LICENSE +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/README.md +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/br_numbers.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/cache.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/converters.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/data_cache.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/excel.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/numbers.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/retry.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/_internal/types.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/anbima/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/anbima/imaq.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/anbima/taxas.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/b3/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/b3/_contratos.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/b3/_validar_pregao.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/b3/boletim.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/b3/derivativos_intradia.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/b3/di_over.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/bc/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/bc/_olinda.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/bc/leiloes.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/bc/lft.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/bc/sgs.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/du/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/du/core.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/du/feriados/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/du/feriados/feriados_antigos_br.txt +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/du/feriados/feriados_br.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/du/feriados/feriados_novos_br.txt +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/futuro/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/futuro/contratos.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/futuro/di1.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/futuro/historico.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/futuro/intradia.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/fwd.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/interpolador.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/ipca/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/ipca/historico.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/ipca/projetado.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/py.typed +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/relogio.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/selic/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/selic/compromissada.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/_taxas.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/benchmark.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/dealers.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/leiloes.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/rmd/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/rmd/_aba_1_3.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/rmd/_aba_2_1.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/rmd/_common.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/rmd/_download.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/secundario/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/secundario/_intradia.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/secundario/_mensal.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/__init__.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/_utils.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/_zero_td.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/lft.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/ltn.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/ntnb.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/ntnb1.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/ntnbp.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/ntnc.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/ntnf.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/titulos/pre.py +0 -0
- {pyield-0.55.1 → pyield-0.55.2}/pyield/tpf/vna/_download.py +0 -0
|
@@ -151,10 +151,10 @@ def calendar(
|
|
|
151
151
|
|
|
152
152
|
Examples:
|
|
153
153
|
>>> import pyield as yd
|
|
154
|
-
>>> cal = yd.selic.copom.calendar()
|
|
155
|
-
>>> "ExpiryDate" in cal.columns
|
|
154
|
+
>>> cal = yd.selic.copom.calendar() # doctest: +SKIP
|
|
155
|
+
>>> "ExpiryDate" in cal.columns # doctest: +SKIP
|
|
156
156
|
True
|
|
157
|
-
>>> cal["EndDate"].is_sorted()
|
|
157
|
+
>>> cal["EndDate"].is_sorted() # doctest: +SKIP
|
|
158
158
|
True
|
|
159
159
|
"""
|
|
160
160
|
past = _fetch_past_meetings()
|
|
@@ -192,8 +192,8 @@ def next_meeting(reference: DateLike | None = None) -> pl.DataFrame:
|
|
|
192
192
|
|
|
193
193
|
Examples:
|
|
194
194
|
>>> import pyield as yd
|
|
195
|
-
>>> row = yd.selic.copom.next_meeting()
|
|
196
|
-
>>> len(row)
|
|
195
|
+
>>> row = yd.selic.copom.next_meeting() # doctest: +SKIP
|
|
196
|
+
>>> len(row) # doctest: +SKIP
|
|
197
197
|
1
|
|
198
198
|
"""
|
|
199
199
|
ref = relogio.hoje() if reference is None else converter_datas(reference)
|
|
@@ -254,8 +254,8 @@ def data(date: DateLike) -> pl.DataFrame:
|
|
|
254
254
|
|
|
255
255
|
Examples:
|
|
256
256
|
>>> import pyield as yd
|
|
257
|
-
>>> df = yd.selic.cpm.data("29-01-2025")
|
|
258
|
-
>>> df.is_empty() or set(df.schema.keys()) >= {
|
|
257
|
+
>>> df = yd.selic.cpm.data("29-01-2025") # doctest: +SKIP
|
|
258
|
+
>>> df.is_empty() or set(df.schema.keys()) >= { # doctest: +SKIP
|
|
259
259
|
... "data_referencia",
|
|
260
260
|
... "codigo_negociacao",
|
|
261
261
|
... "data_fim_reuniao",
|
|
@@ -253,11 +253,13 @@ def all_meetings(
|
|
|
253
253
|
Examples:
|
|
254
254
|
>>> import pyield as yd
|
|
255
255
|
>>> import polars as pl
|
|
256
|
-
>>> df = yd.selic.probabilities.all_meetings("29-01-2025")
|
|
257
|
-
>>> df.is_empty() or df["ranking_reuniao"].min() == 1
|
|
256
|
+
>>> df = yd.selic.probabilities.all_meetings("29-01-2025") # doctest: +SKIP
|
|
257
|
+
>>> df.is_empty() or df["ranking_reuniao"].min() == 1 # doctest: +SKIP
|
|
258
258
|
True
|
|
259
|
-
>>> sums = df.group_by("data_expiracao").agg(
|
|
260
|
-
|
|
259
|
+
>>> sums = df.group_by("data_expiracao").agg(
|
|
260
|
+
... pl.col("prob").sum()
|
|
261
|
+
... ) # doctest: +SKIP
|
|
262
|
+
>>> df.is_empty() or (sums["prob"] - 1.0).abs().max() < 1e-9 # doctest: +SKIP
|
|
261
263
|
True
|
|
262
264
|
"""
|
|
263
265
|
raw = cpm.data(date)
|
|
@@ -318,10 +320,12 @@ def meeting(
|
|
|
318
320
|
|
|
319
321
|
Examples:
|
|
320
322
|
>>> import pyield as yd
|
|
321
|
-
>>> df = yd.selic.probabilities.meeting("29-01-2025")
|
|
322
|
-
>>> df.is_empty() or abs(df["prob"].sum() - 1.0) < 1e-9
|
|
323
|
+
>>> df = yd.selic.probabilities.meeting("29-01-2025") # doctest: +SKIP
|
|
324
|
+
>>> df.is_empty() or abs(df["prob"].sum() - 1.0) < 1e-9 # doctest: +SKIP
|
|
323
325
|
True
|
|
324
|
-
>>> df.is_empty() or df["prob_acumulada"].tail(
|
|
326
|
+
>>> df.is_empty() or df["prob_acumulada"].tail(
|
|
327
|
+
... 1
|
|
328
|
+
... ).item() == 1.0 # doctest: +SKIP
|
|
325
329
|
True
|
|
326
330
|
"""
|
|
327
331
|
df = all_meetings(date, option_type=option_type)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Cálculos genéricos de VNA."""
|
|
2
2
|
|
|
3
3
|
import datetime as dt
|
|
4
4
|
|
|
@@ -20,7 +20,29 @@ def calcular_vna(
|
|
|
20
20
|
*,
|
|
21
21
|
fator_variacao: float | None = None,
|
|
22
22
|
) -> float:
|
|
23
|
-
"""Obtém o VNA publicado ou calcula o pró-rata entre pontos publicados.
|
|
23
|
+
"""Obtém o VNA publicado ou calcula o pró-rata entre pontos publicados.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
df: DataFrame com as colunas ``data`` (Date) e ``vna`` (Float64),
|
|
27
|
+
contendo no máximo um ponto publicado por data.
|
|
28
|
+
data: Data para a qual o VNA será obtido ou interpolado.
|
|
29
|
+
fator_variacao: Fator multiplicativo entre o ponto inicial e o final.
|
|
30
|
+
Se omitido, é calculado pela razão entre os VNAs dos dois pontos.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Float: VNA publicado ou calculado por pró-rata exponencial. Retorna
|
|
34
|
+
``float('nan')`` quando não houver pontos publicados dos dois lados da
|
|
35
|
+
data ou quando ela estiver fora do intervalo disponível.
|
|
36
|
+
|
|
37
|
+
Notes:
|
|
38
|
+
Um ponto publicado exatamente na data tem prioridade e ignora
|
|
39
|
+
``fator_variacao``. O expoente do pró-rata é truncado em catorze casas
|
|
40
|
+
e o resultado em seis casas.
|
|
41
|
+
|
|
42
|
+
Raises:
|
|
43
|
+
ValueError: Se o VNA-base não for positivo ou a variação for menor ou
|
|
44
|
+
igual a -100%.
|
|
45
|
+
"""
|
|
24
46
|
ponto_exato = df.filter(pl.col("data") == data)
|
|
25
47
|
if ponto_exato.height == 1:
|
|
26
48
|
return float(ponto_exato.item(0, "vna"))
|
|
@@ -73,3 +95,6 @@ def calcular_vna_projetado(
|
|
|
73
95
|
projecao_percentual / 100,
|
|
74
96
|
expoente,
|
|
75
97
|
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
__all__ = ["calcular_vna"]
|
|
@@ -10,7 +10,8 @@ import pyield._internal.converters as conversores
|
|
|
10
10
|
from pyield._internal.numbers import truncar, truncar_decimal
|
|
11
11
|
from pyield._internal.types import DateLike, any_is_empty
|
|
12
12
|
from pyield.ipca import historico as _ipca
|
|
13
|
-
from pyield.tpf.vna import _download
|
|
13
|
+
from pyield.tpf.vna import _download
|
|
14
|
+
from pyield.tpf.vna import calculo as _vna
|
|
14
15
|
|
|
15
16
|
_DIA_INICIO_VIGENCIA = 15
|
|
16
17
|
_QTD_MARCOS_VIGENCIA = 2
|
|
@@ -23,7 +24,7 @@ def _processar(df_bruto: pl.DataFrame) -> pl.DataFrame:
|
|
|
23
24
|
"""Normaliza as duas colunas da planilha de NTN-B."""
|
|
24
25
|
return (
|
|
25
26
|
df_bruto.select(
|
|
26
|
-
data=
|
|
27
|
+
data=_vna.expressao_data(),
|
|
27
28
|
vna=pl.col("column_2").cast(pl.Float64, strict=False),
|
|
28
29
|
)
|
|
29
30
|
.filter(pl.col("data").is_not_null(), pl.col("vna").is_not_null())
|
|
@@ -94,7 +95,7 @@ def vna(data: DateLike | None = None) -> Decimal:
|
|
|
94
95
|
if math.isnan(fator_ipca):
|
|
95
96
|
return Decimal("NaN")
|
|
96
97
|
return truncar_decimal(
|
|
97
|
-
|
|
98
|
+
_vna.calcular_vna(
|
|
98
99
|
df,
|
|
99
100
|
data_convertida,
|
|
100
101
|
fator_variacao=fator_ipca,
|
|
@@ -174,12 +175,12 @@ def vna_projetado(
|
|
|
174
175
|
"""
|
|
175
176
|
if any_is_empty(data, vna_base, inflacao):
|
|
176
177
|
return Decimal("NaN")
|
|
177
|
-
if inflacao <=
|
|
178
|
+
if inflacao <= _vna.LIMITE_INFERIOR_PERCENTUAL:
|
|
178
179
|
raise ValueError("A inflação deve ser maior que -100%.")
|
|
179
180
|
data_convertida = conversores.converter_datas(data)
|
|
180
181
|
inicio, fim = _obter_vigencia(data_convertida)
|
|
181
182
|
expoente = (data_convertida - inicio).days / (fim - inicio).days
|
|
182
183
|
return truncar_decimal(
|
|
183
|
-
|
|
184
|
+
_vna.calcular_vna_projetado(float(vna_base), float(inflacao), expoente),
|
|
184
185
|
6,
|
|
185
186
|
)
|
|
@@ -8,7 +8,8 @@ import polars as pl
|
|
|
8
8
|
import pyield._internal.converters as conversores
|
|
9
9
|
from pyield._internal.numbers import truncar_decimal
|
|
10
10
|
from pyield._internal.types import DateLike, any_is_empty
|
|
11
|
-
from pyield.tpf.vna import _download
|
|
11
|
+
from pyield.tpf.vna import _download
|
|
12
|
+
from pyield.tpf.vna import calculo as _vna
|
|
12
13
|
|
|
13
14
|
_URL_PUBLICACAO = (
|
|
14
15
|
"https://www.tesourotransparente.gov.br/publicacoes/valor-nominal-de-ntn-c/"
|
|
@@ -24,7 +25,7 @@ def _processar(df_bruto: pl.DataFrame) -> pl.DataFrame:
|
|
|
24
25
|
series = []
|
|
25
26
|
for coluna, anos in _ANOS_VENCIMENTO.items():
|
|
26
27
|
serie = df_bruto.select(
|
|
27
|
-
data=
|
|
28
|
+
data=_vna.expressao_data(),
|
|
28
29
|
anos_vencimento=pl.lit(anos, dtype=pl.List(pl.Int64)),
|
|
29
30
|
vna=pl.col(coluna).cast(pl.Float64, strict=False),
|
|
30
31
|
).filter(
|
|
@@ -100,7 +101,7 @@ def vna(
|
|
|
100
101
|
df = vnas().filter(
|
|
101
102
|
pl.col("anos_vencimento").list.contains(vencimento_convertido.year)
|
|
102
103
|
)
|
|
103
|
-
return truncar_decimal(
|
|
104
|
+
return truncar_decimal(_vna.calcular_vna(df, data_convertida), 6)
|
|
104
105
|
|
|
105
106
|
|
|
106
107
|
def _obter_vigencia(data: dt.date) -> tuple[dt.date, dt.date]:
|
|
@@ -153,12 +154,12 @@ def vna_projetado(
|
|
|
153
154
|
"""
|
|
154
155
|
if any_is_empty(data, vna_base, inflacao):
|
|
155
156
|
return Decimal("NaN")
|
|
156
|
-
if inflacao <=
|
|
157
|
+
if inflacao <= _vna.LIMITE_INFERIOR_PERCENTUAL:
|
|
157
158
|
raise ValueError("A inflação deve ser maior que -100%.")
|
|
158
159
|
data_convertida = conversores.converter_datas(data)
|
|
159
160
|
inicio, fim = _obter_vigencia(data_convertida)
|
|
160
161
|
expoente = (data_convertida - inicio).days / (fim - inicio).days
|
|
161
162
|
return truncar_decimal(
|
|
162
|
-
|
|
163
|
+
_vna.calcular_vna_projetado(float(vna_base), float(inflacao), expoente),
|
|
163
164
|
6,
|
|
164
165
|
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"""Cálculos de VNA por tipo de título público."""
|
|
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
|
|
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
|