pyield 0.48.0__tar.gz → 0.48.1__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.48.0 → pyield-0.48.1}/PKG-INFO +1 -1
- pyield-0.48.1/pyield/__about__.py +1 -0
- pyield-0.48.1/pyield/tn/__init__.py +6 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/ltn.py +3 -2
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/ntnf.py +3 -2
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/pre.py +0 -79
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/utils.py +75 -0
- pyield-0.48.0/pyield/__about__.py +0 -1
- pyield-0.48.0/pyield/tn/__init__.py +0 -19
- {pyield-0.48.0 → pyield-0.48.1}/.gitignore +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/LICENSE +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/README.md +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/_internal/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/_internal/br_numbers.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/_internal/cache.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/_internal/converters.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/_internal/data_cache.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/_internal/retry.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/_internal/types.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/anbima/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/anbima/ettj_intradia.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/anbima/ettj_ultima.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/anbima/ima_ultimo.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/anbima/imaq.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/anbima/tpf.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/_contratos.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/_validar_pregao.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/boletim.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/derivativos_intradia.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/di1.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/di_over.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/futuro/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/futuro/contratos.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/futuro/historico.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/b3/futuro/intradia.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/compromissada.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/copom.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/leiloes.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/ptax.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/taxas.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/tpf_intradia.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/tpf_mensal.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/bc/vna.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/dus/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/dus/core.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/dus/feriados/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/dus/feriados/feriados_antigos_br.txt +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/dus/feriados/feriados_br.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/dus/feriados/feriados_novos_br.txt +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/fwd.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/interpolador.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/ipca/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/ipca/historico.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/ipca/projetado.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/py.typed +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/relogio.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/selic/__init__.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/selic/cpm.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/selic/probabilities.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/benchmark.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/leiloes.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/lft.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/ntnb.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/ntnb1.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/ntnbprinc.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/ntnc.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyield/tn/rmd.py +0 -0
- {pyield-0.48.0 → pyield-0.48.1}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyield
|
|
3
|
-
Version: 0.48.
|
|
3
|
+
Version: 0.48.1
|
|
4
4
|
Summary: A Python library for analysis of fixed income instruments in Brazil
|
|
5
5
|
Project-URL: Homepage, https://github.com/crdcj/PYield
|
|
6
6
|
Project-URL: Documentation, https://crdcj.github.io/PYield
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.48.1"
|
|
@@ -4,7 +4,6 @@ import pyield._internal.converters as cv
|
|
|
4
4
|
from pyield import dus, fwd
|
|
5
5
|
from pyield._internal.types import DateLike, any_is_empty
|
|
6
6
|
from pyield.tn import utils
|
|
7
|
-
from pyield.tn.pre import premio as premio_pre
|
|
8
7
|
|
|
9
8
|
VALOR_FACE = 1000
|
|
10
9
|
|
|
@@ -312,7 +311,9 @@ def premio(
|
|
|
312
311
|
│ LTN ┆ 2032-01-01 ┆ 11.24 │
|
|
313
312
|
└────────┴─────────────────┴────────┘
|
|
314
313
|
"""
|
|
315
|
-
return premio_pre(data, pontos_base=pontos_base).filter(
|
|
314
|
+
return utils.premio_pre(data, pontos_base=pontos_base).filter(
|
|
315
|
+
pl.col("titulo") == "LTN"
|
|
316
|
+
)
|
|
316
317
|
|
|
317
318
|
|
|
318
319
|
def taxas_forward(data: DateLike) -> pl.DataFrame:
|
|
@@ -10,7 +10,6 @@ from pyield import dus
|
|
|
10
10
|
from pyield._internal.types import ArrayLike, DateLike, any_is_empty
|
|
11
11
|
from pyield.b3 import di1
|
|
12
12
|
from pyield.tn import utils
|
|
13
|
-
from pyield.tn.pre import premio as premio_pre
|
|
14
13
|
|
|
15
14
|
"""
|
|
16
15
|
Constantes calculadas conforme regras da ANBIMA
|
|
@@ -674,7 +673,9 @@ def premio(data: DateLike, pontos_base: bool = False) -> pl.DataFrame:
|
|
|
674
673
|
│ NTN-F ┆ 2035-01-01 ┆ 22.0 │
|
|
675
674
|
└────────┴─────────────────┴────────┘
|
|
676
675
|
"""
|
|
677
|
-
return premio_pre(data, pontos_base=pontos_base).filter(
|
|
676
|
+
return utils.premio_pre(data, pontos_base=pontos_base).filter(
|
|
677
|
+
pl.col("titulo") == "NTN-F"
|
|
678
|
+
)
|
|
678
679
|
|
|
679
680
|
|
|
680
681
|
def premio_limpo( # noqa
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import polars as pl
|
|
2
2
|
|
|
3
|
-
import pyield._internal.converters as cv
|
|
4
3
|
from pyield import dus
|
|
5
4
|
from pyield._internal.types import DateLike
|
|
6
5
|
from pyield.tn import ntnf, utils
|
|
@@ -137,81 +136,3 @@ def _validar_resultado_final(df: pl.DataFrame) -> None:
|
|
|
137
136
|
|
|
138
137
|
if df["taxa_zero"].is_null().any():
|
|
139
138
|
raise ValueError("Resultado final contém NaN na coluna taxa_zero")
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def premio(
|
|
143
|
-
data: DateLike,
|
|
144
|
-
pontos_base: bool = False,
|
|
145
|
-
) -> pl.DataFrame:
|
|
146
|
-
"""
|
|
147
|
-
Calcula o prêmio dos títulos prefixados (LTN e NTN-F) sobre o DI.
|
|
148
|
-
|
|
149
|
-
Em linguagem de mercado, esse valor é chamado de prêmio. Em termos
|
|
150
|
-
descritivos, trata-se do spread sobre o DI.
|
|
151
|
-
|
|
152
|
-
Definição do prêmio:
|
|
153
|
-
premio = taxa indicativa do PRE - taxa de ajuste do DI
|
|
154
|
-
|
|
155
|
-
Quando ``pontos_base=False`` a coluna retorna essa diferença em formato
|
|
156
|
-
decimal (ex: 0.000439 ≈ 4.39 bps). Quando ``pontos_base=True`` o valor é
|
|
157
|
-
automaticamente
|
|
158
|
-
multiplicado por 10_000 e exibido diretamente em basis points.
|
|
159
|
-
|
|
160
|
-
Args:
|
|
161
|
-
data: Data da consulta para buscar as taxas.
|
|
162
|
-
pontos_base: Se True, retorna o prêmio já convertido em basis points.
|
|
163
|
-
Padrão False.
|
|
164
|
-
|
|
165
|
-
Returns:
|
|
166
|
-
pl.DataFrame: DataFrame com as colunas do prêmio.
|
|
167
|
-
|
|
168
|
-
Output Columns:
|
|
169
|
-
- titulo (String): Tipo do título.
|
|
170
|
-
- data_vencimento (Date): Data de vencimento.
|
|
171
|
-
- premio (Float64): prêmio em decimal ou bps conforme parâmetro
|
|
172
|
-
(spread sobre o DI).
|
|
173
|
-
|
|
174
|
-
Examples:
|
|
175
|
-
>>> from pyield.tn import pre
|
|
176
|
-
>>> pre.premio("30-05-2025", pontos_base=True)
|
|
177
|
-
shape: (18, 3)
|
|
178
|
-
┌────────┬─────────────────┬────────┐
|
|
179
|
-
│ titulo ┆ data_vencimento ┆ premio │
|
|
180
|
-
│ --- ┆ --- ┆ --- │
|
|
181
|
-
│ str ┆ date ┆ f64 │
|
|
182
|
-
╞════════╪═════════════════╪════════╡
|
|
183
|
-
│ LTN ┆ 2025-07-01 ┆ 4.39 │
|
|
184
|
-
│ LTN ┆ 2025-10-01 ┆ -9.0 │
|
|
185
|
-
│ LTN ┆ 2026-01-01 ┆ -4.88 │
|
|
186
|
-
│ LTN ┆ 2026-04-01 ┆ -4.45 │
|
|
187
|
-
│ LTN ┆ 2026-07-01 ┆ 0.81 │
|
|
188
|
-
│ … ┆ … ┆ … │
|
|
189
|
-
│ NTN-F ┆ 2027-01-01 ┆ -3.31 │
|
|
190
|
-
│ NTN-F ┆ 2029-01-01 ┆ 14.21 │
|
|
191
|
-
│ NTN-F ┆ 2031-01-01 ┆ 21.61 │
|
|
192
|
-
│ NTN-F ┆ 2033-01-01 ┆ 11.51 │
|
|
193
|
-
│ NTN-F ┆ 2035-01-01 ┆ 22.0 │
|
|
194
|
-
└────────┴─────────────────┴────────┘
|
|
195
|
-
"""
|
|
196
|
-
# Busca taxas dos títulos (LTN e NTN-F) e adiciona taxa_di
|
|
197
|
-
df = utils.obter_tpf(data, "PRE").select(
|
|
198
|
-
"titulo", "data_vencimento", "taxa_indicativa"
|
|
199
|
-
)
|
|
200
|
-
if df.is_empty():
|
|
201
|
-
return df.select(
|
|
202
|
-
pl.lit("").alias("titulo"),
|
|
203
|
-
pl.lit(None, dtype=pl.Date).alias("data_vencimento"),
|
|
204
|
-
pl.lit(None, dtype=pl.Float64).alias("premio"),
|
|
205
|
-
).clear()
|
|
206
|
-
data_ref = cv.converter_datas(data)
|
|
207
|
-
df = utils.adicionar_taxa_di(df, data_ref)
|
|
208
|
-
df = (
|
|
209
|
-
df.with_columns(premio=pl.col("taxa_indicativa") - pl.col("taxa_di"))
|
|
210
|
-
.select("titulo", "data_vencimento", "premio")
|
|
211
|
-
.sort("titulo", "data_vencimento")
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
if pontos_base:
|
|
215
|
-
df = df.with_columns(pl.col("premio") * 10_000)
|
|
216
|
-
|
|
217
|
-
return df
|
|
@@ -6,6 +6,7 @@ from typing import overload
|
|
|
6
6
|
|
|
7
7
|
import polars as pl
|
|
8
8
|
|
|
9
|
+
import pyield._internal.converters as cv
|
|
9
10
|
from pyield._internal.types import DateLike
|
|
10
11
|
from pyield.anbima.tpf import TipoTPF
|
|
11
12
|
|
|
@@ -298,3 +299,77 @@ def encontrar_raiz(func_diferenca_preco: Callable[[float], float]) -> float:
|
|
|
298
299
|
|
|
299
300
|
a, b = intervalo
|
|
300
301
|
return _metodo_bissecao(func_diferenca_preco, a, b)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def premio_pre(
|
|
305
|
+
data: DateLike,
|
|
306
|
+
pontos_base: bool = False,
|
|
307
|
+
) -> pl.DataFrame:
|
|
308
|
+
"""Calcula o prêmio dos títulos prefixados (LTN e NTN-F) sobre o DI.
|
|
309
|
+
|
|
310
|
+
Em linguagem de mercado, esse valor é chamado de prêmio. Em termos
|
|
311
|
+
descritivos, trata-se do spread sobre o DI.
|
|
312
|
+
|
|
313
|
+
Definição do prêmio:
|
|
314
|
+
premio = taxa indicativa do PRE - taxa de ajuste do DI
|
|
315
|
+
|
|
316
|
+
Quando ``pontos_base=False`` a coluna retorna essa diferença em formato
|
|
317
|
+
decimal (ex: 0.000439 ≈ 4.39 bps). Quando ``pontos_base=True`` o valor
|
|
318
|
+
é automaticamente multiplicado por 10_000 e exibido diretamente em
|
|
319
|
+
basis points.
|
|
320
|
+
|
|
321
|
+
Args:
|
|
322
|
+
data: Data da consulta para buscar as taxas.
|
|
323
|
+
pontos_base: Se True, retorna o prêmio já convertido em basis
|
|
324
|
+
points. Padrão False.
|
|
325
|
+
|
|
326
|
+
Returns:
|
|
327
|
+
pl.DataFrame: DataFrame com as colunas do prêmio.
|
|
328
|
+
|
|
329
|
+
Output Columns:
|
|
330
|
+
- titulo (String): Tipo do título.
|
|
331
|
+
- data_vencimento (Date): Data de vencimento.
|
|
332
|
+
- premio (Float64): prêmio em decimal ou bps conforme parâmetro
|
|
333
|
+
(spread sobre o DI).
|
|
334
|
+
|
|
335
|
+
Examples:
|
|
336
|
+
>>> from pyield.tn import utils
|
|
337
|
+
>>> utils.premio_pre("30-05-2025", pontos_base=True)
|
|
338
|
+
shape: (18, 3)
|
|
339
|
+
┌────────┬─────────────────┬────────┐
|
|
340
|
+
│ titulo ┆ data_vencimento ┆ premio │
|
|
341
|
+
│ --- ┆ --- ┆ --- │
|
|
342
|
+
│ str ┆ date ┆ f64 │
|
|
343
|
+
╞════════╪═════════════════╪════════╡
|
|
344
|
+
│ LTN ┆ 2025-07-01 ┆ 4.39 │
|
|
345
|
+
│ LTN ┆ 2025-10-01 ┆ -9.0 │
|
|
346
|
+
│ LTN ┆ 2026-01-01 ┆ -4.88 │
|
|
347
|
+
│ LTN ┆ 2026-04-01 ┆ -4.45 │
|
|
348
|
+
│ LTN ┆ 2026-07-01 ┆ 0.81 │
|
|
349
|
+
│ … ┆ … ┆ … │
|
|
350
|
+
│ NTN-F ┆ 2027-01-01 ┆ -3.31 │
|
|
351
|
+
│ NTN-F ┆ 2029-01-01 ┆ 14.21 │
|
|
352
|
+
│ NTN-F ┆ 2031-01-01 ┆ 21.61 │
|
|
353
|
+
│ NTN-F ┆ 2033-01-01 ┆ 11.51 │
|
|
354
|
+
│ NTN-F ┆ 2035-01-01 ┆ 22.0 │
|
|
355
|
+
└────────┴─────────────────┴────────┘
|
|
356
|
+
"""
|
|
357
|
+
df = obter_tpf(data, "PRE").select("titulo", "data_vencimento", "taxa_indicativa")
|
|
358
|
+
if df.is_empty():
|
|
359
|
+
return df.select(
|
|
360
|
+
pl.lit("").alias("titulo"),
|
|
361
|
+
pl.lit(None, dtype=pl.Date).alias("data_vencimento"),
|
|
362
|
+
pl.lit(None, dtype=pl.Float64).alias("premio"),
|
|
363
|
+
).clear()
|
|
364
|
+
data_ref = cv.converter_datas(data)
|
|
365
|
+
df = adicionar_taxa_di(df, data_ref)
|
|
366
|
+
df = (
|
|
367
|
+
df.with_columns(premio=pl.col("taxa_indicativa") - pl.col("taxa_di"))
|
|
368
|
+
.select("titulo", "data_vencimento", "premio")
|
|
369
|
+
.sort("titulo", "data_vencimento")
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
if pontos_base:
|
|
373
|
+
df = df.with_columns(pl.col("premio") * 10_000)
|
|
374
|
+
|
|
375
|
+
return df
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.48.0"
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from pyield.tn.benchmark import benchmarks
|
|
2
|
-
from pyield.tn.leiloes import leilao
|
|
3
|
-
from pyield.tn.pre import premio
|
|
4
|
-
from pyield.tn.rmd import rmd
|
|
5
|
-
|
|
6
|
-
__all__ = [
|
|
7
|
-
"benchmarks",
|
|
8
|
-
"leilao",
|
|
9
|
-
"lft",
|
|
10
|
-
"ltn",
|
|
11
|
-
"ntnb",
|
|
12
|
-
"ntnb1",
|
|
13
|
-
"ntnbprinc",
|
|
14
|
-
"ntnc",
|
|
15
|
-
"ntnf",
|
|
16
|
-
"pre",
|
|
17
|
-
"premio",
|
|
18
|
-
"rmd",
|
|
19
|
-
]
|
|
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
|