tea-bond 0.3.13__cp38-abi3-manylinux_2_28_x86_64.whl → 0.3.15__cp38-abi3-manylinux_2_28_x86_64.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/pl.py CHANGED
@@ -280,7 +280,15 @@ class TfEvaluators:
280
280
  Returns:
281
281
  Polars expression for bond remaining year
282
282
  """
283
- return self._call_plugin("evaluators_remain_year")
283
+ return self._call_plugin("bonds_remain_year")
284
+
285
+ @property
286
+ def carry_date(self):
287
+ return self._call_plugin("bonds_carry_date")
288
+
289
+ @property
290
+ def maturity_date(self):
291
+ return self._call_plugin("bonds_maturity_date")
284
292
 
285
293
 
286
294
  class Bonds:
@@ -329,6 +337,12 @@ class Bonds:
329
337
  """
330
338
  return self._evaluator(date=date).remain_year
331
339
 
340
+ def carry_date(self):
341
+ return self._evaluator().carry_date
342
+
343
+ def maturity_date(self):
344
+ return self._evaluator().maturity_date
345
+
332
346
  def accrued_interest(self, date: IntoExpr = "date"):
333
347
  """
334
348
  Calculate accrued interest for the bond (应计利息).
@@ -392,7 +406,27 @@ class Bonds:
392
406
  """
393
407
  return self._evaluator(date=date).remain_cp_num
394
408
 
395
- # TODO(Teamon): 实现向量化根据净价反推ytm的函数
409
+ def calc_ytm_with_price(
410
+ self,
411
+ date: IntoExpr = "date",
412
+ dirty_price: IntoExpr = "dirty_price",
413
+ clean_price: IntoExpr | None = None,
414
+ ):
415
+ bond = parse_into_expr(self.bond)
416
+ date = parse_into_expr(date)
417
+ if clean_price is None:
418
+ dirty_price = parse_into_expr(dirty_price)
419
+ else:
420
+ assert dirty_price == "dirty_price", (
421
+ "should not set dirty_price when clean_price is set"
422
+ )
423
+ clean_price = parse_into_expr(clean_price)
424
+ dirty_price = clean_price + self.accrued_interest(date)
425
+ return register_plugin(
426
+ args=[bond, date, dirty_price],
427
+ symbol="bonds_calc_ytm_with_price",
428
+ is_elementwise=False,
429
+ )
396
430
 
397
431
 
398
432
  class Futures:
pybond/pnl.py CHANGED
@@ -115,7 +115,7 @@ def trading_from_pos(
115
115
  pos: IntoExpr,
116
116
  open: IntoExpr,
117
117
  finish_price: IntoExpr | None = None,
118
- cash: float = 1e8,
118
+ cash: IntoExpr = 1e8,
119
119
  multiplier: float = 1,
120
120
  qty_tick: float = 1.0,
121
121
  *,
@@ -125,15 +125,16 @@ def trading_from_pos(
125
125
  pos = parse_into_expr(pos)
126
126
  open = parse_into_expr(open)
127
127
  finish_price = parse_into_expr(finish_price)
128
+ cash = parse_into_expr(cash)
128
129
  kwargs = {
129
- "cash": cash,
130
- "multiplier": multiplier,
131
- "qty_tick": qty_tick,
130
+ "cash": None,
131
+ "multiplier": float(multiplier),
132
+ "qty_tick": float(qty_tick),
132
133
  "stop_on_finish": stop_on_finish,
133
134
  "finish_price": None,
134
135
  }
135
136
  return register_plugin(
136
- args=[time, pos, open, finish_price],
137
+ args=[time, pos, open, finish_price, cash],
137
138
  kwargs=kwargs,
138
139
  symbol="trading_from_pos",
139
140
  is_elementwise=False,
pybond/pybond.abi3.so CHANGED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tea-bond
3
- Version: 0.3.13
3
+ Version: 0.3.15
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -18,11 +18,11 @@ pybond/nb/nb_duration.py,sha256=FSX1y2JbHB_SJn-hcVe-7Zf2v0xpQKKZ1MfWBY7d7IQ,1639
18
18
  pybond/nb/nb_evaluators.py,sha256=fCYxcvW717_1E4qY9AV8R5Pv8eTvWqKk3Zj-zMU1kiw,14987
19
19
  pybond/nb/nb_time.py,sha256=LaqXfcNvmYD_lZ2u108MwrxCXoVCBX3cr3oOnPp3c1g,8649
20
20
  pybond/pd.py,sha256=3m6rpBW5-E2mG967Fb_hF4FjGoSXUQz0kBev9X104f8,13760
21
- pybond/pl.py,sha256=YWUm-u6wpwEIU6cJOZW0NuC13gVu_rKd-JgQX0NeXGI,14000
22
- pybond/pnl.py,sha256=upJxtjJyD00eKKJsz7CR6ONXm6UeqCE3AIODZGDE2wQ,3465
21
+ pybond/pl.py,sha256=sS3fk8AFcWskKPBUFAsnmSQetMlxub2cY3RWiAOimMo,15051
22
+ pybond/pnl.py,sha256=fv-5LIcMhNJPgnzVb3z1rXkgdNtooCnppXLywfP7m1A,3521
23
23
  pybond/polars_utils.py,sha256=u14yoK9Qx4TC2oPq-zVk7d1XOLY8nGc1H8Nf9jt0R6c,2599
24
- pybond/pybond.abi3.so,sha256=ycu0J5DMRIIT1QbkgYcFZDeDEX6eVfRTHaaqV706zrk,30687713
24
+ pybond/pybond.abi3.so,sha256=VYbsre68mc1Cn1eGaZXwO1s5Dp-qpsTRo2MS1_5C9Mw,30728897
25
25
  pybond/pybond.pyi,sha256=xME119HJzVNqNCJ9FapVaQg1amxbNHlbd-qfFyiuhL4,11230
26
- tea_bond-0.3.13.dist-info/METADATA,sha256=oeiGcz6LjIS_hxzxSp2M_7D7N48y7Vt3mes1eOvRq6I,258
27
- tea_bond-0.3.13.dist-info/WHEEL,sha256=aOjTN5bAUkIqIK1JFnJz3vA_KyYjKKgPFflJ6PJ2YX0,106
28
- tea_bond-0.3.13.dist-info/RECORD,,
26
+ tea_bond-0.3.15.dist-info/METADATA,sha256=9cTi1yfiJF8hF_FGLOr8Vfc_ygYABorV5xsihSTnrec,258
27
+ tea_bond-0.3.15.dist-info/WHEEL,sha256=aOjTN5bAUkIqIK1JFnJz3vA_KyYjKKgPFflJ6PJ2YX0,106
28
+ tea_bond-0.3.15.dist-info/RECORD,,