PYield 0.35.7__tar.gz → 0.35.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 (52) hide show
  1. {pyield-0.35.7 → pyield-0.35.9}/PKG-INFO +1 -1
  2. pyield-0.35.9/pyield/__about__.py +1 -0
  3. {pyield-0.35.7 → pyield-0.35.9}/pyield/bday.py +186 -95
  4. {pyield-0.35.7 → pyield-0.35.9}/pyield/date_converter.py +12 -3
  5. {pyield-0.35.7 → pyield-0.35.9}/pyield/holidays/brholidays.py +2 -1
  6. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/auction.py +2 -2
  7. pyield-0.35.7/pyield/__about__.py +0 -1
  8. {pyield-0.35.7 → pyield-0.35.9}/.gitignore +0 -0
  9. {pyield-0.35.7 → pyield-0.35.9}/LICENSE +0 -0
  10. {pyield-0.35.7 → pyield-0.35.9}/README.md +0 -0
  11. {pyield-0.35.7 → pyield-0.35.9}/pyield/__init__.py +0 -0
  12. {pyield-0.35.7 → pyield-0.35.9}/pyield/anbima/__init__.py +0 -0
  13. {pyield-0.35.7 → pyield-0.35.9}/pyield/anbima/ettj.py +0 -0
  14. {pyield-0.35.7 → pyield-0.35.9}/pyield/anbima/ima.py +0 -0
  15. {pyield-0.35.7 → pyield-0.35.9}/pyield/anbima/imaq.py +0 -0
  16. {pyield-0.35.7 → pyield-0.35.9}/pyield/anbima/ipca.py +0 -0
  17. {pyield-0.35.7 → pyield-0.35.9}/pyield/anbima/tpf.py +0 -0
  18. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/__init__.py +0 -0
  19. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/di1.py +0 -0
  20. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/di_over.py +0 -0
  21. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/futures/__init__.py +0 -0
  22. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/futures/common.py +0 -0
  23. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/futures/historical.py +0 -0
  24. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/futures/intraday.py +0 -0
  25. {pyield-0.35.7 → pyield-0.35.9}/pyield/b3/futures/xml.py +0 -0
  26. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/__init__.py +0 -0
  27. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/auction.py +0 -0
  28. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/bcdata.py +0 -0
  29. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/ptax.py +0 -0
  30. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/repo.py +0 -0
  31. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/trades_intraday.py +0 -0
  32. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/trades_monthly.py +0 -0
  33. {pyield-0.35.7 → pyield-0.35.9}/pyield/bc/vna.py +0 -0
  34. {pyield-0.35.7 → pyield-0.35.9}/pyield/conftest.py +0 -0
  35. {pyield-0.35.7 → pyield-0.35.9}/pyield/data_cache.py +0 -0
  36. {pyield-0.35.7 → pyield-0.35.9}/pyield/fwd.py +0 -0
  37. {pyield-0.35.7 → pyield-0.35.9}/pyield/holidays/__init__.py +0 -0
  38. {pyield-0.35.7 → pyield-0.35.9}/pyield/holidays/br_holidays_new.txt +0 -0
  39. {pyield-0.35.7 → pyield-0.35.9}/pyield/holidays/br_holidays_old.txt +0 -0
  40. {pyield-0.35.7 → pyield-0.35.9}/pyield/ibge/__init__.py +0 -0
  41. {pyield-0.35.7 → pyield-0.35.9}/pyield/ibge/ipca.py +0 -0
  42. {pyield-0.35.7 → pyield-0.35.9}/pyield/interpolator.py +0 -0
  43. {pyield-0.35.7 → pyield-0.35.9}/pyield/py.typed +0 -0
  44. {pyield-0.35.7 → pyield-0.35.9}/pyield/retry.py +0 -0
  45. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/__init__.py +0 -0
  46. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/lft.py +0 -0
  47. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/ltn.py +0 -0
  48. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/ntnb.py +0 -0
  49. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/ntnc.py +0 -0
  50. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/ntnf.py +0 -0
  51. {pyield-0.35.7 → pyield-0.35.9}/pyield/tn/tools.py +0 -0
  52. {pyield-0.35.7 → pyield-0.35.9}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PYield
3
- Version: 0.35.7
3
+ Version: 0.35.9
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.35.9"
@@ -44,7 +44,7 @@ def offset(
44
44
  ) -> pd.Series: ...
45
45
 
46
46
 
47
- def offset(
47
+ def offset( # noqa
48
48
  dates: DateScalar | DateArray,
49
49
  offset: IntegerScalar | IntegerArray,
50
50
  roll: Literal["forward", "backward"] = "forward",
@@ -56,8 +56,11 @@ def offset(
56
56
  dates. It is a wrapper for `numpy.busday_offset` adapted for Pandas data types and
57
57
  brazilian holidays.
58
58
 
59
- **Important Note:** The `dates` parameter is used to determine which list of
60
- holidays applies to the calculation.
59
+ **Important Note:** Each date in the `dates` input is evaluated individually to
60
+ determine which list of holidays applies to the calculation. Transition date
61
+ is 2023-12-26, which means:
62
+ - Dates before 2023-12-26 use the old holiday list.
63
+ - Dates on or after 2023-12-26 use the new holiday list.
61
64
 
62
65
  Args:
63
66
  dates (DateScalar | DateArray): The date(s) to offset. Can be a scalar date type
@@ -135,6 +138,33 @@ def offset(
135
138
  1 2024-09-23
136
139
  dtype: datetime64[ns]
137
140
 
141
+ Null values are propagated
142
+
143
+ >>> bday.offset(pd.NaT, 1) # NaT input
144
+ NaT
145
+
146
+ >>> bday.offset(pd.NaT, [1, 2]) # NaT input with a list of offsets
147
+ 0 NaT
148
+ 1 NaT
149
+ dtype: datetime64[ns]
150
+
151
+ >>> bday.offset(["19-09-2024", pd.NaT], 1) # NaT in a list of dates
152
+ 0 2024-09-20
153
+ 1 NaT
154
+ dtype: datetime64[ns]
155
+
156
+ Original pandas index is preserved
157
+
158
+ >>> dates = pd.Series(
159
+ ... ["19-09-2024", "20-09-2024", "21-09-2024"],
160
+ ... index=["a", "b", "c"],
161
+ ... )
162
+ >>> bday.offset(dates, 1)
163
+ a 2024-09-20
164
+ b 2024-09-23
165
+ c 2024-09-24
166
+ dtype: datetime64[ns]
167
+
138
168
  Note:
139
169
  This function uses `numpy.busday_offset` under the hood, which means it follows
140
170
  the same conventions and limitations for business day calculations. For detailed
@@ -142,62 +172,89 @@ def offset(
142
172
  documentation:
143
173
  https://numpy.org/doc/stable/reference/generated/numpy.busday_offset.html
144
174
  """
175
+ # Padroniza as entradas para objetos do Pandas
145
176
  dates_pd = dc.convert_input_dates(dates)
177
+ offset_pd = pd.Series(offset) if isinstance(offset, IntegerArray) else offset
146
178
 
147
- if isinstance(dates_pd, pd.Series):
148
- # Divide the input in order to apply the correct holiday list
149
- old_dates = dates_pd[dates_pd < br_holidays.TRANSITION_DATE]
150
- new_dates = dates_pd[dates_pd >= br_holidays.TRANSITION_DATE]
151
- # nat = NaT = Not a Time = missing value
152
- nat_dates = dates_pd[dates_pd.isna()]
153
-
154
- offsetted_old_dates = np.busday_offset(
155
- dc.to_numpy_date_type(old_dates),
156
- offsets=offset,
157
- roll=roll,
158
- holidays=OLD_HOLIDAYS_ARRAY,
159
- )
160
-
161
- offsetted_new_dates = np.busday_offset(
162
- dc.to_numpy_date_type(new_dates),
163
- offsets=offset,
164
- roll=roll,
165
- holidays=NEW_HOLIDAYS_ARRAY,
166
- )
167
-
168
- # Convert from numpy.datetime64 to pandas.Timestamp
169
- offsetted_old_dates = pd.to_datetime(offsetted_old_dates)
170
- offsetted_new_dates = pd.to_datetime(offsetted_new_dates)
179
+ # 1. VALIDAÇÃO ESTRUTURAL
180
+ if isinstance(dates_pd, pd.Series) and isinstance(offset_pd, pd.Series):
181
+ if not dates_pd.index.equals(offset_pd.index):
182
+ raise ValueError("Input dates have different indices!")
171
183
 
172
- # 'pd.to_datetime' does not necessarily return datetime64[ns] Series
173
- offsetted_old_dates = pd.Series(offsetted_old_dates).astype("datetime64[ns]")
174
- offsetted_new_dates = pd.Series(offsetted_new_dates).astype("datetime64[ns]")
175
-
176
- # Use old index to rejoin the results
177
- offsetted_old_dates.index = old_dates.index
178
- offsetted_new_dates.index = new_dates.index
184
+ is_scalar_input = not (
185
+ isinstance(dates_pd, pd.Series) or isinstance(offset_pd, pd.Series)
186
+ )
179
187
 
180
- offsetted_dates = pd.concat(
181
- [offsetted_old_dates, offsetted_new_dates, nat_dates]
182
- )
188
+ # 2. LÓGICA PRINCIPAL
183
189
 
184
- # Reorder the result to match the original input order
185
- return offsetted_dates.sort_index()
190
+ # --- CASO 1: AMBOS OS INPUTS SÃO ESCALARES
191
+ if is_scalar_input:
192
+ if pd.isna(dates_pd) or pd.isna(offset_pd):
193
+ return pd.NaT
186
194
 
187
- elif isinstance(dates_pd, pd.Timestamp):
188
- offsetted_dates_np = np.busday_offset(
195
+ offsetted_date_np = np.busday_offset(
189
196
  dc.to_numpy_date_type(dates_pd),
190
- offsets=offset,
197
+ offsets=offset_pd,
191
198
  roll=roll,
192
199
  holidays=br_holidays.get_holiday_array(dates_pd),
193
200
  )
194
- if isinstance(offsetted_dates_np, np.datetime64):
195
- return pd.Timestamp(offsetted_dates_np).as_unit("ns")
196
- else:
197
- return pd.Series(offsetted_dates_np).astype("datetime64[ns]")
198
201
 
199
- else:
200
- raise ValueError("Invalid input type for 'dates'.")
202
+ return pd.Timestamp(offsetted_date_np).as_unit("ns")
203
+
204
+ # --- CASO 2: PELO MENOS UM DOS INPUTS É UMA SÉRIE ---
205
+ if isinstance(dates_pd, pd.Series) or isinstance(offset_pd, pd.Series):
206
+ # Garante que ambas as variáveis sejam Series para alinhamento automático.
207
+ # O Pandas faz o "broadcast" do escalar para o tamanho da Series.
208
+ if not isinstance(dates_pd, pd.Series):
209
+ # dates escalar e offset Series -> Series de dates com o índice de offset.
210
+ dates_pd = pd.Series(dates_pd, index=offset_pd.index)
211
+ if not isinstance(offset_pd, pd.Series):
212
+ # offset escalar e dates Series -> Series de offset com o índice de dates.
213
+ offset_pd = pd.Series(offset_pd, index=dates_pd.index)
214
+
215
+ # Inicializa a série de resultados com o índice correto e tipo que suporta NaT.
216
+ result = pd.Series(index=dates_pd.index, dtype="datetime64[ns]")
217
+
218
+ # Divide the input in order to apply the correct holiday list
219
+ mask_not_null = dates_pd.notna() & offset_pd.notna()
220
+ mask_old_holidays = mask_not_null & (dates_pd < br_holidays.TRANSITION_DATE)
221
+ mask_new_holidays = mask_not_null & (dates_pd >= br_holidays.TRANSITION_DATE)
222
+
223
+ if mask_old_holidays.any():
224
+ np_offset_values = np.busday_offset(
225
+ dates=dc.to_numpy_date_type(dates_pd[mask_old_holidays]),
226
+ offsets=offset_pd[mask_old_holidays],
227
+ roll=roll,
228
+ holidays=OLD_HOLIDAYS_ARRAY,
229
+ )
230
+ pd_offset_values = pd.to_datetime(np_offset_values).astype("datetime64[ns]")
231
+ result.loc[mask_old_holidays] = pd_offset_values
232
+
233
+ if mask_new_holidays.any():
234
+ np_offset_values = np.busday_offset(
235
+ dates=dc.to_numpy_date_type(dates_pd[mask_new_holidays]),
236
+ offsets=offset_pd[mask_new_holidays],
237
+ roll=roll,
238
+ holidays=NEW_HOLIDAYS_ARRAY,
239
+ )
240
+ pd_offset_values = pd.to_datetime(np_offset_values).astype("datetime64[ns]")
241
+ result.loc[mask_new_holidays] = pd_offset_values
242
+
243
+ return result
244
+
245
+ # --- CASO 3: A ENTRADA 'dates' É UM ESCALAR E 'offset' É UMA SÉRIE ---
246
+ result = pd.Series(index=offset_pd.index, dtype="datetime64[ns]")
247
+ offset_dates_np = np.busday_offset(
248
+ dates=dc.to_numpy_date_type(dates_pd),
249
+ offsets=offset_pd,
250
+ roll=roll,
251
+ holidays=br_holidays.get_holiday_array(dates_pd),
252
+ )
253
+ # Convert from numpy.datetime64 to datetime64[ns] (pandas format)
254
+ offset_dates_pd = pd.to_datetime(offset_dates_np).astype("datetime64[ns]")
255
+ return pd.Series(
256
+ offset_dates_pd.values, index=offset_pd.index, dtype="datetime64[ns]"
257
+ )
201
258
 
202
259
 
203
260
  @overload
@@ -216,7 +273,7 @@ def count(start: DateScalar, end: DateArray) -> pd.Series: ...
216
273
  def count(start: DateArray, end: DateArray) -> pd.Series: ...
217
274
 
218
275
 
219
- def count(
276
+ def count( # noqa
220
277
  start: DateScalar | DateArray,
221
278
  end: DateScalar | DateArray,
222
279
  ) -> int | pd.Series:
@@ -227,8 +284,11 @@ def count(
227
284
  on the inputs. It accounts for specified holidays, effectively excluding them from
228
285
  the business day count.
229
286
 
230
- **Important Note:** The `start` date is used to determine which list of holidays
231
- applies to the calculation.
287
+ **Important Note:** Each date in the `start` input is evaluated individually to
288
+ determine which list of holidays (old or new) applies to the calculation. The
289
+ transition date is 2023-12-26, which means:
290
+ - Dates before 2023-12-26 use the old holiday list.
291
+ - Dates on or after 2023-12-26 use the new holiday list.
232
292
 
233
293
  Args:
234
294
  start (DateScalar | DateArray): The start date(s) for counting (inclusive).
@@ -278,64 +338,95 @@ def count(
278
338
  0 22
279
339
  1 19
280
340
  dtype: Int64
341
+
342
+ Null values are propagated
343
+
344
+ >>> bday.count(pd.NaT, "01-01-2024") # NaT start
345
+ <NA>
346
+
347
+ >>> bday.count("01-01-2024", pd.NaT) # NaT end
348
+ <NA>
349
+
350
+ >>> bday.count("01-01-2024", ["01-02-2024", pd.NaT]) # NaT in end array
351
+ 0 22
352
+ 1 <NA>
353
+ dtype: Int64
354
+
355
+ Original pandas index is preserved
356
+
357
+ >>> start_dates = pd.Series(
358
+ ... ["01-01-2024", "01-02-2024", "01-03-2024"],
359
+ ... index=["a", "b", "c"],
360
+ ... )
361
+ >>> bday.count(start_dates, "01-01-2025")
362
+ a 253
363
+ b 231
364
+ c 212
365
+ dtype: Int64
281
366
  """
367
+ # Padroniza as entradas para objetos do Pandas
282
368
  start_pd = dc.convert_input_dates(start)
283
369
  end_pd = dc.convert_input_dates(end)
284
370
 
285
- # If inputs are Series, check if they have different lengths
371
+ # 1. VALIDAÇÃO ESTRUTURAL
286
372
  if isinstance(start_pd, pd.Series) and isinstance(end_pd, pd.Series):
287
- if start_pd.size != end_pd.size:
288
- raise ValueError("Input Series must have the same length.")
373
+ if not start_pd.index.equals(end_pd.index):
374
+ raise ValueError("Input dates have different indices!")
289
375
 
290
- # Only start is used to determine the holiday list
291
- if isinstance(start_pd, pd.Series):
292
- # Divide the input in order to apply the correct holiday list
293
- start1 = start_pd[start_pd < br_holidays.TRANSITION_DATE]
294
- start2 = start_pd[start_pd >= br_holidays.TRANSITION_DATE]
295
- start3 = start_pd[start_pd.isna()]
296
-
297
- # If end is a Series, it must be divided as well
298
- if isinstance(end_pd, pd.Series):
299
- end1 = end_pd[start1.index]
300
- end2 = end_pd[start2.index]
301
- else:
302
- end1 = end_pd
303
- end2 = end_pd
304
-
305
- result1 = np.busday_count(
306
- begindates=dc.to_numpy_date_type(start1),
307
- enddates=dc.to_numpy_date_type(end1),
308
- holidays=OLD_HOLIDAYS_ARRAY,
309
- )
310
- result2 = np.busday_count(
311
- begindates=dc.to_numpy_date_type(start2),
312
- enddates=dc.to_numpy_date_type(end2),
313
- holidays=NEW_HOLIDAYS_ARRAY,
314
- )
315
-
316
- # Prepare results to be rejoined
317
- result1 = pd.Series(result1, dtype="Int64")
318
- result2 = pd.Series(result2, dtype="Int64")
319
- # Convert the third result from NaT to NA
320
- result3 = pd.Series(pd.NA, index=start3.index, dtype="Int64")
321
-
322
- # Old index is used to rejoin the results
323
- result1.index = start1.index
324
- result2.index = start2.index
376
+ # 2. LÓGICA PRINCIPAL
377
+ is_scalar_input = not (
378
+ isinstance(start_pd, pd.Series) or isinstance(end_pd, pd.Series)
379
+ )
325
380
 
326
- # Reorder the result to match the original input order
327
- result = pd.concat([result1, result2, result3]).sort_index()
381
+ # --- CASO 1: AMBAS AS ENTRADAS SÃO ESCALARES ---
382
+ if is_scalar_input:
383
+ if pd.isna(start_pd) or pd.isna(end_pd):
384
+ return pd.NA
328
385
 
329
- else: # Start is a single date
330
386
  result = np.busday_count(
331
387
  begindates=dc.to_numpy_date_type(start_pd),
332
388
  enddates=dc.to_numpy_date_type(end_pd),
333
389
  holidays=br_holidays.get_holiday_array(start_pd),
334
390
  )
335
- result = pd.Series(result, dtype="Int64")
391
+ return int(result)
392
+
393
+ # --- CASO 2: PELO MENOS UMA ENTRADA É UMA SÉRIE ---
394
+ # Garante que ambas as variáveis sejam Series para alinhamento automático.
395
+ # O Pandas faz o "broadcast" do escalar para o tamanho da Series.
396
+ if not isinstance(start_pd, pd.Series):
397
+ # start escalar e end Series: cria uma Series de start com o índice de end.
398
+ start_pd = pd.Series(start_pd, index=end_pd.index)
399
+ if not isinstance(end_pd, pd.Series):
400
+ # end escalar e start Series: cria uma Series de end com o índice de start.
401
+ end_pd = pd.Series(end_pd, index=start_pd.index)
402
+
403
+ # Inicializa a série de resultados com o índice correto e tipo que suporta NA.
404
+ # Nulos nas entradas (start_pd ou end_pd) resultarão em NA aqui.
405
+ result = pd.Series(index=start_pd.index, dtype="Int64")
406
+
407
+ # Cria máscaras para linhas não-nulas, divididas pelo calendário de feriados.
408
+ # A lógica de feriados depende APENAS da data de início.
409
+ not_null_mask = start_pd.notna() & end_pd.notna()
410
+ mask_old_holidays = not_null_mask & (start_pd < br_holidays.TRANSITION_DATE)
411
+ mask_new_holidays = not_null_mask & (start_pd >= br_holidays.TRANSITION_DATE)
412
+
413
+ # Calcula e atribui os resultados para o subconjunto "OLD"
414
+ if mask_old_holidays.any():
415
+ result.loc[mask_old_holidays] = np.busday_count(
416
+ begindates=dc.to_numpy_date_type(start_pd[mask_old_holidays]),
417
+ enddates=dc.to_numpy_date_type(end_pd[mask_old_holidays]),
418
+ holidays=OLD_HOLIDAYS_ARRAY,
419
+ )
420
+
421
+ # Calcula e atribui os resultados para o subconjunto "NEW"
422
+ if mask_new_holidays.any():
423
+ result.loc[mask_new_holidays] = np.busday_count(
424
+ begindates=dc.to_numpy_date_type(start_pd[mask_new_holidays]),
425
+ enddates=dc.to_numpy_date_type(end_pd[mask_new_holidays]),
426
+ holidays=NEW_HOLIDAYS_ARRAY,
427
+ )
336
428
 
337
- if result.size == 1:
338
- return int(result[0])
429
+ # As linhas onde not_null_mask era False já contêm o valor <NA> default.
339
430
  return result
340
431
 
341
432
 
@@ -32,6 +32,12 @@ def convert_input_dates(dates: DateArray) -> pd.Series: ...
32
32
  def convert_input_dates(
33
33
  dates: DateScalar | DateArray,
34
34
  ) -> pd.Timestamp | pd.Series:
35
+ # Capturar apenas escalares nulos: a verificação `is True` é crucial,
36
+ # pois `pd.isna()` retorna um array booleano para entradas de array,
37
+ # e um array nunca é idêntico ao objeto singleton `True`.
38
+ if pd.isna(dates) is True:
39
+ return pd.NaT
40
+
35
41
  match dates:
36
42
  case str():
37
43
  validate_date_format(dates)
@@ -41,6 +47,7 @@ def convert_input_dates(
41
47
  return pd.Timestamp(dates).normalize()
42
48
 
43
49
  case pd.Series() | np.ndarray() | list() | tuple():
50
+ # Preserve input values making a copy
44
51
  result = pd.Series(dates)
45
52
 
46
53
  if result.empty:
@@ -48,14 +55,14 @@ def convert_input_dates(
48
55
 
49
56
  if pd.api.types.is_string_dtype(result):
50
57
  # Check first element to validate date format
51
- validate_date_format(result[0])
58
+ validate_date_format(result.iloc[0])
52
59
 
53
60
  return pd.to_datetime(result, dayfirst=True).astype("datetime64[ns]")
54
61
 
55
62
  case pd.DatetimeIndex():
56
63
  return pd.Series(dates).astype("datetime64[ns]")
57
64
 
58
- case _: # unreachable code
65
+ case _:
59
66
  raise ValueError("Invalid input type for 'dates'.")
60
67
 
61
68
 
@@ -71,7 +78,9 @@ def to_numpy_date_type(
71
78
  Returns:
72
79
  np.datetime64 | np.ndarray: The input dates in a numpy datetime64[D] format.
73
80
  """
74
- if isinstance(dates, pd.Timestamp):
81
+ if pd.isna(dates) is True:
82
+ return np.datetime64("NaT")
83
+ elif isinstance(dates, pd.Timestamp) or dates is pd.NaT:
75
84
  return np.datetime64(dates, "D")
76
85
  elif isinstance(dates, pd.Series):
77
86
  return dates.to_numpy().astype("datetime64[D]")
@@ -58,7 +58,8 @@ class BrHolidays:
58
58
  if isinstance(dates, pd.Timestamp):
59
59
  earliest_date = dates
60
60
  else:
61
- earliest_date = dates.min()
61
+ # NaN values will be ignored for min date calculation
62
+ earliest_date = dates.min(skipna=True)
62
63
 
63
64
  if earliest_date < BrHolidays.TRANSITION_DATE:
64
65
  holidays = self.old_holidays
@@ -61,12 +61,12 @@ def benchmarks(include_history: bool = False) -> pd.DataFrame:
61
61
  >>> # Get historical benchmarks
62
62
  >>> df_history = tn.benchmarks(include_history=True)
63
63
  >>> df_history.head()
64
- Benchmark MaturityDate BondType StartDate EndDate
64
+ Benchmark MaturityDate BondType StartDate EndDate
65
65
  0 LFT 6 anos 2020-03-01 LFT 2014-01-01 2014-06-30
66
66
  1 LFT 6 anos 2020-09-01 LFT 2014-07-01 2014-12-31
67
67
  2 LFT 6 anos 2021-03-01 LFT 2015-01-01 2015-04-30
68
68
  3 LFT 6 anos 2021-09-01 LFT 2015-05-01 2015-12-31
69
- 4 LFT 1 ano 2022-03-01 LFT 2020-10-15 2021-03-31
69
+ 4 LFT 6 anos 2022-03-01 LFT 2016-01-01 2016-06-30
70
70
  """
71
71
  session = requests.Session()
72
72
  include_history_param_value = "S" if include_history else "N"
@@ -1 +0,0 @@
1
- __version__ = "0.35.7"
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