tea-bond 0.3.7__cp310-abi3-macosx_11_0_arm64.whl → 0.3.8__cp310-abi3-macosx_11_0_arm64.whl
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.
Potentially problematic release.
This version of tea-bond might be problematic. Click here for more details.
pybond/pd.py
CHANGED
|
@@ -4,6 +4,7 @@ import pandas as pd
|
|
|
4
4
|
import polars as pl
|
|
5
5
|
|
|
6
6
|
from .pl import Bonds as PlBonds
|
|
7
|
+
from .pl import Futures as PlFutures
|
|
7
8
|
from .pl import TfEvaluators as PlTfEvaluators
|
|
8
9
|
|
|
9
10
|
|
|
@@ -51,7 +52,6 @@ class TfEvaluators:
|
|
|
51
52
|
}
|
|
52
53
|
)
|
|
53
54
|
self._evaluators = PlTfEvaluators(reinvest_rate=reinvest_rate)
|
|
54
|
-
# self.reinvest_rate = reinvest_rate
|
|
55
55
|
|
|
56
56
|
@property
|
|
57
57
|
def net_basis_spread(self):
|
|
@@ -258,6 +258,30 @@ class TfEvaluators:
|
|
|
258
258
|
"remain_cp_num"
|
|
259
259
|
].to_pandas()
|
|
260
260
|
|
|
261
|
+
@property
|
|
262
|
+
def deliver_date(self):
|
|
263
|
+
"""
|
|
264
|
+
Calculate delivery date (交割日).
|
|
265
|
+
|
|
266
|
+
Returns:
|
|
267
|
+
pd.Series: Delivery date values
|
|
268
|
+
"""
|
|
269
|
+
return self.pl_df.select(deliver_date=self._evaluators.deliver_date)[
|
|
270
|
+
"deliver_date"
|
|
271
|
+
].to_pandas()
|
|
272
|
+
|
|
273
|
+
@property
|
|
274
|
+
def last_trading_date(self):
|
|
275
|
+
"""
|
|
276
|
+
Calculate last trading date (最后交易日).
|
|
277
|
+
|
|
278
|
+
Returns:
|
|
279
|
+
pd.Series: Last trading date values
|
|
280
|
+
"""
|
|
281
|
+
return self.pl_df.select(last_trading_date=self._evaluators.last_trading_date)[
|
|
282
|
+
"last_trading_date"
|
|
283
|
+
].to_pandas()
|
|
284
|
+
|
|
261
285
|
|
|
262
286
|
class Bonds:
|
|
263
287
|
"""
|
|
@@ -355,6 +379,41 @@ class Bonds:
|
|
|
355
379
|
].to_pandas()
|
|
356
380
|
|
|
357
381
|
|
|
382
|
+
class Futures:
|
|
383
|
+
def __init__(self, future: str | pd.Series):
|
|
384
|
+
self.future = future
|
|
385
|
+
|
|
386
|
+
def deliver_date(self):
|
|
387
|
+
"""
|
|
388
|
+
Calculate delivery date (交割日).
|
|
389
|
+
|
|
390
|
+
Args:
|
|
391
|
+
date: Evaluation date(s)
|
|
392
|
+
|
|
393
|
+
Returns:
|
|
394
|
+
pd.Series: Delivery date values
|
|
395
|
+
"""
|
|
396
|
+
df = pl.DataFrame({"future": self.future})
|
|
397
|
+
return df.select(deliver_date=PlFutures("future").deliver_date())[
|
|
398
|
+
"deliver_date"
|
|
399
|
+
].to_pandas()
|
|
400
|
+
|
|
401
|
+
def last_trading_date(self):
|
|
402
|
+
"""
|
|
403
|
+
Calculate last trading date (最后交易日).
|
|
404
|
+
|
|
405
|
+
Args:
|
|
406
|
+
date: Evaluation date(s)
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
pd.Series: Last trading date values
|
|
410
|
+
"""
|
|
411
|
+
df = pl.DataFrame({"future": self.future})
|
|
412
|
+
return df.select(last_trading_date=PlFutures("future").last_trading_date())[
|
|
413
|
+
"last_trading_date"
|
|
414
|
+
].to_pandas()
|
|
415
|
+
|
|
416
|
+
|
|
358
417
|
def find_workday(date: str | pd.Series, market: str, offset: int = 0):
|
|
359
418
|
"""
|
|
360
419
|
Find the workday based on the given date and market calendar.
|
pybond/pl.py
CHANGED
|
@@ -38,6 +38,8 @@ class TfEvaluators:
|
|
|
38
38
|
"""
|
|
39
39
|
if future is None:
|
|
40
40
|
future = pl.lit(None).cast(str)
|
|
41
|
+
if bond is None:
|
|
42
|
+
bond = pl.lit(None).cast(str)
|
|
41
43
|
self.future = parse_into_expr(future)
|
|
42
44
|
self.bond = parse_into_expr(bond)
|
|
43
45
|
self.date = parse_into_expr(date)
|
|
@@ -239,6 +241,26 @@ class TfEvaluators:
|
|
|
239
241
|
"""
|
|
240
242
|
return self._call_plugin("evaluators_remain_cp_num")
|
|
241
243
|
|
|
244
|
+
@property
|
|
245
|
+
def deliver_date(self):
|
|
246
|
+
"""
|
|
247
|
+
Calculate delivery date (交割日).
|
|
248
|
+
|
|
249
|
+
Returns:
|
|
250
|
+
Polars expression for delivery date
|
|
251
|
+
"""
|
|
252
|
+
return self._call_plugin("evaluators_deliver_date")
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def last_trading_date(self):
|
|
256
|
+
"""
|
|
257
|
+
Calculate last trading date (最后交易日).
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
Polars expression for last trading date
|
|
261
|
+
"""
|
|
262
|
+
return self._call_plugin("evaluators_last_trading_date")
|
|
263
|
+
|
|
242
264
|
|
|
243
265
|
class Bonds:
|
|
244
266
|
"""
|
|
@@ -346,6 +368,61 @@ class Bonds:
|
|
|
346
368
|
# TODO(Teamon): 实现向量化根据净价反推ytm的函数
|
|
347
369
|
|
|
348
370
|
|
|
371
|
+
class Futures:
|
|
372
|
+
def __init__(self, future: IntoExpr = "symbol"):
|
|
373
|
+
"""
|
|
374
|
+
Initialize Futures with future identifier.
|
|
375
|
+
|
|
376
|
+
Args:
|
|
377
|
+
future: Future code column expression (default: "symbol")
|
|
378
|
+
"""
|
|
379
|
+
self.future = future
|
|
380
|
+
|
|
381
|
+
def _evaluator(self, date: IntoExpr | None = None) -> TfEvaluators:
|
|
382
|
+
"""
|
|
383
|
+
Create a TfEvaluators instance for future-only calculations.
|
|
384
|
+
|
|
385
|
+
Args:
|
|
386
|
+
date: Evaluation date column expression
|
|
387
|
+
|
|
388
|
+
Returns:
|
|
389
|
+
TfEvaluators: Configured evaluator instance
|
|
390
|
+
"""
|
|
391
|
+
return TfEvaluators(
|
|
392
|
+
future=self.future,
|
|
393
|
+
bond=None,
|
|
394
|
+
date=date,
|
|
395
|
+
bond_ytm=None,
|
|
396
|
+
future_price=None,
|
|
397
|
+
capital_rate=None,
|
|
398
|
+
reinvest_rate=None,
|
|
399
|
+
)
|
|
400
|
+
|
|
401
|
+
def deliver_date(self):
|
|
402
|
+
"""
|
|
403
|
+
Calculate delivery date (交割日).
|
|
404
|
+
|
|
405
|
+
Args:
|
|
406
|
+
date: Evaluation date column expression
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
Polars expression for delivery date
|
|
410
|
+
"""
|
|
411
|
+
return self._evaluator().deliver_date
|
|
412
|
+
|
|
413
|
+
def last_trading_date(self):
|
|
414
|
+
"""
|
|
415
|
+
Calculate last trading date (最后交易日).
|
|
416
|
+
|
|
417
|
+
Args:
|
|
418
|
+
date: Evaluation date column expression
|
|
419
|
+
|
|
420
|
+
Returns:
|
|
421
|
+
Polars expression for last trading date
|
|
422
|
+
"""
|
|
423
|
+
return self._evaluator().last_trading_date
|
|
424
|
+
|
|
425
|
+
|
|
349
426
|
def find_workday(date: IntoExpr, market: str | Ib | Sse, offset: int = 0):
|
|
350
427
|
"""
|
|
351
428
|
Find the workday based on the given date and market calendar.
|
pybond/pybond.abi3.so
CHANGED
|
Binary file
|
|
@@ -15,12 +15,12 @@ pybond/nb/nb_datetime.py,sha256=9fLD9rnfpHQ-cvX4H6PoFh_O3jgk475ZKrG8q_UxT34,1026
|
|
|
15
15
|
pybond/nb/nb_duration.py,sha256=FSX1y2JbHB_SJn-hcVe-7Zf2v0xpQKKZ1MfWBY7d7IQ,1639
|
|
16
16
|
pybond/nb/nb_evaluators.py,sha256=fCYxcvW717_1E4qY9AV8R5Pv8eTvWqKk3Zj-zMU1kiw,14987
|
|
17
17
|
pybond/nb/nb_time.py,sha256=LaqXfcNvmYD_lZ2u108MwrxCXoVCBX3cr3oOnPp3c1g,8649
|
|
18
|
-
pybond/pd.py,sha256=
|
|
19
|
-
pybond/pl.py,sha256=
|
|
18
|
+
pybond/pd.py,sha256=yDEurCNedu5Q821XFbqsHBAblv9hBDwc3Z3hwdt_lyo,13122
|
|
19
|
+
pybond/pl.py,sha256=7HTX2Eu6hDccy4WJpxej2_UjKQXk6KvWdISt54lqGSk,13234
|
|
20
20
|
pybond/pnl.py,sha256=zDHDShaU5Cpp47JELb3u9xURSkm-1NUiZ5aFdwtwWf4,2644
|
|
21
21
|
pybond/polars_utils.py,sha256=A8D5T0x08oMCndWiQ5DPhLsuWp8s4OPgqvAnK36d8yY,2567
|
|
22
|
-
pybond/pybond.abi3.so,sha256=
|
|
22
|
+
pybond/pybond.abi3.so,sha256=3yatecp5jQaIH5pjaRzn4IaQI25bE21Zr4g8kVig5xg,23191344
|
|
23
23
|
pybond/pybond.pyi,sha256=xME119HJzVNqNCJ9FapVaQg1amxbNHlbd-qfFyiuhL4,11230
|
|
24
|
-
tea_bond-0.3.
|
|
25
|
-
tea_bond-0.3.
|
|
26
|
-
tea_bond-0.3.
|
|
24
|
+
tea_bond-0.3.8.dist-info/METADATA,sha256=iFDD8dsw7ptVOSC_aR1cOepgVmUCQVxGKW423JB2BKU,258
|
|
25
|
+
tea_bond-0.3.8.dist-info/WHEEL,sha256=Mdosfxua6Dx1zYgObRH97e3wyiELqBbLtoRJj4RUSQE,103
|
|
26
|
+
tea_bond-0.3.8.dist-info/RECORD,,
|
|
File without changes
|