change something

This commit is contained in:
jackyu66git
2025-04-27 18:37:50 +08:00
parent 88701608bd
commit fceb57d2b8
10 changed files with 285 additions and 162 deletions
+28 -5
View File
@@ -80,8 +80,8 @@ class ChanLun():
return Chan_FX_TYPE.UNKNOWN
def get_macd(self, df):
fast = 8
slow = 16
period = 6
slow = 15
period = 2
macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period)
df['macd'] = macd['macd']
df['macdsignal'] = macd['macdsignal']
@@ -212,6 +212,27 @@ class ChanLun():
klc_list = self.get_klc_list(dataframe)
bi_list = self.cal_bi_list(klc_list)
return klc_list
def print_bi_klc(self, dataframe):
klc_list = self.get_klc_list(dataframe)
bi_list = self.cal_bi_list(klc_list)
rsi_list = dataframe['rsi']
fx_list = []
for klc in klc_list:
if klc.klc_fx_type != Chan_KLC_FX.UNKNOWN:
if klc.bi.dir == Chan_BI_DIR.UP and klc.volume_ratio > 2:
print(klc.start_time, klc.end_time, klc.klc_fx_type, klc.rsi, klc.volume_ratio)
fx_list.append(klc)
elif klc.bi.dir == Chan_BI_DIR.DOWN and klc.volume_ratio > 2:
print(klc.start_time, klc.end_time, klc.klc_fx_type, klc.rsi, klc.volume_ratio)
fx_list.append(klc)
bi_start_index_list = []
for bi in bi_list:
bi_start_index_list.append(bi.start_klc.index)
if bi.end_klc:
bi.cal_macdhist()
bi.cal_macd_div()
print("Bi:", bi.start_time, bi.end_time, bi.dir, bi.macd_hist, bi.macd_div)
klc_index_count = 0
def get_seg_list(self, bi_list):
seg_list = []
up_bi_list = []
@@ -639,6 +660,7 @@ class ChanLun():
#print(klc.start_time, last_bi.start_klc.start_time, "New TOP Found reset last bi")
klc.set_state("10")
#print(klc.start_time, klc.fx, "笔卖点Sell 1")
klc.set_klc_fx_type(Chan_KLC_FX.TOP2)
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
else:
@@ -758,6 +780,7 @@ class ChanLun():
#print(klc.start_time, last_bi.start_klc.start_time, "New BOTTOM Found reset last bi")
#klc.set_state("-10")
#print(klc.start_time, klc.fx, "笔买点Buy 1")
klc.set_klc_fx_type(Chan_KLC_FX.BOTTOM2)
bi_list[-1].add_klc(klc)
klc.set_bi(bi_list[-1])
else:
@@ -1903,10 +1926,10 @@ class ChanLun():
bbox=dict(boxstyle="round,pad=0.2", fc=style['color'], alpha=0.5))
"""
# 绘制MACD(使用小周期数据)
exp1 = small_df['close'].ewm(span=8, adjust=False).mean()
exp2 = small_df['close'].ewm(span=16, adjust=False).mean()
exp1 = small_df['close'].ewm(span=12, adjust=False).mean()
exp2 = small_df['close'].ewm(span=26, adjust=False).mean()
macd = exp1 - exp2
signal = macd.ewm(span=6, adjust=False).mean()
signal = macd.ewm(span=9, adjust=False).mean()
histogram = macd - signal
ax3.bar(small_dates_num, histogram, width=0.0002, color=['red' if h > 0 else 'green' for h in histogram])