tea-bond 0.3.7__cp310-abi3-win_amd64.whl → 0.3.8__cp310-abi3-win_amd64.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.pyd CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tea-bond
3
- Version: 0.3.7
3
+ Version: 0.3.8
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -15,12 +15,12 @@ pybond/nb/nb_datetime.py,sha256=sg3Vmg2n2P_A186QgOGSOKBq-Tr72ht_Yw064yYrWXE,1067
15
15
  pybond/nb/nb_duration.py,sha256=bndVSHdG_yV0_vEWeAHd9Lq_UQ-8nkPnEC9cN2A2ca4,1709
16
16
  pybond/nb/nb_evaluators.py,sha256=GBsW3UuGf8iVUWr2DTISXzdYoGV5ITEOVFJivBNmWkc,15544
17
17
  pybond/nb/nb_time.py,sha256=5KNrWYcPwZUHoxvZKvh3qdhjB0DjRkxbUzONSv6OfhY,8928
18
- pybond/pd.py,sha256=SzHyXRRm7CbytyQ4FCwwM4FazkjXwJLX5y-MZniCbi8,11985
19
- pybond/pl.py,sha256=DzI2YcCqQICKeeQxjjxwcWVBJBiwBjLpuCg_KHHs45s,11680
18
+ pybond/pd.py,sha256=SSQdg4hzc9dLN53ICTI65UyAEkAvKnAt98u9EX09IqM,13575
19
+ pybond/pl.py,sha256=kB0rxuJjZnD8tm_c5Vmy6iGxmstaB51qzr65M9vR4sA,13706
20
20
  pybond/pnl.py,sha256=RXC5GnQckD4LmTjgPwCePB-3GxsQ4liu0TW6hSdudLE,2752
21
21
  pybond/polars_utils.py,sha256=020Dy-l6v_NF-y7LXcKyJmWGAgH59NAxWKvjfnJO1tY,2663
22
- pybond/pybond.pyd,sha256=bVJ8Nn6PY9mWno8-LZEaHrQF0ZV89KHa1nXEafc_Q4I,23516672
22
+ pybond/pybond.pyd,sha256=mvYdCwkfJP-GuHltpv2c-Sn8GepMZ5QvEU-PAeUCJd0,23558656
23
23
  pybond/pybond.pyi,sha256=qzOfqoysuUW7rnZYxEmGEJXK_UrCjMvQ29Y_mJOBN1Y,11621
24
- tea_bond-0.3.7.dist-info/METADATA,sha256=HqpNJ-MX00PeagAXvrgYwKgpGlNxMuYzeFYHjofp2U4,258
25
- tea_bond-0.3.7.dist-info/WHEEL,sha256=G8mq-RexZGAfbjW58CyHDPQ4EbuJINRXbIh22TbaFhw,95
26
- tea_bond-0.3.7.dist-info/RECORD,,
24
+ tea_bond-0.3.8.dist-info/METADATA,sha256=iFDD8dsw7ptVOSC_aR1cOepgVmUCQVxGKW423JB2BKU,258
25
+ tea_bond-0.3.8.dist-info/WHEEL,sha256=G8mq-RexZGAfbjW58CyHDPQ4EbuJINRXbIh22TbaFhw,95
26
+ tea_bond-0.3.8.dist-info/RECORD,,