From 3410b922ad7333d7b43400f7a2d00e63e248a1bc Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 28 May 2026 18:07:31 +0800 Subject: [PATCH] fix: include ZHUOYAO function in MyTT.py (missing from 1.4.1 release) The 1.4.1 commit added the indicator registry entry in indicator.py but forgot to include the actual ZHUOYAO() function definition in MyTT.py. Also includes lint cleanups (trailing semicolons, import formatting). Co-Authored-By: Claude Opus 4.7 --- src/easy_tdx/MyTT.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/easy_tdx/MyTT.py b/src/easy_tdx/MyTT.py index e105d3d..214cde4 100644 --- a/src/easy_tdx/MyTT.py +++ b/src/easy_tdx/MyTT.py @@ -17,7 +17,9 @@ #以下所有函数如无特别说明,输入参数S均为numpy序列或者列表list,N为整型int #应用层1级函数完美兼容通达信或同花顺,具体使用方法请参考通达信 -import numpy as np; import pandas as pd +import numpy as np +import pandas as pd + #------------------ 0级:核心工具函数 -------------------------------------------- def RD(N,D=3): return np.round(N,D) #四舍五入取3位小数 @@ -143,7 +145,7 @@ def LOWRANGE(S): # LOWRANGE(LOW)表示当前最低价是 #------------------ 2级:技术指标函数(全部通过0级,1级函数实现) ------------------------------ def MACD(CLOSE,SHORT=12,LONG=26,M=9): # EMA的关系,S取120日,和雪球小数点2位相同 - DIF = EMA(CLOSE,SHORT)-EMA(CLOSE,LONG); + DIF = EMA(CLOSE,SHORT)-EMA(CLOSE,LONG) DEA = EMA(DIF,M); MACD=(DIF-DEA)*2 return RD(DIF),RD(DEA),RD(MACD) @@ -191,7 +193,7 @@ def BIAS(CLOSE,L1=6, L2=12, L3=24): # BIAS乖离率 return RD(BIAS1), RD(BIAS2), RD(BIAS3) def BOLL(CLOSE,N=20, P=2): #BOLL指标,布林带 - MID = MA(CLOSE, N); + MID = MA(CLOSE, N) UPPER = MID + STD(CLOSE, N) * P LOWER = MID - STD(CLOSE, N) * P return RD(UPPER), RD(MID), RD(LOWER) @@ -243,7 +245,7 @@ def VR(CLOSE,VOL,M1=26): #VR容量比率 return SUM(IF(CLOSE > LC, VOL, 0), M1) / SUM(IF(CLOSE <= LC, VOL, 0), M1) * 100 def CR(CLOSE,HIGH,LOW,N=20): #CR价格动量指标 - MID=REF(HIGH+LOW+CLOSE,1)/3; + MID=REF(HIGH+LOW+CLOSE,1)/3 return SUM(MAX(0,HIGH-MID),N)/SUM(MAX(0,MID-LOW),N)*100 def EMV(HIGH,LOW,VOL,N=14,M=9): #简易波动指标 @@ -279,7 +281,7 @@ def ROC(CLOSE,N=12,M=6): #变动率指标 return ROC,MAROC def EXPMA(CLOSE,N1=12,N2=50): #EMA指数平均数指标 - return EMA(CLOSE,N1),EMA(CLOSE,N2); + return EMA(CLOSE,N1),EMA(CLOSE,N2) def OBV(CLOSE,VOL): #能量潮指标 return SUM(IF(CLOSE>REF(CLOSE,1),VOL,IF(CLOSEBB) & (AA>CC),AA+BB/2+DD/4,IF( (BB>CC) & (BB>AA),BB+AA/2+DD/4,CC+DD/4)); - X=(CLOSE-LC+(CLOSE-OPEN)/2+LC-REF(OPEN,1)); - SI=16*X/R*MAX(AA,BB); ASI=SUM(SI,M1); ASIT=MA(ASI,M2); + LC=REF(CLOSE,1); AA=ABS(HIGH-LC); BB=ABS(LOW-LC) + CC=ABS(HIGH-REF(LOW,1)); DD=ABS(LC-REF(OPEN,1)) + R=IF( (AA>BB) & (AA>CC),AA+BB/2+DD/4,IF( (BB>CC) & (BB>AA),BB+AA/2+DD/4,CC+DD/4)) + X=(CLOSE-LC+(CLOSE-OPEN)/2+LC-REF(OPEN,1)) + SI=16*X/R*MAX(AA,BB); ASI=SUM(SI,M1); ASIT=MA(ASI,M2) return ASI,ASIT def XSII(CLOSE, HIGH, LOW, N=102, M=7): #薛斯通道II @@ -305,4 +307,12 @@ def XSII(CLOSE, HIGH, LOW, N=102, M=7): #薛斯通道II return TD1, TD2, TD3, TD4 +def ZHUOYAO(CLOSE, N1=120, N2=60, N3=20, M=10): #捉妖大师指标:中长短线趋势共振 + LONG1 = (CLOSE / REF(CLOSE, N1) - 1) * 100 #120日涨跌幅 + LONG = EMA(LONG1, M) #长线 EXPMA(长线1,10) + MID = (CLOSE / REF(CLOSE, N2) - 1) * 100 #中线 60日涨跌幅 + SHORT = (CLOSE / REF(CLOSE, N3) - 1) * 100 #短线 20日涨跌幅 + TREND = EMA(MID, M) #趋势 EXPMA(中线,10) + return RD(LONG), RD(MID), RD(SHORT), RD(TREND) + #望大家能提交更多指标和函数 https://github.com/mpquant/MyTT