添加布林带显示

This commit is contained in:
jackyu66git
2025-07-07 01:15:49 +08:00
parent a56052e768
commit 9a68aa1913
4 changed files with 1080 additions and 118 deletions
+8 -2
View File
@@ -22,7 +22,10 @@ class ChanKLU:
self.ma250 = 0
self.rsi = 0
self.volume_ratio = 0
self.bbp120 = 0
self.bbp365 = 0
self.bb120 = 0
self.bb365 = 0
# === 新增:K线类型 ===
self.kline_type = None # K线类型:大阳线、大阴线、小阳线、小阴线
@@ -575,7 +578,10 @@ class ChanKLU:
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.update_realtime_analysis()
+2 -2
View File
@@ -106,10 +106,10 @@ class ChanLun():
klc_index += 1
if klc.klc_fx_type == Chan_KLC_FX.TOP3:
state_list.append("10")
print(klc.start_time, klc.end_time, klc.klc_fx_type)
#print(klc.start_time, klc.end_time, klc.klc_fx_type)
elif klc.klc_fx_type == Chan_KLC_FX.BOTTOM3:
state_list.append("-10")
print(klc.start_time, klc.end_time, klc.klc_fx_type)
#print(klc.start_time, klc.end_time, klc.klc_fx_type)
else:
state_list.append("00")
else:
+10 -5
View File
@@ -115,7 +115,7 @@ class ChanLun_BTC_30(IStrategy):
state_list = self.chan.get_klc_state_list(dataframe_15)
dataframe_15['state'] = state_list
dataframe_15['fx'] = state_list
state_list = self.chan.get_klc_state_list(dataframe_30)
#bi_list_1 = self.chan.get_bi_list(dataframe)
#bi_list_5 = self.chan.get_bi_list(dataframe_5)
#bi_list_15 = self.chan.get_bi_list(dataframe_15)
@@ -154,12 +154,17 @@ class ChanLun_BTC_30(IStrategy):
period = 6
macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period)
bb365 = ta.BBANDS(df, timeperiod=365, nbdevup=3.0, nbdevdn=3.0, matype=0)
bbp365 = ta.BBP(df, timeperiod=365)
bb120 = ta.BBANDS(df, timeperiod=120, nbdevup=3.0, nbdevdn=3.0, matype=0)
bbp120 = ta.BBP(df, timeperiod=120)
# 手动计算布林带 %B 指标 (BBP)
# %B = (Price - Lower Band) / (Upper Band - Lower Band)
bbp365 = (df['close'] - bb365['lowerband']) / (bb365['upperband'] - bb365['lowerband'])
bbp120 = (df['close'] - bb120['lowerband']) / (bb120['upperband'] - bb120['lowerband'])
df['bb365'] = bb365['upperband']
df['bbp365'] = bbp365
df['bb120'] = bb120['upperband']
df['bbp120'] = bbp120
df['macd'] = macd['macd']
df['macdsignal'] = macd['macdsignal']
df['macdhist'] = macd['macdhist']
@@ -279,8 +284,8 @@ class ChanLun_BTC_30(IStrategy):
ema10 = 'resample_{}_ema10'.format(self.get_ticker_indicator()*self.time30)
ema26 = 'resample_{}_ema26'.format(self.get_ticker_indicator()*self.time30)
ema52 = 'resample_{}_ema52'.format(self.get_ticker_indicator()*self.time30)
print(last_candle[ema5], last_candle[ema10], last_candle[ema26], last_candle[ema52])
print(last_candle['close'])
#print(last_candle[ema5], last_candle[ema10], last_candle[ema26], last_candle[ema52])
#print(last_candle['close'])
klc_list = self.chan.get_klc_list(resample_to_interval(dataframe, self.get_ticker_indicator() * self.time30))
bi_list = self.chan.cal_bi_list(klc_list)
if self.last_order is None:
+1060 -109
View File
File diff suppressed because it is too large Load Diff