change something
This commit is contained in:
@@ -117,6 +117,8 @@ class ChanLun_SOL_15(IStrategy):
|
||||
#self.print_macd_div_list(dataframe)
|
||||
#self.print_resample_df(dataframe, 1, 50)
|
||||
#self.chan.get_bi_list(dataframe_30)
|
||||
#self.chan.plot_dual(dataframe_5, dataframe_30)
|
||||
self.chan.print_bi_klc(dataframe_5)
|
||||
#if self.last_time + timedelta(minutes=1) < datetime.now():
|
||||
#print(informative.iloc[-1])
|
||||
#self.print_klc(dataframe, "1m: ")
|
||||
@@ -279,10 +281,11 @@ class ChanLun_SOL_15(IStrategy):
|
||||
cn3 = 'resample_{}_state'.format(self.get_ticker_indicator()*time)
|
||||
logger.info(f'{df[cn1][index]}, {df[cn2][index]}, {df[cn3][index]}')
|
||||
def add_indicators(self, df):
|
||||
fast = 9
|
||||
slow = 24
|
||||
period = 14
|
||||
fast = 8
|
||||
slow = 16
|
||||
period = 6
|
||||
macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period)
|
||||
|
||||
df['macd'] = macd['macd']
|
||||
df['macdsignal'] = macd['macdsignal']
|
||||
df['macdhist'] = macd['macdhist']
|
||||
@@ -299,7 +302,17 @@ class ChanLun_SOL_15(IStrategy):
|
||||
df['ma30'] = df['ma30'].fillna(0)
|
||||
df['ma250'] = df['ma250'].fillna(0)
|
||||
df['rsi'] = df['rsi'].fillna(0)
|
||||
df['volume_ratio'] = self.cal_volume_ratio(df)
|
||||
return df
|
||||
def cal_volume_ratio(self, dataframe, window=10):
|
||||
df = dataframe.copy()
|
||||
# 计算过去N根K线的平均成交量
|
||||
df['avg_volume'] = df['volume'].rolling(window=window).mean()
|
||||
# 计算量比
|
||||
df['volume_ratio'] = df['volume'] / df['avg_volume']
|
||||
# 填充缺失值(前N根K线)
|
||||
df['volume_ratio'] = df['volume_ratio'].fillna(1.0)
|
||||
return df['volume_ratio']
|
||||
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
|
||||
dataframe.loc[
|
||||
|
||||
Reference in New Issue
Block a user