No need to add nor change

This commit is contained in:
jackyu66git
2025-06-04 23:49:38 +08:00
parent 872eec8100
commit 8662b633ae
6 changed files with 721 additions and 1203 deletions
+34 -2
View File
@@ -1,4 +1,4 @@
from ChanEnum import Chan_FX_TYPE
from ChanEnum import Chan_FX_TYPE, Chan_KLU_TYPE
class ChanKLU:
def __init__(self, time, open, high, low, close, volume):
# _time, _close, _open, _high, _low, _extra_info={}
@@ -23,13 +23,45 @@ class ChanKLU:
self.rsi = 0
self.volume_ratio = 0
# === 新增:K线类型 ===
self.kline_type = None # K线类型:大阳线、大阴线、小阳线、小阴线
# === 新增:实时分型相关属性 ===
self.pre = None # 前一根K线
self.next = None # 后一根K线
self.fx_type = Chan_FX_TYPE.UNKNOWN # 分型类型:0=无分型,1=顶分型,-1=底分型
self.fx_strength = 0 # 分型强度:0-100
self.fx_confirmed = False # 分型是否确认
self.klu_type = None
self.cal_klu_min_max()
def cal_klu_min_max(self):
"""
计算K线类型:大阳线、大阴线、小阳线、小阴线
"""
if self.open <= 0: # 避免除零错误
self.kline_type = None
return
# 计算涨跌幅
price_change_ratio = (self.close - self.open) / self.open
strength = 0
# 判断K线类型
if price_change_ratio > 0.005: # 涨幅超过2%
self.kline_type = Chan_KLU_TYPE.BigBull
strength += abs(price_change_ratio)
elif price_change_ratio > 0: # 涨幅0-2%
self.kline_type = Chan_KLU_TYPE.SmallBull
strength += abs(price_change_ratio)
elif price_change_ratio < -0.005: # 跌幅超过2%
self.kline_type = Chan_KLU_TYPE.BigBear
strength += abs(price_change_ratio)
elif price_change_ratio < 0: # 跌幅0-2%
self.kline_type = Chan_KLU_TYPE.SmallBear
strength += abs(price_change_ratio)
else: # 开盘价等于收盘价
self.kline_type = Chan_KLU_TYPE.Cross
strength += abs(price_change_ratio)
return strength
def set_next(self, next):
self.next = next
self.update_realtime_analysis()