tea-bond 0.3.5__cp310-abi3-manylinux_2_34_x86_64.whl → 0.3.7__cp310-abi3-manylinux_2_34_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/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
|
-
|
|
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
|
-
"
|
|
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
|
|
@@ -19,10 +19,10 @@ pybond/nb/nb_evaluators.py,sha256=fCYxcvW717_1E4qY9AV8R5Pv8eTvWqKk3Zj-zMU1kiw,14
|
|
|
19
19
|
pybond/nb/nb_time.py,sha256=LaqXfcNvmYD_lZ2u108MwrxCXoVCBX3cr3oOnPp3c1g,8649
|
|
20
20
|
pybond/pd.py,sha256=QmkADhIu0T7w1pbhYZB9dFDaPSO9aZ3kdFxktZf5Kro,11591
|
|
21
21
|
pybond/pl.py,sha256=fk5AGXym02gCkJIZmOpQRPf1qnqYUa1V_PawbeYm7WE,11285
|
|
22
|
-
pybond/pnl.py,sha256=
|
|
22
|
+
pybond/pnl.py,sha256=zDHDShaU5Cpp47JELb3u9xURSkm-1NUiZ5aFdwtwWf4,2644
|
|
23
23
|
pybond/polars_utils.py,sha256=A8D5T0x08oMCndWiQ5DPhLsuWp8s4OPgqvAnK36d8yY,2567
|
|
24
|
-
pybond/pybond.abi3.so,sha256=
|
|
24
|
+
pybond/pybond.abi3.so,sha256=KHJ4C4jgIee5yXior7MrP8gs9Y6_m7SUJtRGIH7VAT0,30556361
|
|
25
25
|
pybond/pybond.pyi,sha256=xME119HJzVNqNCJ9FapVaQg1amxbNHlbd-qfFyiuhL4,11230
|
|
26
|
-
tea_bond-0.3.
|
|
27
|
-
tea_bond-0.3.
|
|
28
|
-
tea_bond-0.3.
|
|
26
|
+
tea_bond-0.3.7.dist-info/METADATA,sha256=HqpNJ-MX00PeagAXvrgYwKgpGlNxMuYzeFYHjofp2U4,258
|
|
27
|
+
tea_bond-0.3.7.dist-info/WHEEL,sha256=QUqTgYGwY2EWSp2nZb9WOq7FyV4zGcx0XCx5wrEnnjI,107
|
|
28
|
+
tea_bond-0.3.7.dist-info/RECORD,,
|
|
File without changes
|