tea-bond 0.3.11__cp38-abi3-win_amd64.whl → 0.3.13__cp38-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/bond.py +4 -2
- pybond/download.py +0 -2
- pybond/pd.py +17 -1
- pybond/pl.py +19 -0
- pybond/pnl.py +30 -0
- pybond/polars_utils.py +3 -1
- pybond/pybond.pyd +0 -0
- {tea_bond-0.3.11.dist-info → tea_bond-0.3.13.dist-info}/METADATA +1 -1
- {tea_bond-0.3.11.dist-info → tea_bond-0.3.13.dist-info}/RECORD +10 -10
- {tea_bond-0.3.11.dist-info → tea_bond-0.3.13.dist-info}/WHEEL +1 -1
pybond/bond.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
from datetime import date
|
|
5
4
|
from importlib.util import find_spec
|
|
6
5
|
from pathlib import Path
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
from .pybond import Bond as _BondRS
|
|
9
9
|
from .pybond import Future, download_bond
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
from datetime import date
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
WIND_AVAILABLE = find_spec("WindPy") is not None
|
|
14
16
|
|
pybond/download.py
CHANGED
pybond/pd.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
4
5
|
import polars as pl
|
|
5
6
|
|
|
6
7
|
from .pl import Bonds as PlBonds
|
|
7
8
|
from .pl import Futures as PlFutures
|
|
8
9
|
from .pl import TfEvaluators as PlTfEvaluators
|
|
9
10
|
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
import pandas as pd
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class TfEvaluators:
|
|
12
16
|
"""
|
|
@@ -287,6 +291,12 @@ class TfEvaluators:
|
|
|
287
291
|
"last_trading_date"
|
|
288
292
|
].to_pandas()
|
|
289
293
|
|
|
294
|
+
@property
|
|
295
|
+
def remain_year(self):
|
|
296
|
+
return self.pl_df.select(remain_year=self._evaluators.remain_year)[
|
|
297
|
+
"remain_year"
|
|
298
|
+
].to_pandas()
|
|
299
|
+
|
|
290
300
|
|
|
291
301
|
class Bonds:
|
|
292
302
|
"""
|
|
@@ -383,6 +393,12 @@ class Bonds:
|
|
|
383
393
|
"remain_cp_num"
|
|
384
394
|
].to_pandas()
|
|
385
395
|
|
|
396
|
+
def remain_year(self, date: str | pd.Series):
|
|
397
|
+
df = pl.DataFrame({"bond": self.bond, "date": date})
|
|
398
|
+
return df.select(remain_year=PlBonds("bond").remain_year("date"))[
|
|
399
|
+
"remain_year"
|
|
400
|
+
].to_pandas()
|
|
401
|
+
|
|
386
402
|
|
|
387
403
|
class Futures:
|
|
388
404
|
def __init__(self, future: str | pd.Series):
|
pybond/pl.py
CHANGED
|
@@ -269,6 +269,19 @@ class TfEvaluators:
|
|
|
269
269
|
"""
|
|
270
270
|
return self._call_plugin("evaluators_last_trading_date")
|
|
271
271
|
|
|
272
|
+
@property
|
|
273
|
+
def remain_year(self):
|
|
274
|
+
"""
|
|
275
|
+
Calculate bond remaining year (债券剩余期限).
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
date: Evaluation date column expression
|
|
279
|
+
|
|
280
|
+
Returns:
|
|
281
|
+
Polars expression for bond remaining year
|
|
282
|
+
"""
|
|
283
|
+
return self._call_plugin("evaluators_remain_year")
|
|
284
|
+
|
|
272
285
|
|
|
273
286
|
class Bonds:
|
|
274
287
|
"""
|
|
@@ -310,6 +323,12 @@ class Bonds:
|
|
|
310
323
|
reinvest_rate=None,
|
|
311
324
|
)
|
|
312
325
|
|
|
326
|
+
def remain_year(self, date: IntoExpr = "date"):
|
|
327
|
+
"""
|
|
328
|
+
Calculate remain year for the bond (剩余期限).
|
|
329
|
+
"""
|
|
330
|
+
return self._evaluator(date=date).remain_year
|
|
331
|
+
|
|
313
332
|
def accrued_interest(self, date: IntoExpr = "date"):
|
|
314
333
|
"""
|
|
315
334
|
Calculate accrued interest for the bond (应计利息).
|
pybond/pnl.py
CHANGED
|
@@ -108,3 +108,33 @@ def calc_bond_trade_pnl(
|
|
|
108
108
|
symbol="calc_bond_trade_pnl",
|
|
109
109
|
is_elementwise=False,
|
|
110
110
|
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def trading_from_pos(
|
|
114
|
+
time: IntoExpr,
|
|
115
|
+
pos: IntoExpr,
|
|
116
|
+
open: IntoExpr,
|
|
117
|
+
finish_price: IntoExpr | None = None,
|
|
118
|
+
cash: float = 1e8,
|
|
119
|
+
multiplier: float = 1,
|
|
120
|
+
qty_tick: float = 1.0,
|
|
121
|
+
*,
|
|
122
|
+
stop_on_finish: bool = False,
|
|
123
|
+
) -> pl.Expr:
|
|
124
|
+
time = parse_into_expr(time)
|
|
125
|
+
pos = parse_into_expr(pos)
|
|
126
|
+
open = parse_into_expr(open)
|
|
127
|
+
finish_price = parse_into_expr(finish_price)
|
|
128
|
+
kwargs = {
|
|
129
|
+
"cash": cash,
|
|
130
|
+
"multiplier": multiplier,
|
|
131
|
+
"qty_tick": qty_tick,
|
|
132
|
+
"stop_on_finish": stop_on_finish,
|
|
133
|
+
"finish_price": None,
|
|
134
|
+
}
|
|
135
|
+
return register_plugin(
|
|
136
|
+
args=[time, pos, open, finish_price],
|
|
137
|
+
kwargs=kwargs,
|
|
138
|
+
symbol="trading_from_pos",
|
|
139
|
+
is_elementwise=False,
|
|
140
|
+
)
|
pybond/polars_utils.py
CHANGED
|
@@ -2,11 +2,13 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import TYPE_CHECKING, Any
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
6
|
|
|
7
7
|
import polars as pl
|
|
8
8
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
|
+
from collections.abc import Sequence
|
|
11
|
+
|
|
10
12
|
from polars.type_aliases import IntoExpr, PolarsDataType
|
|
11
13
|
|
|
12
14
|
|
pybond/pybond.pyd
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
pybond/__init__.py,sha256=ocuh95mkVrcU3cps2zC-kgK7VMV7BZIcOK-mXo7oYg0,563
|
|
2
|
-
pybond/bond.py,sha256=
|
|
3
|
-
pybond/download.py,sha256=
|
|
2
|
+
pybond/bond.py,sha256=2YBnASWqBtRZ-ydzpCnjVuzPy-RxYvI97CruJLJ992U,6772
|
|
3
|
+
pybond/download.py,sha256=oEConLut3tC0hDGhiEdZXH6dleAa_rT2hTLtwo-nQzU,4294
|
|
4
4
|
pybond/ffi/__init__.py,sha256=AKhddxYYqfOkujr9FGKo-FOPk3DDi42SOfk5mbc0zWE,98
|
|
5
5
|
pybond/ffi/bond.py,sha256=BQmhYw1-cEJeU2XOy3yVmivMV-F0KI7xOKHsHpe4N7k,1654
|
|
6
6
|
pybond/ffi/datetime.py,sha256=NKgyWegyqc8MmGk11L3nL6hsVmfO9ibU_C3i9V_TW38,2047
|
|
@@ -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=
|
|
19
|
-
pybond/pl.py,sha256=
|
|
20
|
-
pybond/pnl.py,sha256=
|
|
21
|
-
pybond/polars_utils.py,sha256=
|
|
22
|
-
pybond/pybond.pyd,sha256=
|
|
18
|
+
pybond/pd.py,sha256=ghqoO9-wB0f3yjpYf5BMbz0Mu8Z1BVTbngcf1G4_Y9Y,14234
|
|
19
|
+
pybond/pl.py,sha256=gmAkS84qRq2yx26aYQK_0alIIhKkHAKYmh5Q0XzzePA,14499
|
|
20
|
+
pybond/pnl.py,sha256=FSIN6YJ9P44nsJGgnpdsf7b5MS96ziGMmQAlPzG8lb4,3605
|
|
21
|
+
pybond/polars_utils.py,sha256=XJ7DXpBfMEm3DilAun7E8S_6ShqQxi--ZSFV8CyRCxA,2697
|
|
22
|
+
pybond/pybond.pyd,sha256=QAg0XNoG7L1BAKKr_GFbTN_NdPZCZfZhSgr3-TK6wJo,23655936
|
|
23
23
|
pybond/pybond.pyi,sha256=qzOfqoysuUW7rnZYxEmGEJXK_UrCjMvQ29Y_mJOBN1Y,11621
|
|
24
|
-
tea_bond-0.3.
|
|
25
|
-
tea_bond-0.3.
|
|
26
|
-
tea_bond-0.3.
|
|
24
|
+
tea_bond-0.3.13.dist-info/METADATA,sha256=oeiGcz6LjIS_hxzxSp2M_7D7N48y7Vt3mes1eOvRq6I,258
|
|
25
|
+
tea_bond-0.3.13.dist-info/WHEEL,sha256=CG8OzNtm0LMpJ2zhrjswlO8N-965OeMLklsQAG-nMvQ,94
|
|
26
|
+
tea_bond-0.3.13.dist-info/RECORD,,
|