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
+9 -2
View File
@@ -30,8 +30,15 @@ class Chan_KLINE_DIR(Enum):
DOWN = auto()
COMBINE = auto()
INCLUDED = auto()
class Chan_KLU_TYPE(Enum):
BigBull = auto()
MiddleBull = auto()
SmallBull = auto()
BigBear = auto()
MiddleBear = auto()
SmallBear = auto()
Cross = auto()
class Chan_FX_TYPE(Enum):
BOTTOM = auto()
TOP = auto()
+663 -1174
View File
File diff suppressed because it is too large Load Diff
+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()
+6 -4
View File
@@ -697,10 +697,11 @@ class ChanLun():
else:
# A new top found
#last_top.set_fx(Chan_FX_TYPE.UNKNOWN)
#print(klc.start_time, last_top.start_time, klc.cal_fx_strength(), "一类卖点Sell 1")
last_top = klc
#print(klc.start_time, klc.fx, bi_list[-1].dir, "Last Top Change 1")
klc.set_klc_fx_type(Chan_KLC_FX.TOP1)
#print(klc.start_time, klc.fx, "一类卖点Sell 1")
#klc.set_fx(fx)
#klc.set_state("10")
bi_list[-1].add_klc(klc)
@@ -731,6 +732,7 @@ class ChanLun():
#klc.set_state("10")
#print(klc.start_time, klc.fx, "笔卖点Sell 1")
klc.set_klc_fx_type(Chan_KLC_FX.TOP2)
#print(klc.start_time, last_top.start_time, klc.fx, "二类卖点Sell 2")
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
else:
@@ -755,7 +757,7 @@ class ChanLun():
#klc.set_state('30')
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
#print(klc.start_time, last_bottom.start_time, "Normal TOP Found, Confirm down bi 4")
#print(klc.start_time, last_top.start_time, "Normal TOP Found, Confirm down bi 4")
#print(klc.start_time, klc.fx, "笔卖点Sell 2")
# last bottom = None
else:
@@ -1220,8 +1222,8 @@ class ChanLun():
klc.set_pre(last_klc)
last_klc.set_end_klu(last_klu)
klc.set_pre_fx()
else:
last_klc.add_klu(klu)
#else:
#last_klc.add_klu(klu)
else:
ddir = Chan_KLINE_DIR.UP
if klu.open > klu.close:
+1 -1
View File
@@ -323,7 +323,7 @@ def add_indicators(df):
def calculate_macd(df):
"""计算MACD指标"""
exp1 = df['close'].ewm(span=12, adjust=False).mean()
exp1 = df['close'].ewm(span=10, adjust=False).mean()
exp2 = df['close'].ewm(span=26, adjust=False).mean()
macd = exp1 - exp2
signal = macd.ewm(span=9, adjust=False).mean()
+8 -20
View File
@@ -3241,20 +3241,16 @@
console.error('主周期KLC分型时间或价格转换错误:', fx.time, fx.price);
return;
}
// 主周期 KLC
// 确定颜色和位置
const color = fx.is_bottom ? '#28a745' : '#dc3545'; // 底分型绿色,顶分型红色
// 根据强度等级调整颜色强度
let strengthColor = color;
if (fx.is_strong_fx) {
// 强分型使用更亮的颜色
strengthColor = fx.is_bottom ? '#00ff00' : '#ff0000';
}
// 构建显示文本,包含分型类型和强度信息
let displayText = `${fx.fx_strength.toFixed(1)}`;
if (fx.fx_strength < 50) { // 降低阈值让更多分型显示
if (fx.fx_strength < 1.4) { // 降低阈值让更多分型显示
displayText = fx.fx_strength >= 0.8 ? '•' : '' // 0.8以上显示点,0.8以下不显示文本
}
@@ -3265,7 +3261,7 @@
color: strengthColor,
shape: 'triangle',
text: displayText,
size: fx.is_strong_fx ? 1 : 0.6 // 调整尺寸,强分型稍大,普通分型更小
size: 2 // 调整尺寸,强分型稍大,普通分型更小
};
allMainFxMarkers.push(markerConfig);
@@ -3306,7 +3302,7 @@
return;
}
// KLU分型使用不同的颜色区分
// 主周期 KLU
const color = fx.is_bottom ? '#17a2b8' : '#fd7e14'; // 底分型用青色,顶分型用橙色
// 根据强度等级调整颜色强度
@@ -3399,12 +3395,8 @@
return;
}
// 小周期分型使用不同的颜色和样式,与主周期区分
let strengthColor = fx.is_bottom ? '#FF6B6B' : '#4ECDC4'; // 底分型用珊瑚红,顶分型用薄荷绿
if (fx.is_strong_fx) {
// 强分型使用更亮的颜色
strengthColor = fx.is_bottom ? '#FF0000' : '#00CED1';
}
// 小周期 KLC
let strengthColor = fx.is_bottom ? '#11116B' : '#222222'; // 底分型用珊瑚红,顶分型用薄荷绿
let displayText = `${fx.fx_strength.toFixed(1)}`;
// 构建小周期分型显示文本
if (fx.fx_strength < 1.5){ // 调整小周期阈值
@@ -3459,12 +3451,8 @@
return;
}
// 小周期KLU分型使用不同的颜色
// 小周期 KLU
let strengthColor = fx.is_bottom ? '#9A8C98' : '#F2CC8F'; // 底分型用灰紫色,顶分型用浅黄色
if (fx.is_strong_fx) {
// 强分型使用更亮的颜色
strengthColor = fx.is_bottom ? '#6C5B7B' : '#F9844A';
}
let displayText = `${fx.fx_strength.toFixed(1)}`;
// 构建小周期分型显示文本
if (fx.fx_strength < 1.4){ // 调整小周期阈值