新的策略,先开单,明天继续添加条件

This commit is contained in:
jackyu66git
2025-10-16 02:44:21 +08:00
parent eb3f394386
commit a1f8c6c605
6 changed files with 579 additions and 55 deletions
+5 -38
View File
@@ -15,23 +15,10 @@ class ChanKLU:
self.signal = 0
self.macdhist = 0
self.klc = None
self.ma5 = 0
self.ma10 = 0
self.ma30 = 0
self.ma50 = 0
self.ma200 = 0
self.ma250 = 0
self.rsi = 0
self.volume_ratio = 0
self.bbp120 = 0
self.bbp365 = 0
self.bb120 = 0
self.bb365 = 0
self.bbp302 = 0
self.bbup302 = 0
self.bblow302 = 0
self.bbup30 = 0
self.bblow30 = 0
self.bb52upper = 0
self.bb52lower = 0
# === 新增:K线类型 ===
self.kline_type = None # K线类型:大阳线、大阴线、小阳线、小阴线
@@ -107,33 +94,13 @@ class ChanKLU:
self.macd = float(item['macd']) if 'macd' in item and item['macd'] else 0
self.signal = float(item['macdsignal']) if 'macdsignal' in item and item['macdsignal'] else 0
self.macdhist = float(item['macdhist']) if 'macdhist' in item and item['macdhist'] else 0
self.ma5 = float(item['ma5']) if 'ma5' in item and item['ma5'] else 0
self.ma10 = float(item['ma10']) if 'ma10' in item and item['ma10'] else 0
self.ma30 = float(item['ma30']) if 'ma30' in item and item['ma30'] else 0
self.ema52 = float(item['ema52']) if 'ema52' in item and item['ema52'] else 0
self.ema24 = float(item['ema24']) if 'ema24' in item and item['ema24'] else 0
# 安全检查 ma250、ma50 和 ma200
self.ma250 = float(item['ma250']) if 'ma250' in item and item['ma250'] else 0
self.ma50 = float(item['ma50']) if 'ma50' in item and item['ma50'] else 0
self.ma200 = float(item['ma200']) if 'ma200' in item and item['ma200'] else 0
self.rsi = float(item['rsi']) if 'rsi' in item and item['rsi'] else 0
self.volume_ratio = float(item['volume_ratio']) if 'volume_ratio' in item and item['volume_ratio'] else 0
self.bbp120 = float(item['bbp120']) if 'bbp120' in item and item['bbp120'] else 0
self.bbp365 = float(item['bbp365']) if 'bbp365' in item and item['bbp365'] else 0
self.bb120 = float(item['bb120']) if 'bb120' in item and item['bb120'] else 0
self.bb365 = float(item['bb365']) if 'bb365' in item and item['bb365'] else 0
self.bbp30 = float(item['bbp30']) if 'bbp30' in item and item['bbp30'] else 0
self.bbup30 = float(item['bbup30']) if 'bbup30' in item and item['bbup30'] else 0
self.bblow30 = float(item['bblow30']) if 'bblow30' in item and item['bblow30'] else 0
self.bbp302 = float(item['bbp302']) if 'bbp302' in item and item['bbp302'] else 0
self.bbup302 = float(item['bbup302']) if 'bbup302' in item and item['bbup302'] else 0
self.bblow302 = float(item['bblow302']) if 'bblow302' in item and item['bblow302'] else 0
self.bbup120 = float(item['bbup120']) if 'bbup120' in item and item['bbup120'] else 0
self.bblow120 = float(item['bblow120']) if 'bblow120' in item and item['bblow120'] else 0
self.bbup365 = float(item['bbup365']) if 'bbup365' in item and item['bbup365'] else 0
self.bblow365 = float(item['bblow365']) if 'bblow365' in item and item['bblow365'] else 0
self.bb52upper = float(item['bb52upper']) if 'bb52upper' in item and item['bb52upper'] else 0
self.bb52lower = float(item['bb52lower']) if 'bb52lower' in item and item['bb52lower'] else 0
def cal_macd_state(self):
# 按定义精简实现:优先级 CROSS0 > 位置(HIGH/HE/RETURN_ZERO) > NEAR0 > UNKNOWN
# 首条或缺前一根