PYield 0.40.2__tar.gz → 0.40.3__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 (59) hide show
  1. {pyield-0.40.2 → pyield-0.40.3}/PKG-INFO +1 -1
  2. pyield-0.40.3/pyield/__about__.py +1 -0
  3. {pyield-0.40.2 → pyield-0.40.3}/pyield/data_cache.py +0 -3
  4. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/auctions.py +26 -37
  5. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/ntnf.py +0 -2
  6. pyield-0.40.2/pyield/__about__.py +0 -1
  7. {pyield-0.40.2 → pyield-0.40.3}/.gitignore +0 -0
  8. {pyield-0.40.2 → pyield-0.40.3}/LICENSE +0 -0
  9. {pyield-0.40.2 → pyield-0.40.3}/README.md +0 -0
  10. {pyield-0.40.2 → pyield-0.40.3}/pyield/__init__.py +0 -0
  11. {pyield-0.40.2 → pyield-0.40.3}/pyield/anbima/__init__.py +0 -0
  12. {pyield-0.40.2 → pyield-0.40.3}/pyield/anbima/difusao.py +0 -0
  13. {pyield-0.40.2 → pyield-0.40.3}/pyield/anbima/ettj_intraday.py +0 -0
  14. {pyield-0.40.2 → pyield-0.40.3}/pyield/anbima/ettj_last.py +0 -0
  15. {pyield-0.40.2 → pyield-0.40.3}/pyield/anbima/ima.py +0 -0
  16. {pyield-0.40.2 → pyield-0.40.3}/pyield/anbima/imaq.py +0 -0
  17. {pyield-0.40.2 → pyield-0.40.3}/pyield/anbima/tpf.py +0 -0
  18. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/__init__.py +0 -0
  19. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/di1.py +0 -0
  20. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/di_over.py +0 -0
  21. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/futures/__init__.py +0 -0
  22. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/futures/common.py +0 -0
  23. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/futures/historical.py +0 -0
  24. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/futures/intraday.py +0 -0
  25. {pyield-0.40.2 → pyield-0.40.3}/pyield/b3/futures/xml.py +0 -0
  26. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/__init__.py +0 -0
  27. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/auction.py +0 -0
  28. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/ptax_api.py +0 -0
  29. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/rates.py +0 -0
  30. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/repo.py +0 -0
  31. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/trades_intraday.py +0 -0
  32. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/trades_monthly.py +0 -0
  33. {pyield-0.40.2 → pyield-0.40.3}/pyield/bc/vna.py +0 -0
  34. {pyield-0.40.2 → pyield-0.40.3}/pyield/bday/__init__.py +0 -0
  35. {pyield-0.40.2 → pyield-0.40.3}/pyield/bday/core.py +0 -0
  36. {pyield-0.40.2 → pyield-0.40.3}/pyield/bday/holidays/__init__.py +0 -0
  37. {pyield-0.40.2 → pyield-0.40.3}/pyield/bday/holidays/br_holidays_new.txt +0 -0
  38. {pyield-0.40.2 → pyield-0.40.3}/pyield/bday/holidays/br_holidays_old.txt +0 -0
  39. {pyield-0.40.2 → pyield-0.40.3}/pyield/bday/holidays/brholidays.py +0 -0
  40. {pyield-0.40.2 → pyield-0.40.3}/pyield/config.py +0 -0
  41. {pyield-0.40.2 → pyield-0.40.3}/pyield/conftest.py +0 -0
  42. {pyield-0.40.2 → pyield-0.40.3}/pyield/converters.py +0 -0
  43. {pyield-0.40.2 → pyield-0.40.3}/pyield/fwd.py +0 -0
  44. {pyield-0.40.2 → pyield-0.40.3}/pyield/interpolator.py +0 -0
  45. {pyield-0.40.2 → pyield-0.40.3}/pyield/ipca/__init__.py +0 -0
  46. {pyield-0.40.2 → pyield-0.40.3}/pyield/ipca/historical.py +0 -0
  47. {pyield-0.40.2 → pyield-0.40.3}/pyield/ipca/projected.py +0 -0
  48. {pyield-0.40.2 → pyield-0.40.3}/pyield/py.typed +0 -0
  49. {pyield-0.40.2 → pyield-0.40.3}/pyield/retry.py +0 -0
  50. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/__init__.py +0 -0
  51. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/benchmark.py +0 -0
  52. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/lft.py +0 -0
  53. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/ltn.py +0 -0
  54. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/ntnb.py +0 -0
  55. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/ntnc.py +0 -0
  56. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/pre.py +0 -0
  57. {pyield-0.40.2 → pyield-0.40.3}/pyield/tn/tools.py +0 -0
  58. {pyield-0.40.2 → pyield-0.40.3}/pyield/types.py +0 -0
  59. {pyield-0.40.2 → pyield-0.40.3}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PYield
3
- Version: 0.40.2
3
+ Version: 0.40.3
4
4
  Summary: A Python library for analysis of fixed income instruments in Brazil
5
5
  Project-URL: Source, https://github.com/crdcj/PYield
6
6
  Author-email: Carlos Carvalho <cr.cj@outlook.com>
@@ -0,0 +1 @@
1
+ __version__ = "0.40.3"
@@ -72,9 +72,6 @@ def _get_dataset_with_ttl(dataset_id: str, date_key: str) -> pl.DataFrame:
72
72
  raise
73
73
 
74
74
 
75
- # --- API Pública ---
76
-
77
-
78
75
  def get_cached_dataset(dataset_id: DatasetId) -> pl.DataFrame:
79
76
  """
80
77
  Obtém um dataset configurado pelo seu ID, garantindo que o cache
@@ -130,13 +130,7 @@ def _transform_raw_data(raw_data: list[dict]) -> pl.DataFrame:
130
130
  .rename(COLUMN_MAP)
131
131
  .with_columns(
132
132
  # Conversão de datas
133
- cs.starts_with("data_")
134
- .exclude("data_liquidacao_2v")
135
- .str.strptime(pl.Date, "%d/%m/%Y"),
136
- # Tratamento da data de 2ª volta que tem formato diferente
137
- pl.col("data_liquidacao_2v").str.strptime(
138
- pl.Date, "%Y-%m-%dT%H:%M:%S%.f%#z", strict=False
139
- ),
133
+ cs.starts_with("data_").str.strptime(pl.Date, "%d/%m/%Y"),
140
134
  # Cálculos de totais
141
135
  pl.sum_horizontal("quantidade_ofertada_1v", "quantidade_ofertada_2v").alias(
142
136
  "quantidade_ofertada_total"
@@ -192,28 +186,25 @@ def _transform_raw_data(raw_data: list[dict]) -> pl.DataFrame:
192
186
  cs.starts_with("financeiro_ofertado").round(2),
193
187
  (cs.starts_with("taxa") / 100).round(7), # Percentual -> decimal
194
188
  )
195
- .with_columns(
196
- # Aplicar a lógica condicional em um segundo passo para evitar
197
- # conflito de nomes duplicados dentro do MESMO with_columns.
198
- [
199
- pl.when(pl.col("quantidade_aceita_1v") == 0)
200
- .then(None)
201
- .otherwise(pl.col(col))
202
- .alias(col)
203
- for col in [
204
- "pu_minimo",
205
- "pu_medio",
206
- "tipo_pu_medio",
207
- "taxa_media",
208
- "taxa_maxima",
209
- ]
210
- ]
211
- )
189
+ )
190
+ ajustar_cols = [
191
+ "pu_minimo",
192
+ "pu_medio",
193
+ "tipo_pu_medio",
194
+ "taxa_media",
195
+ "taxa_maxima",
196
+ ]
197
+ # Se a quantidade aceita for zero, ajustar colunas específicas para None
198
+ df = df.with_columns(
199
+ pl.when(pl.col("quantidade_aceita_1v") == 0)
200
+ .then(None)
201
+ .otherwise(pl.col(ajustar_cols))
202
+ .name.keep()
212
203
  )
213
204
 
214
205
  # Cálculo de dias úteis (requer acesso a colunas já convertidas)
215
206
  dias_uteis = bday.count(df["data_liquidacao_1v"], df["data_vencimento"])
216
- df = df.with_columns(pl.Series(name="dias_uteis", values=dias_uteis))
207
+ df = df.with_columns(dias_uteis.alias("dias_uteis"))
217
208
  return df.sort(["data_1v", "titulo", "data_vencimento"])
218
209
 
219
210
 
@@ -244,13 +235,11 @@ def _add_duration(df: pl.DataFrame) -> pl.DataFrame:
244
235
 
245
236
  df = df.with_columns(
246
237
  pl.struct(
247
- [
248
- "titulo",
249
- "data_liquidacao_1v",
250
- "data_vencimento",
251
- "taxa_media",
252
- "dias_uteis",
253
- ]
238
+ "titulo",
239
+ "data_liquidacao_1v",
240
+ "data_vencimento",
241
+ "taxa_media",
242
+ "dias_uteis",
254
243
  )
255
244
  .map_elements(calculate_duration_per_row, return_dtype=pl.Float64)
256
245
  .alias("duration")
@@ -279,9 +268,9 @@ def _add_dv01(df: pl.DataFrame) -> pl.DataFrame:
279
268
 
280
269
  df = df.with_columns(
281
270
  # 2. Criar as colunas DV01 multiplicando a expressão base pelas quantidades.
282
- (dv01_unit_expr * pl.col("quantidade_aceita_1v")).alias("dv01_1v"),
283
- (dv01_unit_expr * pl.col("quantidade_aceita_2v")).alias("dv01_2v"),
284
- (dv01_unit_expr * pl.col("quantidade_aceita_total")).alias("dv01_total"),
271
+ dv01_1v=dv01_unit_expr * pl.col("quantidade_aceita_1v"),
272
+ dv01_2v=dv01_unit_expr * pl.col("quantidade_aceita_2v"),
273
+ dv01_total=dv01_unit_expr * pl.col("quantidade_aceita_total"),
285
274
  ).with_columns(cs.starts_with("dv01").round(2))
286
275
 
287
276
  return df
@@ -301,7 +290,7 @@ def _fetch_ptax_data(auction_date: dt.date) -> pl.DataFrame:
301
290
  return pl.DataFrame()
302
291
 
303
292
  return (
304
- df.select(["Date", "MidRate"])
293
+ df.select("Date", "MidRate")
305
294
  .rename({"Date": "data_ref", "MidRate": "ptax"})
306
295
  .sort("data_ref")
307
296
  )
@@ -346,7 +335,7 @@ def auction(auction_date: DateScalar) -> pl.DataFrame:
346
335
  {...},
347
336
  {
348
337
  "quantidade_bcb": 0,
349
- "liquidacao_segunda_volta": "2025-10-01T00:00:00.000Z",
338
+ "liquidacao_segunda_volta": "30/09/2025",
350
339
  "oferta_segunda_volta": 37499,
351
340
  "data_leilao": "30/09/2025",
352
341
  "oferta": 150000,
@@ -647,8 +647,6 @@ def di_net_spread( # noqa
647
647
  ntnf_rate (float): The yield to maturity (YTM) of the bond.
648
648
  di_rates (FloatArray): A Series of DI rates.
649
649
  di_expirations (DateArray): A list or Series of DI expiration dates.
650
- initial_guess (float, optional): An initial guess for the spread. Defaults to
651
- None. A good initial guess is the DI gross spread for the bond.
652
650
 
653
651
  Returns:
654
652
  float: The net DI spread in decimal format (e.g., 0.0012 for 12 bps).
@@ -1 +0,0 @@
1
- __version__ = "0.40.2"
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