PYield 0.19.0__tar.gz → 0.19.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.
Files changed (33) hide show
  1. {pyield-0.19.0 → pyield-0.19.2}/PKG-INFO +1 -1
  2. pyield-0.19.2/pyield/__about__.py +1 -0
  3. {pyield-0.19.0 → pyield-0.19.2}/pyield/bday.py +82 -42
  4. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/intraday.py +3 -2
  5. {pyield-0.19.0 → pyield-0.19.2}/pyproject.toml +1 -1
  6. pyield-0.19.0/pyield/__about__.py +0 -1
  7. {pyield-0.19.0 → pyield-0.19.2}/LICENSE +0 -0
  8. {pyield-0.19.0 → pyield-0.19.2}/README.md +0 -0
  9. {pyield-0.19.0 → pyield-0.19.2}/pyield/__init__.py +0 -0
  10. {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/__init__.py +0 -0
  11. {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/bond_tools.py +0 -0
  12. {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/lft.py +0 -0
  13. {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/ltn.py +0 -0
  14. {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/ntnb.py +0 -0
  15. {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/ntnf.py +0 -0
  16. {pyield-0.19.0 → pyield-0.19.2}/pyield/calculators.py +0 -0
  17. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/__init__.py +0 -0
  18. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/anbima.py +0 -0
  19. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/data_cache.py +0 -0
  20. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/di.py +0 -0
  21. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/__init__.py +0 -0
  22. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/common.py +0 -0
  23. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/historical.py +0 -0
  24. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/xml.py +0 -0
  25. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/indicators.py +0 -0
  26. {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/projections.py +0 -0
  27. {pyield-0.19.0 → pyield-0.19.2}/pyield/date_converter.py +0 -0
  28. {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/__init__.py +0 -0
  29. {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/br_holidays_new.txt +0 -0
  30. {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/br_holidays_old.txt +0 -0
  31. {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/holidays_manager.py +0 -0
  32. {pyield-0.19.0 → pyield-0.19.2}/pyield/interpolator.py +0 -0
  33. {pyield-0.19.0 → pyield-0.19.2}/pyield/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PYield
3
- Version: 0.19.0
3
+ Version: 0.19.2
4
4
  Summary: A Python library for analysis of fixed income instruments in Brazil
5
5
  Keywords: fixed-income, brazil, finance, analysis, bonds
6
6
  Author-Email: Carlos Carvalho <cr.cj@outlook.com>
@@ -0,0 +1 @@
1
+ __version__ = "0.19.2"
@@ -105,10 +105,10 @@ def offset(
105
105
  types and holiday adjustments.
106
106
 
107
107
  Args:
108
- dates (SingleDateTypes | SeriesDateTypes):
108
+ dates (ScalarDateTypes | ArrayDateTypes):
109
109
  The date(s) to offset. Can be a single date in various formats (string,
110
110
  `datetime`, `Timestamp`, etc.) or a collection of dates (list, tuple,
111
- `Series`, etc.). If None, the current date is used.
111
+ `Series`, etc.).
112
112
  offset (int | Series | np.ndarray | list[int] | tuple[int], optional):
113
113
  The number of business days to offset the dates. Positive for
114
114
  future dates, negative for past dates. Zero will return the same date if
@@ -127,32 +127,57 @@ def offset(
127
127
  `Series` of offset dates.
128
128
 
129
129
  Examples:
130
- >>> date = "23-12-2023" # Saturday before Christmas
131
- >>> bday.offset(date, 0) # Offset to the next business day
132
- Timestamp('2023-12-26')
130
+ >>> from pandas import Timestamp
131
+ >>> from pyield import bday
133
132
 
134
- >>> date = "22-12-2023" # Friday before Christmas
135
- >>> bday.offset(date, 0)
136
- Timestamp('2023-12-22') # No offset because it's a business day
133
+ Offset to the next business day if not a bday (offset=0 and roll="forward")
137
134
 
138
- >>> bday.offset(date, 1)
139
- Timestamp('2023-12-26') # Offset to the next business day
135
+ # Offset Saturday before Christmas to the next b. day (Tuesday after Christmas)
136
+ >>> bday.offset("23-12-2023", 0)
137
+ Timestamp('2023-12-26 00:00:00')
140
138
 
141
- >>> bday.offset(date, -1)
142
- Timestamp('2023-12-21') # Offset to the previous business day
139
+ # Offset Friday before Christmas (no offset because it's a business day)
140
+ >>> bday.offset("22-12-2023", 0)
141
+ Timestamp('2023-12-22 00:00:00')
143
142
 
144
- >>> bday.offset(date, 0, roll="backward")
145
- Timestamp('2023-12-22') # No offset because it's a business day
143
+ Offset to the previous business day if not a bday (offset=0 and roll="backward")
146
144
 
145
+ # No offset because it's a business day
146
+ >>> bday.offset("22-12-2023", 0, roll="backward")
147
+ Timestamp('2023-12-22 00:00:00')
148
+
149
+ # Offset to the first business day before "23-12-2023"
147
150
  >>> bday.offset("23-12-2023", 0, roll="backward")
148
- Timestamp('2023-12-22') # Offset to the first business day before "23-12-2023"
151
+ Timestamp('2023-12-22 00:00:00')
152
+
153
+ Jump to the next business day (1 offset and roll="forward")
154
+
155
+ # Offset Friday to the next business day (Friday is jumped -> Monday)
156
+ >>> bday.offset("27-09-2024", 1)
157
+ Timestamp('2024-09-30 00:00:00')
158
+
159
+ # Offset Saturday to the next business day (Monday is jumped -> Tuesday)
160
+ >>> bday.offset("28-09-2024", 1)
161
+ Timestamp('2024-10-01 00:00:00')
162
+
163
+ Jump to the previous business day (-1 offset and roll="backward")
164
+
165
+ # Offset Friday to the previous business day (Friday is jumped -> Thursday)
166
+ >>> bday.offset("27-09-2024", -1, roll="backward")
167
+ Timestamp('2024-09-26 00:00:00')
168
+
169
+ # Offset Saturday to the previous business day (Friday is jumped -> Thursday)
170
+ >>> bday.offset("28-09-2024", -1, roll="backward")
171
+ Timestamp('2024-09-26 00:00:00')
172
+
173
+ List of dates and offsets
149
174
 
150
175
  >>> bday.offset(["19-09-2024", "20-09-2024"], 1) # a list of dates
151
176
  0 2024-09-20
152
177
  1 2024-09-23
153
178
  dtype: datetime64[ns]
154
179
 
155
- >>> bday.offset("19-09-2024", [1, 2] # a list of offsets
180
+ >>> bday.offset("19-09-2024", [1, 2]) # a list of offsets
156
181
  0 2024-09-20
157
182
  1 2024-09-23
158
183
  dtype: datetime64[ns]
@@ -231,11 +256,10 @@ def count(
231
256
  the business day count.
232
257
 
233
258
  Args:
234
- start (SingleDateTypes | SeriesDateTypes): The start date(s)
235
- for counting. If None, the current date is used.
236
- end (SingleDateTypes | SeriesDateTypes| None, optional): The end date(s) for
237
- counting, which are excluded from the count themselves. If None, the current
238
- date is used.
259
+ start (ScalarDateTypes | ArrayDateTypes): The start date(s)
260
+ for counting.
261
+ end (ScalarDateTypes | ArrayDateTypes): The end date(s) for counting, which
262
+ is excluded from the count themselves.
239
263
  holiday_list (Literal["old", "new", "infer"], optional):
240
264
  Specifies which set of holidays to consider in the count. 'old' or 'new'
241
265
  refer to predefined holiday lists, while 'infer' automatically selects the
@@ -257,10 +281,28 @@ def count(
257
281
  https://numpy.org/doc/stable/reference/generated/numpy.busday_count.html.
258
282
 
259
283
  Examples:
260
- >>> bday.count("2023-12-15", "2024-01-01")
284
+ >>> from pyield import bday
285
+
286
+ >>> bday.count("15-12-2023", "01-01-2024")
261
287
  10
262
- >>> bday.count(start="01-01-2023", end=["31-01-2023", "01-03-2023"])
263
- pd.Series([22, 40], dtype='int64')
288
+
289
+ # Total business days in January and February since the start of the year
290
+ >>> bday.count(start="01-01-2024", end=["01-02-2024", "01-03-2024"])
291
+ 0 22
292
+ 1 41
293
+ dtype: Int64
294
+
295
+ # The remaining business days in January and February to the end of the year
296
+ >>> bday.count(["01-01-2024", "01-02-2024"], "01-01-2025")
297
+ 0 253
298
+ 1 231
299
+ dtype: Int64
300
+
301
+ # The total business days in January and February of 2024
302
+ >>> bday.count(["01-01-2024", "01-02-2024"], ["01-02-2024", "01-03-2024"])
303
+ 0 22
304
+ 1 19
305
+ dtype: Int64
264
306
  """
265
307
  normalized_start = _convert_input_dates(start)
266
308
  normalized_end = _convert_input_dates(end)
@@ -294,10 +336,10 @@ def generate(
294
336
  inclusion options for start and end dates. It wraps `pandas.bdate_range`.
295
337
 
296
338
  Args:
297
- start (SingleDateTypes | None, optional):
339
+ start (ScalarDateTypes | None, optional):
298
340
  The start date for generating business days. If None, the current date is
299
341
  used. Defaults to None.
300
- end (SingleDateTypes | None, optional):
342
+ end (ScalarDateTypes | None, optional):
301
343
  The end date for generating business days. If None, the current date is
302
344
  used. Defaults to None.
303
345
  inclusive (Literal["both", "neither", "left", "right"], optional):
@@ -313,9 +355,15 @@ def generate(
313
355
  start and end dates, considering the specified holidays.
314
356
 
315
357
  Examples:
358
+ >>> from pyield import bday
316
359
  >>> bday.generate(start="22-12-2023", end="02-01-2024")
317
- pd.Series(['2023-12-22', '2023-12-26', '2023-12-27', '2023-12-28', '2023-12-29',
318
- '2024-01-02'], dtype='datetime64[ns]')
360
+ 0 2023-12-22
361
+ 1 2023-12-26
362
+ 2 2023-12-27
363
+ 3 2023-12-28
364
+ 4 2023-12-29
365
+ 5 2024-01-02
366
+ dtype: datetime64[ns]
319
367
 
320
368
  Note:
321
369
  For detailed information on parameters and error handling, refer to
@@ -347,29 +395,21 @@ def generate(
347
395
  return pd.Series(result_dti.values)
348
396
 
349
397
 
350
- def is_business_day(date: ScalarDateTypes | None = None) -> bool:
398
+ def is_business_day(date: ScalarDateTypes) -> bool:
351
399
  """
352
400
  Checks if the input date is a business day.
353
401
 
354
402
  Args:
355
- date (SingleDateTypes | None, optional): The date to check.
356
- If None, the current date is used. Defaults to None.
403
+ date (ScalarDateTypes): The date to check.
357
404
 
358
405
  Returns:
359
406
  bool: True if the input date is a business day, False otherwise.
360
407
 
361
408
  Examples:
409
+ >>> from pyield import bday
362
410
  >>> bday.is_business_day("25-12-2023") # Christmas
363
411
  False
364
- >>> bday.is_business_day() # Check if today is a business day
365
- True
366
412
  """
367
- if date:
368
- converted_date = _convert_input_dates(date)
369
- else:
370
- converted_date = pd.Timestamp.today().normalize()
371
-
372
- # Shift the date if it is not a business day
373
- adjusted_date = offset(converted_date, 0)
374
-
375
- return converted_date == adjusted_date
413
+ converted_date = _convert_input_dates(date)
414
+ shifted_date = offset(converted_date, 0) # Shift the date if it is not a bus. day
415
+ return converted_date == shifted_date
@@ -137,7 +137,7 @@ def _select_and_reorder_columns(df: pd.DataFrame) -> pd.DataFrame:
137
137
  Returns:
138
138
  pd.DataFrame: DataFrame with the columns selected and reordered.
139
139
  """
140
- columns = [
140
+ all_columns = [
141
141
  "TradeDate",
142
142
  "TradeTime",
143
143
  "TickerSymbol",
@@ -159,7 +159,8 @@ def _select_and_reorder_columns(df: pd.DataFrame) -> pd.DataFrame:
159
159
  "CurrentBidRate",
160
160
  "CurrentRate",
161
161
  ]
162
- return df[columns]
162
+ reordered_columns = [col for col in all_columns if col in df.columns]
163
+ return df[reordered_columns].copy()
163
164
 
164
165
 
165
166
  def fetch_intraday_df(future_code: str) -> pd.DataFrame:
@@ -32,7 +32,7 @@ dependencies = [
32
32
  "types-requests",
33
33
  ]
34
34
  dynamic = []
35
- version = "0.19.0"
35
+ version = "0.19.2"
36
36
 
37
37
  [project.license]
38
38
  file = "LICENSE"
@@ -1 +0,0 @@
1
- __version__ = "0.19.0"
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