PYield 0.44.1__tar.gz → 0.44.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.44.1 → pyield-0.44.2}/PKG-INFO +2 -1
- pyield-0.44.2/pyield/__about__.py +1 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/anbima/ettj_intraday.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/anbima/ettj_last.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/anbima/ima.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/futures/__init__.py +12 -6
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/intraday_derivatives.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/ptax_api.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/rates.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/trades_intraday.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/vna.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/ipca/projected.py +2 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyproject.toml +1 -0
- pyield-0.44.1/pyield/__about__.py +0 -1
- {pyield-0.44.1 → pyield-0.44.2}/.gitignore +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/LICENSE +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/README.md +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/_internal/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/_internal/converters.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/_internal/data_cache.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/_internal/retry.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/_internal/types.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/anbima/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/anbima/difusao.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/anbima/imaq.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/anbima/tpf.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/_contracts.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/_validar_pregao.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/di1.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/di_over.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/futures/common.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/futures/historical.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/futures/intraday.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/b3/price_report.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/auction.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/copom.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/repo.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bc/trades_monthly.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bday/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bday/core.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bday/holidays/br_holidays_new.txt +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bday/holidays/br_holidays_old.txt +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/bday/holidays/brholidays.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/clock.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/fwd.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/interpolator.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/ipca/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/ipca/historical.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/py.typed +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/rmd.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/selic/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/selic/cpm.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/selic/probabilities.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/__init__.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/auctions.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/benchmark.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/lft.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/ltn.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/ntnb.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/ntnb1.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/ntnbprinc.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/ntnc.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/ntnf.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/pre.py +0 -0
- {pyield-0.44.1 → pyield-0.44.2}/pyield/tn/tools.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyield
|
|
3
|
-
Version: 0.44.
|
|
3
|
+
Version: 0.44.2
|
|
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
|
|
@@ -36,6 +36,7 @@ Classifier: Operating System :: OS Independent
|
|
|
36
36
|
Classifier: Programming Language :: Python :: 3
|
|
37
37
|
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
38
38
|
Requires-Python: >=3.12
|
|
39
|
+
Requires-Dist: cachetools>=5.0.0
|
|
39
40
|
Requires-Dist: fastexcel>=0.19.0
|
|
40
41
|
Requires-Dist: lxml>=6.0.0
|
|
41
42
|
Requires-Dist: polars>=1.33.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.44.2"
|
|
@@ -2,6 +2,7 @@ import datetime as dt
|
|
|
2
2
|
import logging
|
|
3
3
|
from io import StringIO
|
|
4
4
|
|
|
5
|
+
import cachetools
|
|
5
6
|
import polars as pl
|
|
6
7
|
import requests
|
|
7
8
|
|
|
@@ -18,6 +19,7 @@ URL_ETTJ_INTRADAY = (
|
|
|
18
19
|
CASAS_DECIMAIS = 6
|
|
19
20
|
|
|
20
21
|
|
|
22
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=60))
|
|
21
23
|
@retry_padrao
|
|
22
24
|
def _buscar_texto_intraday() -> str:
|
|
23
25
|
carga_requisicao = {"Dt_Ref": "", "saida": "csv"}
|
|
@@ -2,6 +2,7 @@ import datetime as dt
|
|
|
2
2
|
import logging
|
|
3
3
|
from io import StringIO
|
|
4
4
|
|
|
5
|
+
import cachetools
|
|
5
6
|
import polars as pl
|
|
6
7
|
import requests
|
|
7
8
|
|
|
@@ -15,6 +16,7 @@ URL_ULTIMA_ETTJ = "https://www.anbima.com.br/informacoes/est-termo/CZ-down.asp"
|
|
|
15
16
|
CASAS_DECIMAIS = 6
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=60))
|
|
18
20
|
@retry_padrao
|
|
19
21
|
def _buscar_texto_ultima_ettj() -> str:
|
|
20
22
|
"""Busca o texto bruto da curva de juros na ANBIMA."""
|
|
@@ -2,6 +2,7 @@ import io
|
|
|
2
2
|
import logging
|
|
3
3
|
from typing import Literal
|
|
4
4
|
|
|
5
|
+
import cachetools
|
|
5
6
|
import polars as pl
|
|
6
7
|
import requests
|
|
7
8
|
|
|
@@ -81,6 +82,7 @@ ORDEM_COLUNAS_FINAL = [
|
|
|
81
82
|
URL_ULTIMO_IMA = "https://www.anbima.com.br/informacoes/ima/arqs/ima_completo.txt"
|
|
82
83
|
|
|
83
84
|
|
|
85
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=60))
|
|
84
86
|
@retry_padrao
|
|
85
87
|
def _buscar_texto_ultimo_ima() -> str:
|
|
86
88
|
resposta = requests.get(URL_ULTIMO_IMA, timeout=3)
|
|
@@ -4,6 +4,7 @@ import polars as pl
|
|
|
4
4
|
|
|
5
5
|
import pyield._internal.converters as cv
|
|
6
6
|
from pyield import clock
|
|
7
|
+
from pyield._internal.retry import DadoIndisponivelError
|
|
7
8
|
from pyield._internal.types import DateLike, any_is_empty
|
|
8
9
|
from pyield.b3._contracts import normalizar_codigos_contrato
|
|
9
10
|
from pyield.b3._validar_pregao import data_negociacao_valida
|
|
@@ -22,12 +23,17 @@ def _buscar_intraday_ou_historico(
|
|
|
22
23
|
return pl.DataFrame()
|
|
23
24
|
|
|
24
25
|
if horario_atual >= intraday.HORA_FIM_INTRADAY:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
for tentativa_full_report in (full_report, not full_report):
|
|
27
|
+
try:
|
|
28
|
+
df_historico = historical.historical(
|
|
29
|
+
data_negociacao, codigos_contrato, tentativa_full_report
|
|
30
|
+
)
|
|
31
|
+
except DadoIndisponivelError:
|
|
32
|
+
continue
|
|
33
|
+
if not df_historico.is_empty():
|
|
34
|
+
logger.info("Dados consolidados disponíveis. Usando histórico.")
|
|
35
|
+
return df_historico
|
|
36
|
+
logger.info("Histórico consolidado indisponível. Tentando intraday.")
|
|
31
37
|
|
|
32
38
|
dataframes_intraday = [intraday.intraday(codigo) for codigo in codigos_contrato]
|
|
33
39
|
dataframes_intraday = [df for df in dataframes_intraday if not df.is_empty()]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import cachetools
|
|
3
4
|
import polars as pl
|
|
4
5
|
import requests
|
|
5
6
|
|
|
@@ -49,6 +50,7 @@ def _mapa_renomeacao_intraday() -> dict[str, str]:
|
|
|
49
50
|
return {nome_orig: nome_novo for nome_orig, nome_novo, _ in COLUNAS_INTRADAY}
|
|
50
51
|
|
|
51
52
|
|
|
53
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=15))
|
|
52
54
|
@retry_padrao
|
|
53
55
|
def _buscar_json_intraday(codigo_contrato: str) -> list[dict]:
|
|
54
56
|
url = f"{URL_BASE_INTRADAY}/{codigo_contrato}"
|
|
@@ -18,6 +18,7 @@ cotacaoCompra, cotacaoVenda, dataHoraCotacao
|
|
|
18
18
|
import datetime as dt
|
|
19
19
|
import logging
|
|
20
20
|
|
|
21
|
+
import cachetools
|
|
21
22
|
import polars as pl
|
|
22
23
|
import requests
|
|
23
24
|
|
|
@@ -53,6 +54,7 @@ def _montar_url_api(inicio: dt.date, fim: dt.date) -> str:
|
|
|
53
54
|
return url
|
|
54
55
|
|
|
55
56
|
|
|
57
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=15))
|
|
56
58
|
@retry_padrao
|
|
57
59
|
def _buscar_texto_api(url: str) -> bytes:
|
|
58
60
|
resposta = requests.get(url, timeout=10)
|
|
@@ -15,6 +15,7 @@ Notas de implementação:
|
|
|
15
15
|
import logging
|
|
16
16
|
from enum import Enum
|
|
17
17
|
|
|
18
|
+
import cachetools
|
|
18
19
|
import polars as pl
|
|
19
20
|
import requests
|
|
20
21
|
|
|
@@ -42,6 +43,7 @@ class SerieBC(Enum):
|
|
|
42
43
|
DI_OVER = 11
|
|
43
44
|
|
|
44
45
|
|
|
46
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=15))
|
|
45
47
|
@retry_padrao
|
|
46
48
|
def _chamar_api(url_api: str) -> list[dict[str, str]]:
|
|
47
49
|
"""Executa uma chamada GET na API do BCB e retorna o JSON.
|
|
@@ -7,6 +7,7 @@ import datetime as dt
|
|
|
7
7
|
import io
|
|
8
8
|
import logging
|
|
9
9
|
|
|
10
|
+
import cachetools
|
|
10
11
|
import polars as pl
|
|
11
12
|
import polars.selectors as cs
|
|
12
13
|
import requests
|
|
@@ -93,6 +94,7 @@ ORDEM_COLUNAS_FINAL = [
|
|
|
93
94
|
]
|
|
94
95
|
|
|
95
96
|
|
|
97
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=15))
|
|
96
98
|
@retry_padrao
|
|
97
99
|
def _buscar_csv() -> str:
|
|
98
100
|
"""
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
|
+
import cachetools
|
|
3
4
|
import requests
|
|
4
5
|
|
|
5
6
|
from pyield._internal.converters import converter_datas
|
|
@@ -9,6 +10,7 @@ from pyield._internal.types import DateLike, any_is_empty
|
|
|
9
10
|
logger = logging.getLogger(__name__)
|
|
10
11
|
|
|
11
12
|
|
|
13
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=15))
|
|
12
14
|
@retry_padrao
|
|
13
15
|
def _baixar_texto(date: DateLike) -> str:
|
|
14
16
|
"""Baixa o arquivo diário do SELIC no site do BCB."""
|
|
@@ -2,6 +2,7 @@ import datetime as dt
|
|
|
2
2
|
import re
|
|
3
3
|
from dataclasses import dataclass
|
|
4
4
|
|
|
5
|
+
import cachetools
|
|
5
6
|
import requests
|
|
6
7
|
|
|
7
8
|
from pyield._internal.retry import retry_padrao
|
|
@@ -14,6 +15,7 @@ class ProjecaoIndicador:
|
|
|
14
15
|
valor_projetado: float # Valor projetado
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
@cachetools.cached(cache=cachetools.TTLCache(maxsize=16, ttl=60))
|
|
17
19
|
@retry_padrao
|
|
18
20
|
def _buscar_texto_pagina() -> str:
|
|
19
21
|
"""
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.44.1"
|
|
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
|