polars-ta 0.4.5__py3-none-any.whl → 0.4.6__py3-none-any.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.
- polars_ta/_version.py +1 -1
- polars_ta/prefix/tdx.py +55 -0
- polars_ta/tdx/__init__.py +2 -0
- polars_ta/tdx/pattern_feature.py +236 -0
- polars_ta/tdx/reference.py +6 -0
- polars_ta/tdx/trend_feature.py +449 -0
- polars_ta/wq/arithmetic.py +450 -20
- polars_ta/wq/cross_sectional.py +10 -0
- polars_ta/wq/time_series.py +36 -3
- {polars_ta-0.4.5.dist-info → polars_ta-0.4.6.dist-info}/METADATA +2 -2
- {polars_ta-0.4.5.dist-info → polars_ta-0.4.6.dist-info}/RECORD +14 -12
- {polars_ta-0.4.5.dist-info → polars_ta-0.4.6.dist-info}/WHEEL +1 -1
- {polars_ta-0.4.5.dist-info → polars_ta-0.4.6.dist-info}/LICENSE +0 -0
- {polars_ta-0.4.5.dist-info → polars_ta-0.4.6.dist-info}/top_level.txt +0 -0
polars_ta/_version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.4.
|
1
|
+
__version__ = "0.4.6"
|
polars_ta/prefix/tdx.py
CHANGED
@@ -57,6 +57,31 @@ from polars_ta.tdx.over_bought_over_sold import MTM as ts_MTM # noqa
|
|
57
57
|
from polars_ta.tdx.over_bought_over_sold import RSI as ts_RSI # noqa
|
58
58
|
from polars_ta.tdx.over_bought_over_sold import RSV as ts_RSV # noqa
|
59
59
|
from polars_ta.tdx.pattern import ts_WINNER_COST # noqa
|
60
|
+
from polars_ta.tdx.pattern_feature import 仙人指路 as ts_仙人指路 # noqa
|
61
|
+
from polars_ta.tdx.pattern_feature import 低开大阳线 as ts_低开大阳线 # noqa
|
62
|
+
from polars_ta.tdx.pattern_feature import 低点搜寻 as ts_低点搜寻 # noqa
|
63
|
+
from polars_ta.tdx.pattern_feature import 出水芙蓉 as ts_出水芙蓉 # noqa
|
64
|
+
from polars_ta.tdx.pattern_feature import 出水芙蓉II as ts_出水芙蓉II # noqa
|
65
|
+
from polars_ta.tdx.pattern_feature import 剑 as ts_剑 # noqa
|
66
|
+
from polars_ta.tdx.pattern_feature import 单阳不破选股 as ts_单阳不破选股 # noqa
|
67
|
+
from polars_ta.tdx.pattern_feature import 四串阳 as ts_四串阳 # noqa
|
68
|
+
from polars_ta.tdx.pattern_feature import 四串阴 as ts_四串阴 # noqa
|
69
|
+
from polars_ta.tdx.pattern_feature import 回补跳空向上缺口 as ts_回补跳空向上缺口 # noqa
|
70
|
+
from polars_ta.tdx.pattern_feature import 均线多头排列 as ts_均线多头排列 # noqa
|
71
|
+
from polars_ta.tdx.pattern_feature import 均线空头排列 as ts_均线空头排列 # noqa
|
72
|
+
from polars_ta.tdx.pattern_feature import 天量法则 as ts_天量法则 # noqa
|
73
|
+
from polars_ta.tdx.pattern_feature import 强势整理 as ts_强势整理 # noqa
|
74
|
+
from polars_ta.tdx.pattern_feature import 揉搓线 as ts_揉搓线 # noqa
|
75
|
+
from polars_ta.tdx.pattern_feature import 早晨之星 as ts_早晨之星 # noqa
|
76
|
+
from polars_ta.tdx.pattern_feature import 旭日初升 as ts_旭日初升 # noqa
|
77
|
+
from polars_ta.tdx.pattern_feature import 突破 as ts_突破 # noqa
|
78
|
+
from polars_ta.tdx.pattern_feature import 老鸭头 as ts_老鸭头 # noqa
|
79
|
+
from polars_ta.tdx.pattern_feature import 蜻蜓点水 as ts_蜻蜓点水 # noqa
|
80
|
+
from polars_ta.tdx.pattern_feature import 跳空缺口选股 as ts_跳空缺口选股 # noqa
|
81
|
+
from polars_ta.tdx.pattern_feature import 近日创历史新低 as ts_近日创历史新低 # noqa
|
82
|
+
from polars_ta.tdx.pattern_feature import 近日创历史新高 as ts_近日创历史新高 # noqa
|
83
|
+
from polars_ta.tdx.pattern_feature import 高开大阴线 as ts_高开大阴线 # noqa
|
84
|
+
from polars_ta.tdx.pattern_feature import 鸳鸯底 as ts_鸳鸯底 # noqa
|
60
85
|
from polars_ta.tdx.pressure_support import BOLL as ts_BOLL # noqa
|
61
86
|
from polars_ta.tdx.pressure_support import BOLL_M as ts_BOLL_M # noqa
|
62
87
|
from polars_ta.tdx.reference import BARSLAST as ts_BARSLAST # noqa
|
@@ -77,6 +102,7 @@ from polars_ta.tdx.reference import HOD as ts_HOD # noqa
|
|
77
102
|
from polars_ta.tdx.reference import LLV as ts_LLV # noqa
|
78
103
|
from polars_ta.tdx.reference import LLVBARS as ts_LLVBARS # noqa
|
79
104
|
from polars_ta.tdx.reference import LOD as ts_LOD # noqa
|
105
|
+
from polars_ta.tdx.reference import LOWRANGE # noqa
|
80
106
|
from polars_ta.tdx.reference import MA as ts_MA # noqa
|
81
107
|
from polars_ta.tdx.reference import MAX # noqa
|
82
108
|
from polars_ta.tdx.reference import MEMA as ts_MEMA # noqa
|
@@ -110,5 +136,34 @@ from polars_ta.tdx.trend import MINUS_DI as ts_MINUS_DI # noqa
|
|
110
136
|
from polars_ta.tdx.trend import MINUS_DM as ts_MINUS_DM # noqa
|
111
137
|
from polars_ta.tdx.trend import PLUS_DI as ts_PLUS_DI # noqa
|
112
138
|
from polars_ta.tdx.trend import PLUS_DM as ts_PLUS_DM # noqa
|
139
|
+
from polars_ta.tdx.trend_feature import N天内出现以涨停收盘 as ts_N天内出现以涨停收盘 # noqa
|
140
|
+
from polars_ta.tdx.trend_feature import N天内出现涨停 as ts_N天内出现涨停 # noqa
|
141
|
+
from polars_ta.tdx.trend_feature import N天内有跳空向上缺口 as ts_N天内有跳空向上缺口 # noqa
|
142
|
+
from polars_ta.tdx.trend_feature import N天内经常涨停 as ts_N天内经常涨停 # noqa
|
143
|
+
from polars_ta.tdx.trend_feature import N日内上涨多于下跌 as ts_N日内上涨多于下跌 # noqa
|
144
|
+
from polars_ta.tdx.trend_feature import N日内下跌多于上涨 as ts_N日内下跌多于上涨 # noqa
|
145
|
+
from polars_ta.tdx.trend_feature import N日内创新低 as ts_N日内创新低 # noqa
|
146
|
+
from polars_ta.tdx.trend_feature import N日内创新高 as ts_N日内创新高 # noqa
|
147
|
+
from polars_ta.tdx.trend_feature import N日内阳线多于阴线 as ts_N日内阳线多于阴线 # noqa
|
148
|
+
from polars_ta.tdx.trend_feature import N日内阴线多于阳线 as ts_N日内阴线多于阳线 # noqa
|
149
|
+
from polars_ta.tdx.trend_feature import 下跌多日再放量上涨 as ts_下跌多日再放量上涨 # noqa
|
150
|
+
from polars_ta.tdx.trend_feature import 价量渐低后阳包阴 as ts_价量渐低后阳包阴 # noqa
|
151
|
+
from polars_ta.tdx.trend_feature import 单日放量 as ts_单日放量 # noqa
|
152
|
+
from polars_ta.tdx.trend_feature import 小步碎阳 as ts_小步碎阳 # noqa
|
153
|
+
from polars_ta.tdx.trend_feature import 平台整理 as ts_平台整理 # noqa
|
154
|
+
from polars_ta.tdx.trend_feature import 拉升后多日调整 as ts_拉升后多日调整 # noqa
|
155
|
+
from polars_ta.tdx.trend_feature import 持续放量 as ts_持续放量 # noqa
|
156
|
+
from polars_ta.tdx.trend_feature import 持续缩量 as ts_持续缩量 # noqa
|
157
|
+
from polars_ta.tdx.trend_feature import 放量上攻 as ts_放量上攻 # noqa
|
158
|
+
from polars_ta.tdx.trend_feature import 昨日底部十字星 as ts_昨日底部十字星 # noqa
|
159
|
+
from polars_ta.tdx.trend_feature import 温和放量上攻 as ts_温和放量上攻 # noqa
|
160
|
+
from polars_ta.tdx.trend_feature import 突然放量 as ts_突然放量 # noqa
|
161
|
+
from polars_ta.tdx.trend_feature import 突破长期盘整 as ts_突破长期盘整 # noqa
|
162
|
+
from polars_ta.tdx.trend_feature import 跳空高开或低开 as ts_跳空高开或低开 # noqa
|
163
|
+
from polars_ta.tdx.trend_feature import 连续N天收阳线 as ts_连续N天收阳线 # noqa
|
164
|
+
from polars_ta.tdx.trend_feature import 连续N天收阴线 as ts_连续N天收阴线 # noqa
|
165
|
+
from polars_ta.tdx.trend_feature import 间隔放量 as ts_间隔放量 # noqa
|
166
|
+
from polars_ta.tdx.trend_feature import 阶段放量 as ts_阶段放量 # noqa
|
167
|
+
from polars_ta.tdx.trend_feature import 阶段缩量 as ts_阶段缩量 # noqa
|
113
168
|
from polars_ta.tdx.volume import OBV as ts_OBV # noqa
|
114
169
|
from polars_ta.tdx.volume import VR as ts_VR # noqa
|
polars_ta/tdx/__init__.py
CHANGED
@@ -5,8 +5,10 @@ from polars_ta.tdx.logical import * # noqa
|
|
5
5
|
from polars_ta.tdx.moving_average import * # noqa
|
6
6
|
from polars_ta.tdx.over_bought_over_sold import * # noqa
|
7
7
|
from polars_ta.tdx.pattern import * # noqa
|
8
|
+
from polars_ta.tdx.pattern_feature import * # noqa
|
8
9
|
from polars_ta.tdx.pressure_support import * # noqa
|
9
10
|
from polars_ta.tdx.reference import * # noqa
|
10
11
|
from polars_ta.tdx.statistic import * # noqa
|
11
12
|
from polars_ta.tdx.trend import * # noqa
|
13
|
+
from polars_ta.tdx.trend_feature import * # noqa
|
12
14
|
from polars_ta.tdx.volume import * # noqa
|
@@ -0,0 +1,236 @@
|
|
1
|
+
from polars import Expr
|
2
|
+
|
3
|
+
from polars_ta.tdx.arithmetic import ABS, BETWEEN
|
4
|
+
from polars_ta.tdx.arithmetic import MAX
|
5
|
+
from polars_ta.tdx.arithmetic import MIN
|
6
|
+
from polars_ta.tdx.choice import IF
|
7
|
+
from polars_ta.tdx.logical import EVERY, CROSS, LAST, EXIST, NOT
|
8
|
+
from polars_ta.tdx.reference import COUNT, BARSLASTCOUNT, BARSLAST, EMA, FILTER, LOWRANGE
|
9
|
+
from polars_ta.tdx.reference import HHV
|
10
|
+
from polars_ta.tdx.reference import LLV
|
11
|
+
from polars_ta.tdx.reference import MA
|
12
|
+
from polars_ta.tdx.reference import REF
|
13
|
+
from polars_ta.wq.time_series import ts_cum_max, ts_cum_min
|
14
|
+
|
15
|
+
|
16
|
+
def 早晨之星(OPEN: Expr, CLOSE: Expr) -> Expr:
|
17
|
+
"""MSTAR 早晨之星"""
|
18
|
+
A1 = REF(CLOSE, 2) / REF(OPEN, 2) < 0.95
|
19
|
+
A2 = REF(OPEN, 1) < REF(CLOSE, 2)
|
20
|
+
A3 = ABS(REF(OPEN, 1) - REF(CLOSE, 1)) / REF(CLOSE, 1) < 0.03
|
21
|
+
A4 = CLOSE / OPEN > 1.05
|
22
|
+
A5 = CLOSE > REF(CLOSE, 2)
|
23
|
+
return A1 & A2 & A3 & A4 & A5
|
24
|
+
|
25
|
+
|
26
|
+
def 剑(OPEN: Expr, HIGH: Expr, LOW: Expr, CLOSE: Expr, VOL: Expr, CAPITAL: Expr) -> Expr:
|
27
|
+
"""SWORD 剑"""
|
28
|
+
AA = (VOL > REF(VOL, 1)) | (VOL > CAPITAL)
|
29
|
+
BB = (OPEN >= REF(HIGH, 1)) & (REF(HIGH, 1) > REF(HIGH, 2) * 1.06)
|
30
|
+
CC = CLOSE > (REF(CLOSE, 1) - REF(CLOSE, 1) * 0.01)
|
31
|
+
DD = (CLOSE < HIGH * 0.965) & (HIGH > OPEN * 1.05)
|
32
|
+
EE = (LOW < OPEN) & (LOW < CLOSE) & (HIGH > REF(CLOSE, 1) * 1.06)
|
33
|
+
FF = (HIGH - MAX(OPEN, CLOSE)) / 2 > (MIN(OPEN, CLOSE) - LOW)
|
34
|
+
GG = (ABS(OPEN - CLOSE)) / 2 < (MIN(OPEN, CLOSE) - LOW)
|
35
|
+
return AA & BB & CC & DD & EE & FF & GG
|
36
|
+
|
37
|
+
|
38
|
+
def 天量法则(OPEN: Expr, CLOSE: Expr) -> Expr:
|
39
|
+
"""TLFZ 天量法则"""
|
40
|
+
A1 = CLOSE > OPEN
|
41
|
+
A2 = HHV(CLOSE, 50) == CLOSE
|
42
|
+
# DYNAINFO(37) > 0.1 & &
|
43
|
+
# DYNAINFO(13) < 0.14;
|
44
|
+
raise
|
45
|
+
|
46
|
+
|
47
|
+
def 四串阴(OPEN: Expr, CLOSE: Expr) -> Expr:
|
48
|
+
"""GREEN4 四串阴"""
|
49
|
+
return EVERY(CLOSE < OPEN, 4)
|
50
|
+
|
51
|
+
|
52
|
+
def 四串阳(OPEN: Expr, CLOSE: Expr) -> Expr:
|
53
|
+
"""RED4 四串阳"""
|
54
|
+
return EVERY(CLOSE > OPEN, 4)
|
55
|
+
|
56
|
+
|
57
|
+
def 鸳鸯底(O: Expr, LOW: Expr, C: Expr, V: Expr, N: int = 50) -> Expr:
|
58
|
+
"""YYD 鸳鸯底"""
|
59
|
+
return (C > O) & (REF(C, 1) < REF(O, 1)) & (C > REF(O, 1)) & (V > REF(V, 1)) & EXIST(LOWRANGE(LOW) > N, 3)
|
60
|
+
|
61
|
+
|
62
|
+
def 出水芙蓉(OPEN: Expr, CLOSE: Expr, S: int = 20, M: int = 40, N: int = 60) -> Expr:
|
63
|
+
"""CSFR 出水芙蓉"""
|
64
|
+
AAA = CLOSE > OPEN
|
65
|
+
BBB = AAA & (CLOSE > MA(CLOSE, S)) & (CLOSE > MA(CLOSE, M)) & (CLOSE > MA(CLOSE, N))
|
66
|
+
CCC = BBB & (OPEN < MA(CLOSE, M)) & (OPEN < MA(CLOSE, N))
|
67
|
+
return CCC & (CLOSE - OPEN > 0.0618 * CLOSE)
|
68
|
+
|
69
|
+
|
70
|
+
def 出水芙蓉II(C: Expr, V: Expr, N: float = 0.05, M: float = 2.0) -> Expr:
|
71
|
+
"""CSFR2 出水芙蓉II"""
|
72
|
+
ZF = C / REF(C, 1)
|
73
|
+
FLTJ = V > REF(V, 1) * M
|
74
|
+
A1 = CROSS(C, MA(C, 5)) & CROSS(C, MA(C, 10)) & CROSS(C, MA(C, 20)) & CROSS(C, MA(C, 60))
|
75
|
+
return (ZF > 1 + N) & FLTJ & A1
|
76
|
+
|
77
|
+
|
78
|
+
def 近日创历史新高(HIGH: Expr, N: int = 3, M: int = 0) -> Expr:
|
79
|
+
"""NHIGH 近日创历史新高"""
|
80
|
+
if M == 0:
|
81
|
+
return HHV(HIGH, N) == ts_cum_max(HIGH)
|
82
|
+
else:
|
83
|
+
return HHV(HIGH, N) == HHV(HIGH, M)
|
84
|
+
|
85
|
+
|
86
|
+
def 近日创历史新低(LOW: Expr, N: int = 3, M: int = 0) -> Expr:
|
87
|
+
"""NLOW 近日创历史新低"""
|
88
|
+
if M == 0:
|
89
|
+
return LLV(LOW, N) == ts_cum_min(LOW)
|
90
|
+
else:
|
91
|
+
return LLV(LOW, N) == LLV(LOW, M)
|
92
|
+
|
93
|
+
|
94
|
+
def 旭日初升(CLOSE: Expr, VOL: Expr, N: int = 120) -> Expr:
|
95
|
+
"""XRDS 旭日初升"""
|
96
|
+
BUY1 = LAST(CLOSE < MA(CLOSE, N), 0, 5)
|
97
|
+
return (CLOSE > MA(CLOSE, N)) & (VOL > MA(VOL, 5) * 2) & BUY1
|
98
|
+
|
99
|
+
|
100
|
+
def 蜻蜓点水(CLOSE: Expr, N: int = 120) -> Expr:
|
101
|
+
"""QTDS 蜻蜓点水"""
|
102
|
+
BUY1 = LAST(CLOSE > MA(CLOSE, N), 0, 5)
|
103
|
+
BUY2 = EXIST(CLOSE < MA(CLOSE, N), 5)
|
104
|
+
return (CLOSE > MA(CLOSE, N)) & BUY1 & BUY2
|
105
|
+
|
106
|
+
|
107
|
+
def 均线多头排列(OPEN: Expr, CLOSE: Expr, N: int = 5, N1: int = 10, N2: int = 20, N3: int = 30) -> Expr:
|
108
|
+
"""DTPL 均线多头排列"""
|
109
|
+
A1 = MA(CLOSE, N)
|
110
|
+
A2 = MA(CLOSE, N1)
|
111
|
+
A3 = MA(CLOSE, N2)
|
112
|
+
A4 = MA(CLOSE, N3)
|
113
|
+
return (CLOSE > A1) & (A1 > A2) & (A2 > A3) & (A3 > A4) & (CLOSE > OPEN)
|
114
|
+
|
115
|
+
|
116
|
+
def 均线空头排列(OPEN: Expr, CLOSE: Expr, N: int = 5, N1: int = 10, N2: int = 20, N3: int = 30) -> Expr:
|
117
|
+
"""KTPL 均线空头排列"""
|
118
|
+
A1 = MA(CLOSE, N)
|
119
|
+
A2 = MA(CLOSE, N1)
|
120
|
+
A3 = MA(CLOSE, N2)
|
121
|
+
A4 = MA(CLOSE, N3)
|
122
|
+
return (CLOSE < A1) & (A1 < A2) & (A2 < A3) & (A3 < A4) & (CLOSE < OPEN)
|
123
|
+
|
124
|
+
|
125
|
+
def 强势整理(OPEN: Expr, CLOSE: Expr, N: int = 2, M: float = 0.05) -> Expr:
|
126
|
+
"""QSZL 强势整理"""
|
127
|
+
A1 = ABS(CLOSE - OPEN) / OPEN < 0.015
|
128
|
+
A2 = COUNT(A1, N) == N
|
129
|
+
A3 = (REF(OPEN, N) < REF(CLOSE, N)) & (REF(CLOSE, N) / REF(CLOSE, N + 1) > 1 + M)
|
130
|
+
return A2 & A3
|
131
|
+
|
132
|
+
|
133
|
+
def 高开大阴线(OPEN: Expr, CLOSE: Expr, N: float = 0.06, M: float = 0.04) -> Expr:
|
134
|
+
"""W103 高开大阴线"""
|
135
|
+
A1 = OPEN / REF(CLOSE, 1) >= 1 + M
|
136
|
+
A2 = CLOSE / OPEN <= 1 - N
|
137
|
+
return A1 & A2
|
138
|
+
|
139
|
+
|
140
|
+
def 低开大阳线(OPEN: Expr, CLOSE: Expr, N: float = 0.06, M: float = 0.04) -> Expr:
|
141
|
+
"""W104 低开大阳线"""
|
142
|
+
A1 = OPEN / REF(CLOSE, 1) <= 1 - M
|
143
|
+
A2 = CLOSE / OPEN >= 1 + N
|
144
|
+
return A1 & A2
|
145
|
+
|
146
|
+
|
147
|
+
def 跳空缺口选股(HIGH: Expr, LOW: Expr) -> Expr:
|
148
|
+
"""W105 跳空缺口选股"""
|
149
|
+
A1 = HIGH < (REF(LOW, 1) - 0.001)
|
150
|
+
A2 = LOW > (REF(HIGH, 1) + 0.001)
|
151
|
+
return A1 | A2
|
152
|
+
|
153
|
+
|
154
|
+
def 单阳不破选股(O: Expr, H: Expr, L: Expr, C: Expr, N1: int = 2, N2: int = 7) -> Expr:
|
155
|
+
"""W106 单阳不破选股
|
156
|
+
"""
|
157
|
+
A0 = ((C > O * 1.08) | (C > REF(C, 1) * 1.08)) & NOT(H == L) & NOT(H == C & H == O) # {大阳超8%,排除当天一字、T字板}
|
158
|
+
A1 = A0 & BARSLASTCOUNT(A0) == 1
|
159
|
+
A2 = BARSLAST(A1) # {距离大阳几根K}
|
160
|
+
ZCX = REF(O, A2) # {获取大阳位置的开盘价作为支撑线}
|
161
|
+
ZHX = REF(C, A2) # {获取大阳位置的收盘价作为选股最高区间}
|
162
|
+
ZD = LLV(L, A2) # {大阳之后的最低价}
|
163
|
+
ZH = HHV(H, A2) # {大阳之后的最高价}
|
164
|
+
A3 = BARSLASTCOUNT(ZD >= ZCX)
|
165
|
+
return (A3 <= N2) & (A3 > N1) & BETWEEN(C, ZCX, ZHX) & (ZH < ZHX) & (A2 > 0)
|
166
|
+
|
167
|
+
|
168
|
+
def 回补跳空向上缺口(O: Expr, H: Expr, L: Expr, C: Expr, N1: int = 2, N2: int = 7) -> Expr:
|
169
|
+
"""W107 回补跳空向上缺口"""
|
170
|
+
raise
|
171
|
+
|
172
|
+
|
173
|
+
def 揉搓线(O: Expr, H: Expr, L: Expr, C: Expr, V: Expr, N: int = 50) -> Expr:
|
174
|
+
"""RUBLINE 揉搓线
|
175
|
+
"""
|
176
|
+
A1 = (REF(H, 1) - MAX(REF(C, 1), REF(O, 1))) / (REF(H, 1) - REF(L, 1)) * 100 > N # {上影线占K线的N % 以上}
|
177
|
+
A2 = (MIN(O, C) - L) / (H - L) * 100 > N # {下影线占K线的N % 以上}
|
178
|
+
A3 = ABS(C - REF(C, 1)) / MIN(C, REF(C, 1)) * 100 < 2 # {下影K的跌幅不能超过2 %}
|
179
|
+
A4 = REF(C, 2) > REF(C, 3) # {揉搓形态前收涨}
|
180
|
+
A5 = V < REF(V, 1) # {缩量}
|
181
|
+
return A1 & A2 & A3 & A4 & A5
|
182
|
+
|
183
|
+
|
184
|
+
def 老鸭头(L: Expr, C: Expr, V: Expr) -> Expr:
|
185
|
+
"""OLDDUCK 老鸭头
|
186
|
+
"""
|
187
|
+
E1 = EMA(C, 13)
|
188
|
+
E2 = EMA(C, 55)
|
189
|
+
A1 = (COUNT(E1 < REF(E1, 1), 5) >= 3) & (E1 > REF(E1, 1))
|
190
|
+
A2 = (COUNT(E2 > REF(E2, 1), 13) >= 8) & (E2 < REF(E2, 1))
|
191
|
+
A3 = LLV((L / E2 - 1), 13) <= 0.1
|
192
|
+
A4 = COUNT(E1 > E2, 13) == 13
|
193
|
+
A5 = COUNT(C > E2, 5) == 5
|
194
|
+
A6 = CROSS(C, E1)
|
195
|
+
A7 = V > MA(V, 5)
|
196
|
+
YT = A1 & A2 & A3 & A4 & A5 & A6 & A7
|
197
|
+
LYT = FILTER(YT, 10)
|
198
|
+
# FXG:=FINANCE(42)>100;
|
199
|
+
# NTP:=DYNAINFO(8)>0;
|
200
|
+
# LYT AND FXG AND NTP;
|
201
|
+
return LYT
|
202
|
+
|
203
|
+
|
204
|
+
def 仙人指路(O: Expr, H: Expr, C: Expr) -> Expr:
|
205
|
+
"""WISEWAY 仙人指路
|
206
|
+
"""
|
207
|
+
TUPO = 0.5 * (C + H) > HHV(REF(C, 1), 60)
|
208
|
+
SSQS = (MA(C, 5) > MA(C, 60)) & (MA(C, 10) > MA(C, 60))
|
209
|
+
YINX = ((H - MAX(O, C)) / REF(C, 1) > 0.045) & (ABS(C - O) / REF(C, 1) < 0.035) & ((H - MAX(O, C)) > 2.0 * ABS(C - O))
|
210
|
+
QIANG1 = (REF(C, 1) / REF(C, 6) > 1.04) & (REF(C, 1) / REF(C, 6) < 1.18)
|
211
|
+
QIANG2 = (REF(C, 1) / REF(C, 6) > 1.04) & (REF(C, 1) / REF(C, 6) < 1.27)
|
212
|
+
QIANG = IF(True, QIANG2, QIANG1) # TODO 要改
|
213
|
+
QIANK = (REF((H - C), 1) / REF(C, 2) < 1.045) & (REF(C, 1) / REF(C, 2) > 0.97)
|
214
|
+
return TUPO & SSQS & YINX & QIANG & QIANK
|
215
|
+
|
216
|
+
|
217
|
+
def 低点搜寻(HIGH: Expr, LOW: Expr, CLOSE: Expr, N: int = 5) -> Expr:
|
218
|
+
"""SP 低点搜寻"""
|
219
|
+
W = MA((LLV(LOW, 45) - CLOSE) / (HHV(HIGH, 45) - LLV(LOW, 45)), N)
|
220
|
+
return CROSS(-0.05, W)
|
221
|
+
|
222
|
+
|
223
|
+
def 突破(C: Expr, N1: int = 5, N2: int = 10, N3: int = 30) -> Expr:
|
224
|
+
"""TP 突破"""
|
225
|
+
M1 = MA(C, N1) # {短期参数:5}
|
226
|
+
M2 = MA(C, N2) # {中期参数:10}
|
227
|
+
M3 = MA(C, N3) # {长期参数:30}
|
228
|
+
# {以下计算交叉点距今的天数}
|
229
|
+
D1 = BARSLAST(CROSS(M1, M2)) # {短上穿中}
|
230
|
+
D2 = BARSLAST(CROSS(M1, M3)) # {短上穿长}
|
231
|
+
D3 = BARSLAST(CROSS(M2, M3)) # {中上穿长}
|
232
|
+
T1 = CROSS(M2, M3) # {今天中线上穿长线}
|
233
|
+
T2 = (D1 >= D2) & (D2 >= D3) # {交叉按指定的先后出现}
|
234
|
+
T3 = COUNT(CROSS(M2, M1) | CROSS(M3, M2) | CROSS(M3, M1), D1) == 0 # {中间无夹杂其它交叉}
|
235
|
+
T4 = REF(M1 < M3 & M2 < M3, D1 + 1) # {短上穿中前一天短、中线在长线之下}
|
236
|
+
return T1 & T2 & T3 & T4 # {价托确定};
|
polars_ta/tdx/reference.py
CHANGED
@@ -128,6 +128,12 @@ def LOD(close: Expr, N: int = 30) -> Expr:
|
|
128
128
|
return close.map_batches(lambda a: roll_rank(a, N, pct=False, ascending=True))
|
129
129
|
|
130
130
|
|
131
|
+
def LOWRANGE(close: Expr) -> Expr:
|
132
|
+
"""rolling rank of each data in ascending order
|
133
|
+
LOD(X,N):求当前X数据是N周期内的第几个低值"""
|
134
|
+
raise
|
135
|
+
|
136
|
+
|
131
137
|
def MEMA(close: Expr, N: int = 30) -> Expr:
|
132
138
|
"""Exponential moving average given N
|
133
139
|
Y = X / N + last_Y * (N-1) / N
|