pyield 0.48.6__tar.gz → 0.48.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.
Files changed (70) hide show
  1. {pyield-0.48.6 → pyield-0.48.7}/PKG-INFO +1 -1
  2. pyield-0.48.7/pyield/__about__.py +1 -0
  3. pyield-0.48.7/pyield/bc/_olinda.py +33 -0
  4. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/compromissada.py +38 -69
  5. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/leiloes.py +26 -54
  6. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/sgs.py +1 -1
  7. pyield-0.48.6/pyield/__about__.py +0 -1
  8. {pyield-0.48.6 → pyield-0.48.7}/.gitignore +0 -0
  9. {pyield-0.48.6 → pyield-0.48.7}/LICENSE +0 -0
  10. {pyield-0.48.6 → pyield-0.48.7}/README.md +0 -0
  11. {pyield-0.48.6 → pyield-0.48.7}/pyield/__init__.py +0 -0
  12. {pyield-0.48.6 → pyield-0.48.7}/pyield/_internal/__init__.py +0 -0
  13. {pyield-0.48.6 → pyield-0.48.7}/pyield/_internal/br_numbers.py +0 -0
  14. {pyield-0.48.6 → pyield-0.48.7}/pyield/_internal/cache.py +0 -0
  15. {pyield-0.48.6 → pyield-0.48.7}/pyield/_internal/converters.py +0 -0
  16. {pyield-0.48.6 → pyield-0.48.7}/pyield/_internal/data_cache.py +0 -0
  17. {pyield-0.48.6 → pyield-0.48.7}/pyield/_internal/retry.py +0 -0
  18. {pyield-0.48.6 → pyield-0.48.7}/pyield/_internal/types.py +0 -0
  19. {pyield-0.48.6 → pyield-0.48.7}/pyield/anbima/__init__.py +0 -0
  20. {pyield-0.48.6 → pyield-0.48.7}/pyield/anbima/ettj_intradia.py +0 -0
  21. {pyield-0.48.6 → pyield-0.48.7}/pyield/anbima/ettj_ultima.py +0 -0
  22. {pyield-0.48.6 → pyield-0.48.7}/pyield/anbima/ima_ultimo.py +0 -0
  23. {pyield-0.48.6 → pyield-0.48.7}/pyield/anbima/imaq.py +0 -0
  24. {pyield-0.48.6 → pyield-0.48.7}/pyield/anbima/tpf.py +0 -0
  25. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/__init__.py +0 -0
  26. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/_contratos.py +0 -0
  27. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/_validar_pregao.py +0 -0
  28. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/boletim.py +0 -0
  29. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/derivativos_intradia.py +0 -0
  30. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/di1.py +0 -0
  31. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/di_over.py +0 -0
  32. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/futuro/__init__.py +0 -0
  33. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/futuro/contratos.py +0 -0
  34. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/futuro/historico.py +0 -0
  35. {pyield-0.48.6 → pyield-0.48.7}/pyield/b3/futuro/intradia.py +0 -0
  36. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/__init__.py +0 -0
  37. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/copom.py +0 -0
  38. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/tpf_intradia.py +0 -0
  39. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/tpf_mensal.py +0 -0
  40. {pyield-0.48.6 → pyield-0.48.7}/pyield/bc/vna.py +0 -0
  41. {pyield-0.48.6 → pyield-0.48.7}/pyield/du/__init__.py +0 -0
  42. {pyield-0.48.6 → pyield-0.48.7}/pyield/du/core.py +0 -0
  43. {pyield-0.48.6 → pyield-0.48.7}/pyield/du/feriados/__init__.py +0 -0
  44. {pyield-0.48.6 → pyield-0.48.7}/pyield/du/feriados/feriados_antigos_br.txt +0 -0
  45. {pyield-0.48.6 → pyield-0.48.7}/pyield/du/feriados/feriados_br.py +0 -0
  46. {pyield-0.48.6 → pyield-0.48.7}/pyield/du/feriados/feriados_novos_br.txt +0 -0
  47. {pyield-0.48.6 → pyield-0.48.7}/pyield/fwd.py +0 -0
  48. {pyield-0.48.6 → pyield-0.48.7}/pyield/interpolador.py +0 -0
  49. {pyield-0.48.6 → pyield-0.48.7}/pyield/ipca/__init__.py +0 -0
  50. {pyield-0.48.6 → pyield-0.48.7}/pyield/ipca/historico.py +0 -0
  51. {pyield-0.48.6 → pyield-0.48.7}/pyield/ipca/projetado.py +0 -0
  52. {pyield-0.48.6 → pyield-0.48.7}/pyield/py.typed +0 -0
  53. {pyield-0.48.6 → pyield-0.48.7}/pyield/relogio.py +0 -0
  54. {pyield-0.48.6 → pyield-0.48.7}/pyield/selic/__init__.py +0 -0
  55. {pyield-0.48.6 → pyield-0.48.7}/pyield/selic/cpm.py +0 -0
  56. {pyield-0.48.6 → pyield-0.48.7}/pyield/selic/probabilities.py +0 -0
  57. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/__init__.py +0 -0
  58. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/benchmark.py +0 -0
  59. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/leiloes.py +0 -0
  60. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/lft.py +0 -0
  61. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/ltn.py +0 -0
  62. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/ntnb.py +0 -0
  63. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/ntnb1.py +0 -0
  64. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/ntnbprinc.py +0 -0
  65. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/ntnc.py +0 -0
  66. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/ntnf.py +0 -0
  67. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/pre.py +0 -0
  68. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/rmd.py +0 -0
  69. {pyield-0.48.6 → pyield-0.48.7}/pyield/tn/utils.py +0 -0
  70. {pyield-0.48.6 → pyield-0.48.7}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyield
3
- Version: 0.48.6
3
+ Version: 0.48.7
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.7"
@@ -0,0 +1,33 @@
1
+ """Helpers compartilhados para acesso à API OData do BCB (olinda.bcb.gov.br)."""
2
+
3
+ import polars as pl
4
+ import requests
5
+
6
+ from pyield._internal.retry import retry_padrao
7
+
8
+
9
+ def montar_url(url_base: str, parametros: dict[str, str]) -> str:
10
+ """Monta URL OData com parâmetros opcionais e formato CSV.
11
+
12
+ Args:
13
+ url_base: URL base do endpoint OData (com '?' no final).
14
+ parametros: Dicionário ``{nome_param: valor}`` já formatado.
15
+ Parâmetros com valor vazio são ignorados.
16
+ """
17
+ partes = [f"@{k}='{v}'" for k, v in parametros.items() if v]
18
+ return url_base + "&".join(partes) + "&$format=text/csv"
19
+
20
+
21
+ @retry_padrao
22
+ def buscar_csv(url: str) -> bytes:
23
+ """Busca CSV da API OData do BCB com retry automático."""
24
+ r = requests.get(url, timeout=10)
25
+ r.raise_for_status()
26
+ return r.content
27
+
28
+
29
+ def parsear_csv(dados: bytes) -> pl.DataFrame:
30
+ """Lê CSV OData como DataFrame sem inferência de tipos."""
31
+ if not dados.strip():
32
+ return pl.DataFrame()
33
+ return pl.read_csv(dados, infer_schema=False, null_values=["null", ""])
@@ -13,63 +13,27 @@ ac1b013d13d6fb1d9d9e251b8000121e, 2025-08-21 , 12:00 , TodoMercado
13
13
  """
14
14
 
15
15
  import polars as pl
16
- import requests
17
16
 
18
17
  import pyield._internal.converters as cv
19
18
  from pyield import du
20
19
  from pyield._internal.br_numbers import float_br, taxa_br
21
- from pyield._internal.retry import retry_padrao
22
20
  from pyield._internal.types import DateLike
21
+ from pyield.bc._olinda import buscar_csv, montar_url, parsear_csv
23
22
 
24
23
  URL_BASE_API = "https://olinda.bcb.gov.br/olinda/servico/leiloes_selic/versao/v1/odata/leiloes_compromissadas(dataLancamentoInicio=@dataLancamentoInicio,dataLancamentoFim=@dataLancamentoFim,horaInicio=@horaInicio,dataLiquidacao=@dataLiquidacao,dataRetorno=@dataRetorno,publicoPermitidoLeilao=@publicoPermitidoLeilao,nomeTipoOferta=@nomeTipoOferta)?"
25
24
 
26
25
 
27
- def _montar_url(
26
+ def _montar_parametros(
28
27
  inicio: DateLike | None,
29
28
  fim: DateLike | None,
30
- ) -> str:
31
- """Monta URL de consulta conforme parâmetros opcionais de período.
32
-
33
- Regras da API:
34
- - Apenas inicio: retorna de inicio até o fim da série.
35
- - Apenas fim: retorna do início da série até fim.
36
- - Ambos ausentes: retorna a série completa.
37
- """
38
- url = URL_BASE_API
29
+ ) -> dict[str, str]:
30
+ """Converte parâmetros opcionais de período em dicionário para a URL."""
31
+ params: dict[str, str] = {}
39
32
  if inicio:
40
- inicio_dt = cv.converter_datas(inicio)
41
- inicio_str = inicio_dt.strftime("%Y-%m-%d")
42
- url += f"@dataLancamentoInicio='{inicio_str}'"
43
-
33
+ params["dataLancamentoInicio"] = cv.converter_datas(inicio).strftime("%Y-%m-%d")
44
34
  if fim:
45
- fim_dt = cv.converter_datas(fim)
46
- fim_str = fim_dt.strftime("%Y-%m-%d")
47
- url += f"&@dataLancamentoFim='{fim_str}'"
48
-
49
- url += "&$format=text/csv" # Adiciona o formato CSV ao final
50
-
51
- return url
52
-
53
-
54
- @retry_padrao
55
- def _buscar_csv_api(url: str) -> bytes:
56
- """Executa requisição HTTP e retorna o corpo CSV como string.
57
-
58
- Decorado com ``retry_padrao`` para resiliência a falhas transitórias.
59
- Levanta exceções de status HTTP para tratamento a montante.
60
- """
61
- r = requests.get(url, timeout=10)
62
- r.raise_for_status()
63
- return r.content
64
-
65
-
66
- def _ler_csv(csv_bytes: bytes) -> pl.DataFrame:
67
- """Lê o CSV (bytes) em um DataFrame Polars sem inferência de tipos."""
68
- return pl.read_csv(
69
- csv_bytes,
70
- infer_schema=False,
71
- null_values=["null", ""],
72
- )
35
+ params["dataLancamentoFim"] = cv.converter_datas(fim).strftime("%Y-%m-%d")
36
+ return params
73
37
 
74
38
 
75
39
  def _processar_df(df: pl.DataFrame) -> pl.DataFrame:
@@ -80,14 +44,14 @@ def _processar_df(df: pl.DataFrame) -> pl.DataFrame:
80
44
  data_liquidacao=pl.col("dataLiquidacao").str.to_date("%Y-%m-%d"),
81
45
  data_retorno=pl.col("dataRetorno").str.to_date("%Y-%m-%d"),
82
46
  hora_inicio=pl.col("horaInicio").str.to_time("%H:%M"),
83
- prazo_dias_corridos=pl.col("prazoDiasCorridos").cast(pl.Int64),
84
- prazo_dias_uteis=du.contar_expr("dataLiquidacao", "dataRetorno"),
85
- numero_comunicado=pl.col("numeroComunicado").cast(pl.Int64),
47
+ prazo_dc=pl.col("prazoDiasCorridos").cast(pl.Int64),
48
+ prazo_du=du.contar_expr("dataLiquidacao", "dataRetorno"),
49
+ comunicado=pl.col("numeroComunicado").cast(pl.Int64),
86
50
  tipo_oferta=pl.col("nomeTipoOferta"),
87
- publico_permitido=pl.col("publicoPermitidoLeilao"),
88
- volume_aceito=1000 * pl.col("volumeAceito").cast(pl.Int64),
51
+ publico=pl.col("publicoPermitidoLeilao"),
52
+ financeiro_aceito=1000 * pl.col("volumeAceito").cast(pl.Float64),
89
53
  taxa_corte=pl.when(vol_zero).then(None).otherwise(taxa_br("taxaCorte")),
90
- percentual_aceito=pl.when(vol_zero)
54
+ pct_aceito=pl.when(vol_zero)
91
55
  .then(0.0)
92
56
  .otherwise(100 - float_br("percentualCorte")),
93
57
  ).sort("data_leilao", "hora_inicio", "tipo_oferta")
@@ -117,36 +81,41 @@ def compromissadas(
117
81
  - data_liquidacao (Date): data de liquidação (início da operação).
118
82
  - data_retorno (Date): data de recompra / término da operação.
119
83
  - hora_inicio (Time): horário de início do leilão.
120
- - prazo_dias_corridos (Int64): dias corridos até a data de retorno.
121
- - prazo_dias_uteis (Int64): dias úteis entre liquidação e retorno
122
- (du.contar).
123
- - numero_comunicado (Int64): número do comunicado/aviso do BC (pode ser nulo).
84
+ - prazo_dc (Int64): dias corridos até a data de retorno.
85
+ - prazo_du (Int64): dias úteis entre liquidação e retorno.
86
+ - comunicado (Int64): número do comunicado/aviso do BC (pode ser nulo).
124
87
  - tipo_oferta (String): classif. do tipo de oferta (ex: Tomador, Compromissada 1047).
125
- - publico_permitido (String): escopo de participantes (SomenteDealer, TodoMercado).
126
- - volume_aceito (Int64): volume aceito no leilão em reais (convertido de milhares).
127
- - taxa_corte (Float64): taxa de corte (ex. 0.1490 = 14,90%). Nula se volume_aceito = 0.
128
- - percentual_aceito (Float64): percentual do volume ofertado efetivamente aceito (0-100).
88
+ - publico (String): público permitido no leilão (SomenteDealer, TodoMercado).
89
+ - financeiro_aceito (Float64): financeiro aceito no leilão em reais (convertido de milhares).
90
+ - taxa_corte (Float64): taxa de corte (ex. 0.1490 = 14,90%). Nula se financeiro_aceito = 0.
91
+ - pct_aceito (Float64): percentual do volume ofertado efetivamente aceito (0-100).
129
92
  100 = nenhuma rejeição. 0 indica nada aceito (volume_aceito = 0).
130
93
 
131
94
  Notes:
132
95
  - Dados ordenados por: data_leilao, hora_inicio, tipo_oferta.
133
96
 
134
97
  Examples:
98
+ >>> import polars as pl
99
+ >>> _ = pl.Config.set_tbl_width_chars(210)
100
+ >>> _ = pl.Config.set_tbl_cols(-1)
135
101
  >>> from pyield import bc
136
102
  >>> bc.compromissadas(inicio="21-08-2025", fim="21-08-2025")
137
103
  shape: (2, 12)
138
- ┌─────────────┬─────────────────┬──────────────┬─────────────┬───┬───────────────────┬───────────────┬────────────┬───────────────────┐
139
- │ data_leilao ┆ data_liquidacao ┆ data_retorno ┆ hora_inicio ┆ publico_permitidovolume_aceito ┆ taxa_corte ┆ percentual_aceito
140
- │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ ---
141
- │ date ┆ date ┆ date ┆ time ┆ ┆ str i64 ┆ f64 ┆ f64
142
- ╞═════════════╪═════════════════╪══════════════╪═════════════╪═══╪═══════════════════╪═══════════════╪════════════╪═══════════════════╡
143
- │ 2025-08-21 ┆ 2025-08-21 ┆ 2025-08-22 ┆ 09:00:00 ┆ ┆ SomenteDealer 647707406000 ┆ 0.149 ┆ 100.0
144
- │ 2025-08-21 ┆ 2025-08-22 ┆ 2025-11-21 ┆ 12:00:00 ┆ ┆ TodoMercado 5000000000 ┆ 0.9978 ┆ 35.87
145
- └─────────────┴─────────────────┴──────────────┴─────────────┴───┴───────────────────┴───────────────┴────────────┴───────────────────┘
104
+ ┌─────────────┬─────────────────┬──────────────┬─────────────┬──────────┬──────────┬────────────┬────────────────────┬───────────────┬───────────────────┬────────────┬────────────┐
105
+ │ data_leilao ┆ data_liquidacao ┆ data_retorno ┆ hora_inicio ┆ prazo_dcprazo_ducomunicadotipo_oferta ┆ publico ┆ financeiro_aceito ┆ taxa_corte ┆ pct_aceito
106
+ │ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ ---
107
+ │ date ┆ date ┆ date ┆ time ┆ i64 i64 ┆ i64 ┆ str str ┆ f64 ┆ f64 ┆ f64
108
+ ╞═════════════╪═════════════════╪══════════════╪═════════════╪══════════╪══════════╪════════════╪════════════════════╪═══════════════╪═══════════════════╪════════════╪════════════╡
109
+ │ 2025-08-21 ┆ 2025-08-21 ┆ 2025-08-22 ┆ 09:00:00 ┆ 1 ┆ 1 null ┆ Tomador ┆ SomenteDealer 6.4771e11 ┆ 0.149 ┆ 100.0
110
+ │ 2025-08-21 ┆ 2025-08-22 ┆ 2025-11-21 ┆ 12:00:00 ┆ 91 ┆ 64 43716 ┆ Compromissada 1047 ┆ TodoMercado 5.0000e9 ┆ 0.9978 ┆ 35.87
111
+ └─────────────┴─────────────────┴──────────────┴─────────────┴──────────┴──────────┴────────────┴────────────────────┴───────────────┴───────────────────┴────────────┴────────────┘
112
+ >>> _ = pl.Config.restore_defaults()
113
+ >>> _ = pl.Config.set_tbl_width_chars(150)
146
114
  """
147
- url = _montar_url(inicio=inicio, fim=fim)
148
- csv_api = _buscar_csv_api(url)
149
- df = _ler_csv(csv_api)
115
+ params = _montar_parametros(inicio, fim)
116
+ url = montar_url(URL_BASE_API, params)
117
+ dados = buscar_csv(url)
118
+ df = parsear_csv(dados)
150
119
  if df.is_empty():
151
120
  return pl.DataFrame()
152
121
  return _processar_df(df)
@@ -12,13 +12,12 @@ from typing import Literal
12
12
 
13
13
  import polars as pl
14
14
  import polars.selectors as cs
15
- import requests
16
15
 
17
16
  import pyield._internal.converters as cv
18
17
  from pyield import du
19
18
  from pyield._internal.br_numbers import float_br, taxa_br
20
- from pyield._internal.retry import retry_padrao
21
19
  from pyield._internal.types import DateLike
20
+ from pyield.bc._olinda import buscar_csv, montar_url, parsear_csv
22
21
  from pyield.bc.sgs import ptax_serie
23
22
  from pyield.tn.ntnb import duration as duration_b
24
23
  from pyield.tn.ntnf import duration as duration_f
@@ -74,39 +73,17 @@ CHAVES_ORDENACAO = ["data_leilao", "tipo_leilao", "titulo", "data_vencimento"]
74
73
  URL_BASE_API = "https://olinda.bcb.gov.br/olinda/servico/leiloes_selic/versao/v1/odata/leiloesTitulosPublicos(dataMovimentoInicio=@dataMovimentoInicio,dataMovimentoFim=@dataMovimentoFim,dataLiquidacao=@dataLiquidacao,codigoTitulo=@codigoTitulo,dataVencimento=@dataVencimento,edital=@edital,tipoPublico=@tipoPublico,tipoOferta=@tipoOferta)?"
75
74
 
76
75
 
77
- MAPA_TIPO_LEILAO = {"venda": "Venda", "compra": "Compra"}
78
-
79
-
80
- def _montar_url(
76
+ def _montar_parametros(
81
77
  inicio: DateLike | None = None,
82
78
  fim: DateLike | None = None,
83
- tipo_leilao: Literal["venda", "compra"] | None = None,
84
- ) -> str:
85
- url = URL_BASE_API
79
+ ) -> dict[str, str]:
80
+ """Converte parâmetros opcionais de período em dicionário para a URL."""
81
+ params: dict[str, str] = {}
86
82
  if inicio:
87
- inicio = cv.converter_datas(inicio)
88
- url += f"@dataMovimentoInicio='{inicio:%Y-%m-%d}'"
83
+ params["dataMovimentoInicio"] = cv.converter_datas(inicio).strftime("%Y-%m-%d")
89
84
  if fim:
90
- fim = cv.converter_datas(fim)
91
- url += f"&@dataMovimentoFim='{fim:%Y-%m-%d}'"
92
- if tipo_leilao:
93
- url += f"&@tipoOferta='{MAPA_TIPO_LEILAO[tipo_leilao.lower()]}'"
94
- url += "&$format=text/csv"
95
- return url
96
-
97
-
98
- @retry_padrao
99
- def _buscar_csv(url: str) -> bytes:
100
- resposta = requests.get(url, timeout=10)
101
- resposta.raise_for_status()
102
- return resposta.content
103
-
104
-
105
- def _parsear_df(dados: bytes) -> pl.DataFrame:
106
- """Lê CSV como strings."""
107
- if not dados.strip():
108
- return pl.DataFrame()
109
- return pl.read_csv(dados, infer_schema=False, null_values=["null"])
85
+ params["dataMovimentoFim"] = cv.converter_datas(fim).strftime("%Y-%m-%d")
86
+ return params
110
87
 
111
88
 
112
89
  def _processar_df(df: pl.DataFrame) -> pl.DataFrame:
@@ -147,9 +124,7 @@ def _processar_df(df: pl.DataFrame) -> pl.DataFrame:
147
124
  pu_corte=float_br("cotacaoCorte"),
148
125
  taxa_media=taxa_br("taxaMedia"),
149
126
  taxa_corte=taxa_br("taxaCorte"),
150
- financeiro_total=(float_br("financeiro") * 1_000_000)
151
- .round(0)
152
- .cast(pl.Int64),
127
+ financeiro_total=float_br("financeiro") * 1_000_000,
153
128
  quantidade_ofertada_1v=pl.col("quantidadeOfertada").cast(pl.Int64),
154
129
  quantidade_aceita_1v=pl.col("quantidadeAceita").cast(pl.Int64),
155
130
  quantidade_liquidada_1v=pl.col("quantidadeLiquidada").cast(pl.Int64),
@@ -182,9 +157,7 @@ def _processar_df(df: pl.DataFrame) -> pl.DataFrame:
182
157
  (pl.col("quantidade_aceita_1v") / pl.col("quantidade_aceita_total"))
183
158
  * pl.col("financeiro_total")
184
159
  )
185
- .otherwise(0)
186
- .round(0)
187
- .cast(pl.Int64),
160
+ .otherwise(0.0),
188
161
  )
189
162
  .with_columns(
190
163
  financeiro_2v=pl.col("financeiro_total") - pl.col("financeiro_1v"),
@@ -319,9 +292,9 @@ def leiloes(
319
292
  * quantidade_aceita_1v (Int64): qtd aceita 1ª volta.
320
293
  * quantidade_aceita_2v (Int64): qtd aceita 2ª volta.
321
294
  * quantidade_aceita_total (Int64): qtd total aceita.
322
- * financeiro_1v (Int64): financeiro 1ª volta em R$.
323
- * financeiro_2v (Int64): financeiro 2ª volta em R$.
324
- * financeiro_total (Int64): financeiro total em R$.
295
+ * financeiro_1v (Float64): financeiro 1ª volta em R$.
296
+ * financeiro_2v (Float64): financeiro 2ª volta em R$.
297
+ * financeiro_total (Float64): financeiro total em R$.
325
298
 
326
299
  Notes:
327
300
  1v = primeira volta (rodada), 2v = segunda volta.
@@ -333,24 +306,23 @@ def leiloes(
333
306
  ┌─────────────┬─────────────────┬─────────────┬───────────────┬───┬─────────────────────────┬───────────────┬───────────────┬──────────────────┐
334
307
  │ data_leilao ┆ data_liquidacao ┆ tipo_leilao ┆ numero_edital ┆ … ┆ quantidade_aceita_total ┆ financeiro_1v ┆ financeiro_2v ┆ financeiro_total │
335
308
  │ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
336
- │ date ┆ date ┆ str ┆ i64 ┆ ┆ i64 ┆ i64i64i64
309
+ │ date ┆ date ┆ str ┆ i64 ┆ ┆ i64 ┆ f64f64f64
337
310
  ╞═════════════╪═════════════════╪═════════════╪═══════════════╪═══╪═════════════════════════╪═══════════════╪═══════════════╪══════════════════╡
338
- │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 192 ┆ … ┆ 150000 ┆ 2572400000 ┆ 0 2572400000
339
- │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 192 ┆ … ┆ 751003 ┆ 12804476147 1712385312821600000
340
- │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 193 ┆ … ┆ 300759 ┆ 1289936461 3263539 1293200000
341
- │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 194 ┆ … ┆ 500542 ┆ 2071654327 2245673 2073900000
342
- │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 194 ┆ … ┆ 500000 ┆ 2010700000 ┆ 0 2010700000
311
+ │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 192 ┆ … ┆ 150000 ┆ 2.5724e9 ┆ 0.0 2.5724e9
312
+ │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 192 ┆ … ┆ 751003 ┆ 1.2804e10 1.7124e71.2822e10
313
+ │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 193 ┆ … ┆ 300759 ┆ 1.2899e9 3.2635e6 1.2932e9
314
+ │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 194 ┆ … ┆ 500542 ┆ 2.0717e9 2.2457e6 2.0739e9
315
+ │ 2025-08-19 ┆ 2025-08-20 ┆ Venda ┆ 194 ┆ … ┆ 500000 ┆ 2.0107e9 ┆ 0.0 2.0107e9
343
316
  └─────────────┴─────────────────┴─────────────┴───────────────┴───┴─────────────────────────┴───────────────┴───────────────┴──────────────────┘
344
317
  """
345
- url = _montar_url(
346
- inicio=inicio,
347
- fim=fim,
348
- tipo_leilao=tipo_leilao,
349
- )
350
- dados = _buscar_csv(url)
351
- df = _parsear_df(dados)
318
+ url = montar_url(URL_BASE_API, _montar_parametros(inicio, fim))
319
+ dados = buscar_csv(url)
320
+ df = parsear_csv(dados)
352
321
  if df.is_empty():
353
322
  return pl.DataFrame()
354
323
  df = _processar_df(df)
355
324
  df = _adicionar_dv01_usd(df)
356
- return df.select(ORDEM_COLUNAS_FINAL).sort(CHAVES_ORDENACAO)
325
+ df = df.select(ORDEM_COLUNAS_FINAL).sort(CHAVES_ORDENACAO)
326
+ if tipo_leilao:
327
+ df = df.filter(pl.col("tipo_leilao").str.to_lowercase() == tipo_leilao.lower())
328
+ return df
@@ -59,7 +59,7 @@ class SerieSGS(Enum):
59
59
  @ttl_cache()
60
60
  @retry_padrao
61
61
  def _chamar_api(url_api: str) -> list[dict[str, str]]:
62
- resposta = requests.get(url_api, timeout=10)
62
+ resposta = requests.get(url_api, timeout=30)
63
63
  resposta.raise_for_status()
64
64
  return resposta.json()
65
65
 
@@ -1 +0,0 @@
1
- __version__ = "0.48.6"
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