tea-bond 0.3.5__cp310-abi3-macosx_11_0_arm64.whl → 0.3.7__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/pnl.py CHANGED
@@ -9,6 +9,52 @@ if TYPE_CHECKING:
9
9
  from .polars_utils import parse_into_expr, register_plugin
10
10
 
11
11
 
12
+ class Fee:
13
+ """Represents a fee for a trade."""
14
+
15
+ def __init__(self, fee_str: str = ""):
16
+ self.str = fee_str
17
+
18
+ def __add__(self, other: Fee) -> Fee:
19
+ return Fee(self.str + "+" + other.str)
20
+
21
+ def __radd__(self, other: Fee) -> Fee:
22
+ return Fee(other.str + "+" + self.str)
23
+
24
+ @staticmethod
25
+ def trade(fee) -> TradeFee:
26
+ return TradeFee(fee)
27
+
28
+ @staticmethod
29
+ def qty(fee) -> QtyFee:
30
+ return QtyFee(fee)
31
+
32
+ @staticmethod
33
+ def percent(fee) -> PercentFee:
34
+ return PercentFee(fee)
35
+
36
+
37
+ class TradeFee(Fee):
38
+ """Represents a fixed fee for a trade."""
39
+
40
+ def __init__(self, fee: float):
41
+ self.str = f"Trade({fee})"
42
+
43
+
44
+ class QtyFee(Fee):
45
+ """Represents a fee based on the quantity of a trade."""
46
+
47
+ def __init__(self, fee: float):
48
+ self.str = f"Qty({fee})"
49
+
50
+
51
+ class PercentFee(Fee):
52
+ """Represents a fee based on a percentage of the trade amount."""
53
+
54
+ def __init__(self, fee: float):
55
+ self.str = f"Percent({fee})"
56
+
57
+
12
58
  def calc_bond_trade_pnl(
13
59
  settle_time: IntoExpr,
14
60
  qty: IntoExpr,
@@ -17,11 +63,13 @@ def calc_bond_trade_pnl(
17
63
  symbol: str = "",
18
64
  bond_info_path: str | None = None,
19
65
  multiplier: float = 1,
20
- c_rate: float = 0,
66
+ fee: str | Fee = "",
21
67
  borrowing_cost: float = 0,
22
68
  capital_rate: float = 0,
23
69
  begin_state=None,
24
70
  ) -> pl.Expr:
71
+ if isinstance(fee, Fee):
72
+ fee = fee.str
25
73
  settle_time = parse_into_expr(settle_time)
26
74
  qty = parse_into_expr(qty)
27
75
  clean_price = parse_into_expr(clean_price)
@@ -41,11 +89,12 @@ def calc_bond_trade_pnl(
41
89
  "unrealized_pnl": 0,
42
90
  "coupon_paid": 0,
43
91
  "amt": 0,
92
+ "fee": 0,
44
93
  }
45
94
  kwargs = {
46
95
  "symbol": symbol,
47
96
  "multiplier": multiplier,
48
- "c_rate": c_rate,
97
+ "fee": fee,
49
98
  "borrowing_cost": borrowing_cost,
50
99
  "capital_rate": capital_rate,
51
100
  "begin_state": begin_state,
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.5
3
+ Version: 0.3.7
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -17,10 +17,10 @@ pybond/nb/nb_evaluators.py,sha256=fCYxcvW717_1E4qY9AV8R5Pv8eTvWqKk3Zj-zMU1kiw,14
17
17
  pybond/nb/nb_time.py,sha256=LaqXfcNvmYD_lZ2u108MwrxCXoVCBX3cr3oOnPp3c1g,8649
18
18
  pybond/pd.py,sha256=QmkADhIu0T7w1pbhYZB9dFDaPSO9aZ3kdFxktZf5Kro,11591
19
19
  pybond/pl.py,sha256=fk5AGXym02gCkJIZmOpQRPf1qnqYUa1V_PawbeYm7WE,11285
20
- pybond/pnl.py,sha256=P3KXc-gz6_TA2QxDQR9NHJIJPCvLOGT_v4qN4gzdcRY,1568
20
+ pybond/pnl.py,sha256=zDHDShaU5Cpp47JELb3u9xURSkm-1NUiZ5aFdwtwWf4,2644
21
21
  pybond/polars_utils.py,sha256=A8D5T0x08oMCndWiQ5DPhLsuWp8s4OPgqvAnK36d8yY,2567
22
- pybond/pybond.abi3.so,sha256=ch4pcHS4wHLGYj7g3e60fjGMLnmixexdrVjvsH1XP78,23157328
22
+ pybond/pybond.abi3.so,sha256=4Q3wFYgsrwGZj7GijBDsVs7pAejDDwZLsHE8UMk-n-E,23173120
23
23
  pybond/pybond.pyi,sha256=xME119HJzVNqNCJ9FapVaQg1amxbNHlbd-qfFyiuhL4,11230
24
- tea_bond-0.3.5.dist-info/METADATA,sha256=GE9wr4wwVaMP86N1M8kOYuh6EwYO-2Y7cI-5FI2zxwI,258
25
- tea_bond-0.3.5.dist-info/WHEEL,sha256=Mdosfxua6Dx1zYgObRH97e3wyiELqBbLtoRJj4RUSQE,103
26
- tea_bond-0.3.5.dist-info/RECORD,,
24
+ tea_bond-0.3.7.dist-info/METADATA,sha256=HqpNJ-MX00PeagAXvrgYwKgpGlNxMuYzeFYHjofp2U4,258
25
+ tea_bond-0.3.7.dist-info/WHEEL,sha256=Mdosfxua6Dx1zYgObRH97e3wyiELqBbLtoRJj4RUSQE,103
26
+ tea_bond-0.3.7.dist-info/RECORD,,