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.
- {pyield-0.19.0 → pyield-0.19.2}/PKG-INFO +1 -1
- pyield-0.19.2/pyield/__about__.py +1 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/bday.py +82 -42
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/intraday.py +3 -2
- {pyield-0.19.0 → pyield-0.19.2}/pyproject.toml +1 -1
- pyield-0.19.0/pyield/__about__.py +0 -1
- {pyield-0.19.0 → pyield-0.19.2}/LICENSE +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/README.md +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/__init__.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/__init__.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/bond_tools.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/lft.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/ltn.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/ntnb.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/bonds/ntnf.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/calculators.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/__init__.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/anbima.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/data_cache.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/di.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/__init__.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/common.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/historical.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/futures_data/xml.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/indicators.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/data_sources/projections.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/date_converter.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/__init__.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/br_holidays_new.txt +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/br_holidays_old.txt +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/holidays/holidays_manager.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/interpolator.py +0 -0
- {pyield-0.19.0 → pyield-0.19.2}/pyield/py.typed +0 -0
|
@@ -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 (
|
|
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.).
|
|
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
|
-
>>>
|
|
131
|
-
>>>
|
|
132
|
-
Timestamp('2023-12-26')
|
|
130
|
+
>>> from pandas import Timestamp
|
|
131
|
+
>>> from pyield import bday
|
|
133
132
|
|
|
134
|
-
|
|
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
|
-
|
|
139
|
-
|
|
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
|
-
|
|
142
|
-
|
|
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
|
-
|
|
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')
|
|
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 (
|
|
235
|
-
for counting.
|
|
236
|
-
end (
|
|
237
|
-
|
|
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
|
|
284
|
+
>>> from pyield import bday
|
|
285
|
+
|
|
286
|
+
>>> bday.count("15-12-2023", "01-01-2024")
|
|
261
287
|
10
|
|
262
|
-
|
|
263
|
-
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
318
|
-
|
|
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
|
|
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 (
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
@@ -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
|
|
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
|