pyield 0.48.8__tar.gz → 0.48.9__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 (67) hide show
  1. {pyield-0.48.8 → pyield-0.48.9}/PKG-INFO +1 -1
  2. pyield-0.48.9/pyield/__about__.py +1 -0
  3. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/boletim.py +8 -1
  4. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/futuro/__init__.py +4 -4
  5. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/futuro/historico.py +18 -5
  6. pyield-0.48.8/pyield/__about__.py +0 -1
  7. {pyield-0.48.8 → pyield-0.48.9}/.gitignore +0 -0
  8. {pyield-0.48.8 → pyield-0.48.9}/LICENSE +0 -0
  9. {pyield-0.48.8 → pyield-0.48.9}/README.md +0 -0
  10. {pyield-0.48.8 → pyield-0.48.9}/pyield/__init__.py +0 -0
  11. {pyield-0.48.8 → pyield-0.48.9}/pyield/_internal/__init__.py +0 -0
  12. {pyield-0.48.8 → pyield-0.48.9}/pyield/_internal/br_numbers.py +0 -0
  13. {pyield-0.48.8 → pyield-0.48.9}/pyield/_internal/cache.py +0 -0
  14. {pyield-0.48.8 → pyield-0.48.9}/pyield/_internal/converters.py +0 -0
  15. {pyield-0.48.8 → pyield-0.48.9}/pyield/_internal/data_cache.py +0 -0
  16. {pyield-0.48.8 → pyield-0.48.9}/pyield/_internal/retry.py +0 -0
  17. {pyield-0.48.8 → pyield-0.48.9}/pyield/_internal/types.py +0 -0
  18. {pyield-0.48.8 → pyield-0.48.9}/pyield/anbima/__init__.py +0 -0
  19. {pyield-0.48.8 → pyield-0.48.9}/pyield/anbima/imaq.py +0 -0
  20. {pyield-0.48.8 → pyield-0.48.9}/pyield/anbima/tpf.py +0 -0
  21. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/__init__.py +0 -0
  22. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/_contratos.py +0 -0
  23. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/_validar_pregao.py +0 -0
  24. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/derivativos_intradia.py +0 -0
  25. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/di1.py +0 -0
  26. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/di_over.py +0 -0
  27. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/futuro/contratos.py +0 -0
  28. {pyield-0.48.8 → pyield-0.48.9}/pyield/b3/futuro/intradia.py +0 -0
  29. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/__init__.py +0 -0
  30. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/_olinda.py +0 -0
  31. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/compromissada.py +0 -0
  32. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/copom.py +0 -0
  33. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/leiloes.py +0 -0
  34. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/sgs.py +0 -0
  35. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/tpf_intradia.py +0 -0
  36. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/tpf_mensal.py +0 -0
  37. {pyield-0.48.8 → pyield-0.48.9}/pyield/bc/vna.py +0 -0
  38. {pyield-0.48.8 → pyield-0.48.9}/pyield/du/__init__.py +0 -0
  39. {pyield-0.48.8 → pyield-0.48.9}/pyield/du/core.py +0 -0
  40. {pyield-0.48.8 → pyield-0.48.9}/pyield/du/feriados/__init__.py +0 -0
  41. {pyield-0.48.8 → pyield-0.48.9}/pyield/du/feriados/feriados_antigos_br.txt +0 -0
  42. {pyield-0.48.8 → pyield-0.48.9}/pyield/du/feriados/feriados_br.py +0 -0
  43. {pyield-0.48.8 → pyield-0.48.9}/pyield/du/feriados/feriados_novos_br.txt +0 -0
  44. {pyield-0.48.8 → pyield-0.48.9}/pyield/fwd.py +0 -0
  45. {pyield-0.48.8 → pyield-0.48.9}/pyield/interpolador.py +0 -0
  46. {pyield-0.48.8 → pyield-0.48.9}/pyield/ipca/__init__.py +0 -0
  47. {pyield-0.48.8 → pyield-0.48.9}/pyield/ipca/historico.py +0 -0
  48. {pyield-0.48.8 → pyield-0.48.9}/pyield/ipca/projetado.py +0 -0
  49. {pyield-0.48.8 → pyield-0.48.9}/pyield/py.typed +0 -0
  50. {pyield-0.48.8 → pyield-0.48.9}/pyield/relogio.py +0 -0
  51. {pyield-0.48.8 → pyield-0.48.9}/pyield/selic/__init__.py +0 -0
  52. {pyield-0.48.8 → pyield-0.48.9}/pyield/selic/cpm.py +0 -0
  53. {pyield-0.48.8 → pyield-0.48.9}/pyield/selic/probabilities.py +0 -0
  54. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/__init__.py +0 -0
  55. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/benchmark.py +0 -0
  56. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/leiloes.py +0 -0
  57. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/lft.py +0 -0
  58. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/ltn.py +0 -0
  59. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/ntnb.py +0 -0
  60. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/ntnb1.py +0 -0
  61. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/ntnbprinc.py +0 -0
  62. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/ntnc.py +0 -0
  63. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/ntnf.py +0 -0
  64. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/pre.py +0 -0
  65. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/rmd.py +0 -0
  66. {pyield-0.48.8 → pyield-0.48.9}/pyield/tn/utils.py +0 -0
  67. {pyield-0.48.8 → pyield-0.48.9}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyield
3
- Version: 0.48.8
3
+ Version: 0.48.9
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.9"
@@ -102,6 +102,13 @@ COLUNAS_PRICE_REPORT: list[tuple[str, str, type[pl.DataType]]] = [
102
102
  SCHEMA_PRICE_REPORT = {nome: tipo for _, nome, tipo in COLUNAS_PRICE_REPORT}
103
103
 
104
104
 
105
+ _SESSAO = requests.Session()
106
+ _SESSAO.headers["User-Agent"] = (
107
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
108
+ " (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36"
109
+ )
110
+
111
+
105
112
  @ttl_cache()
106
113
  @retry_padrao
107
114
  def _baixar_zip_url(data: dt.date, boletim_completo: bool) -> bytes:
@@ -113,7 +120,7 @@ def _baixar_zip_url(data: dt.date, boletim_completo: bool) -> bytes:
113
120
  f"https://www.b3.com.br/pesquisapregao/download?filelist=SPRD{data_str}.zip"
114
121
  )
115
122
 
116
- resposta = requests.get(url, timeout=(5, 30))
123
+ resposta = _SESSAO.get(url, timeout=(5, 30))
117
124
  resposta.raise_for_status()
118
125
 
119
126
  if len(resposta.content) < MIN_TAMANHO_ZIP_BYTES:
@@ -13,12 +13,12 @@ def futuro_enriquecer(
13
13
  """Enriquece DataFrame bruto do Price Report (PR) da B3.
14
14
 
15
15
  Aceita um DataFrame com colunas no schema original da B3
16
- (ex.: ``TradDt``, ``TckrSymb``) ou renomeadas para o padrão
17
- PYield. Adiciona data de vencimento, dias úteis/corridos e
18
- colunas derivadas (dv01, taxa_forward) conforme o contrato.
16
+ (ex.: ``TradDt``, ``TckrSymb``). Filtra pelo contrato informado,
17
+ adiciona data de vencimento, dias úteis/corridos e colunas
18
+ derivadas (dv01, taxa_forward) conforme o contrato.
19
19
 
20
20
  Args:
21
- df: DataFrame com dados do PR da B3.
21
+ df: DataFrame com dados brutos do PR da B3.
22
22
  contrato: Contrato futuro
23
23
  (ex.: "DI1", "DOL").
24
24
 
@@ -76,6 +76,9 @@ _COLUNAS_CONTRATO_TAXA = (
76
76
  "taxa_forward",
77
77
  )
78
78
 
79
+ # Comprimento padrão de ticker de futuro na B3 (prefixo 3 + mês 1 + ano 2).
80
+ _COMPRIMENTO_TICKER = 6
81
+
79
82
  # Normaliza o schema XML bruto da B3 para o padrão de colunas deste módulo.
80
83
  _RENOMEAR_COLUNAS_PR = {
81
84
  "TradDt": "data_referencia",
@@ -125,7 +128,11 @@ def _enriquecer_dados(df: pl.DataFrame, contrato: str) -> pl.DataFrame:
125
128
 
126
129
  if contrato in {"DI1", "DAP"}:
127
130
  df = df.with_columns(
128
- taxa_forward=forwards(dias_uteis=df["dias_uteis"], taxas=df["taxa_ajuste"])
131
+ taxa_forward=forwards(
132
+ dias_uteis=df["dias_uteis"],
133
+ taxas=df["taxa_ajuste"],
134
+ agrupar_por=df["data_referencia"],
135
+ )
129
136
  )
130
137
 
131
138
  return df
@@ -156,12 +163,12 @@ def enriquecer(df: pl.DataFrame, contrato: str) -> pl.DataFrame:
156
163
  """Enriquece DataFrame bruto do Price Report (PR) da B3.
157
164
 
158
165
  Aceita um DataFrame com colunas no schema original da B3 (ex.:
159
- ``TradDt``, ``TckrSymb``) ou renomeadas para o padrão PYield.
160
- Adiciona data de vencimento, dias úteis/corridos e colunas derivadas
161
- (dv01, taxa_forward) conforme o contrato.
166
+ ``TradDt``, ``TckrSymb``). Filtra pelo contrato informado,
167
+ adiciona data de vencimento, dias úteis/corridos e colunas
168
+ derivadas (dv01, taxa_forward) conforme o contrato.
162
169
 
163
170
  Args:
164
- df: DataFrame com dados do PR da B3.
171
+ df: DataFrame com dados brutos do PR da B3.
165
172
  contrato: Contrato futuro (ex.: "DI1", "DOL").
166
173
 
167
174
  Returns:
@@ -171,6 +178,12 @@ def enriquecer(df: pl.DataFrame, contrato: str) -> pl.DataFrame:
171
178
  return pl.DataFrame()
172
179
 
173
180
  df = df.rename(_RENOMEAR_COLUNAS_PR)
181
+ df = df.filter(
182
+ pl.col("codigo_negociacao").str.starts_with(contrato),
183
+ pl.col("codigo_negociacao").str.len_chars() == _COMPRIMENTO_TICKER,
184
+ )
185
+ if df.is_empty():
186
+ return pl.DataFrame()
174
187
  df = adicionar_vencimento(df, contrato, coluna_ticker="codigo_negociacao")
175
188
  df = _enriquecer_dados(df, contrato)
176
189
  df = _selecionar_colunas_saida(df, contrato)
@@ -1 +0,0 @@
1
- __version__ = "0.48.8"
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