添加ema52检查

This commit is contained in:
jackyu66git
2026-01-29 13:49:45 +08:00
parent b4032eb5c9
commit dd5ba33c0f
3 changed files with 33 additions and 2 deletions
+29 -1
View File
@@ -46,6 +46,9 @@ class ChanKLU:
self.near0_return = 0 self.near0_return = 0
self.ema52 = 0 self.ema52 = 0
self.ema24 = 0 self.ema24 = 0
self.ema104 = 0
self.ema156 = 0
self.ema208 = 0
self.macd_slop = 0 self.macd_slop = 0
self.signal_slop = 0 self.signal_slop = 0
self.hist_slop = 0 self.hist_slop = 0
@@ -110,13 +113,38 @@ class ChanKLU:
def set_idx(self, idx): def set_idx(self, idx):
self.idx = idx self.idx = idx
self.index = idx self.index = idx
def check_price_ema156(self):
if self.check_indicators():
if self.close > self.ema156:
return 1
elif self.close < self.ema156:
return -1
else:
return 0
else:
return 0
def ema_pattern(self):
if self.check_indicators():
if self.ema24 > self.ema52 and self.ema52 > self.ema104 and self.ema104 > self.ema156:
return 1
elif self.ema24 < self.ema52 and self.ema52 < self.ema104 and self.ema104 < self.ema156:
return -1
else:
return 0
def check_indicators(self):
if self.ema156 == 0:
return False
else:
return True
def set_indicators(self, item): def set_indicators(self, item):
self.macd = float(item['macd']) if 'macd' in item and item['macd'] else 0 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.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.macdhist = float(item['macdhist']) if 'macdhist' in item and item['macdhist'] else 0
self.ema52 = float(item['ema52']) if 'ema52' in item and item['ema52'] 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 self.ema24 = float(item['ema24']) if 'ema24' in item and item['ema24'] else 0
self.ema104 = float(item['ema104']) if 'ema104' in item and item['ema104'] else 0
self.ema156 = float(item['ema156']) if 'ema156' in item and item['ema156'] else 0
self.ema208 = float(item['ema208']) if 'ema208' in item and item['ema208'] else 0
self.rsi = float(item['rsi']) if 'rsi' in item and item['rsi'] 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.volume_ratio = float(item['volume_ratio']) if 'volume_ratio' in item and item['volume_ratio'] else 0
self.bb52upper = float(item['bb52upper']) if 'bb52upper' in item and item['bb52upper'] else 0 self.bb52upper = float(item['bb52upper']) if 'bb52upper' in item and item['bb52upper'] else 0
+1 -1
View File
@@ -23,7 +23,7 @@ class ChanLun():
self.time10m = 10 self.time10m = 10
self.time15m = 15 self.time15m = 15
self.time30m = 30 self.time30m = 30
self.time_m_intervals = [3, 5, 10, 15, 30] self.time_m_intervals = [2, 3, 5, 10, 15, 20, 30]
self.time_m_symbols = ['2m', '3m', '5m', '10m', '15m', '20m','30m'] self.time_m_symbols = ['2m', '3m', '5m', '10m', '15m', '20m','30m']
self.time2h = 2*60 self.time2h = 2*60
self.time4h = 4*60 self.time4h = 4*60
+3
View File
@@ -98,6 +98,9 @@ class TF_DF():
df['ema10'] = ta.EMA(df, timeperiod=10) df['ema10'] = ta.EMA(df, timeperiod=10)
df['ema24'] = ta.EMA(df, timeperiod=24) df['ema24'] = ta.EMA(df, timeperiod=24)
df['ema52'] = ta.EMA(df, timeperiod=52) df['ema52'] = ta.EMA(df, timeperiod=52)
df['ema104'] = ta.EMA(df, timeperiod=104)
df['ema156'] = ta.EMA(df, timeperiod=156)
df['ema208'] = ta.EMA(df, timeperiod=208)
df['rsi'] = ta.RSI(df, timeperiod=14) df['rsi'] = ta.RSI(df, timeperiod=14)
df['volume_ratio'] = self.cal_volume_ratio(df) df['volume_ratio'] = self.cal_volume_ratio(df)
return df return df