add more strategies

This commit is contained in:
jackyu66git
2025-05-09 21:10:45 +08:00
parent 65a85823b9
commit 2440e896ea
17 changed files with 887 additions and 271 deletions
+28 -16
View File
@@ -42,17 +42,17 @@ class ChanLun_SOL_5(IStrategy):
}
# 5m and 15m
minimal_roi_1 = {
"0": 0.253,
"60": 0.159,
"120": 0.052,
"0": 0.1,
"60": 0.05,
"120": 0.02,
"240": 0
}
# 15m and 30m
minimal_roi_1 = {
"0": 0.253,
"120": 0.159,
"240": 0.052,
"360": 0
"0": 0.1,
"240": 0.05,
"480": 0.03,
"600": 0
}
minimal_roi_2 = {
"0": 0.10,
@@ -60,8 +60,8 @@ class ChanLun_SOL_5(IStrategy):
"2400": 0.025,
"3600": 0
}
can_short = False
lev = 5.0
can_short = True
lev = 1.0
stoploss = -0.3 * lev
trailing_stop = False
trailing_stop_positive = 0.025
@@ -471,12 +471,16 @@ class ChanLun_SOL_5(IStrategy):
#print(df['date'][index], df['macdhist'][index], df['macd'][index], df['macdsignal'][index], df['masub'][index])
# (1,1) = 1, (1,0) = 2, (-1,1) = 3, (-1, 0) = 4, (0,0) = 0
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
state_str = 'resample_{}_state'.format(self.get_ticker_indicator()*self.time5)
close_str = 'resample_{}_close'.format(self.get_ticker_indicator()*self.time5)
volume_str = 'resample_{}_volume'.format(self.get_ticker_indicator()*self.time5)
dataframe.loc[
(
#(dataframe['state'] == "-30")
(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "-10") |
(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)] == "99")
(dataframe[state_str].shift(self.time5) == "-10") &
(dataframe[close_str].pct_change().abs() < 0.05) &
(dataframe[close_str] > dataframe[close_str].shift(self.time5)) &
(dataframe[volume_str] > dataframe[volume_str].rolling(window=20).mean())
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "-10") &
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time30)] == "-10") &
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "-10")
@@ -486,7 +490,10 @@ class ChanLun_SOL_5(IStrategy):
dataframe.loc[
(
#(dataframe['state'] == "30")
(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "10")
(dataframe[state_str].shift(self.time5) == "10") &
(dataframe[close_str].pct_change().abs() < 0.05) &
(dataframe[close_str] < dataframe[close_str].shift(self.time5)) &
(dataframe[volume_str] > dataframe[volume_str].rolling(window=20).mean())
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "10") &
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time30)] == "10") &
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "10")
@@ -495,11 +502,14 @@ class ChanLun_SOL_5(IStrategy):
['enter_short', 'enter_tag']] = (1, 'short_signal_chan')
return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
state_str = 'resample_{}_state'.format(self.get_ticker_indicator()*self.time5)
close_str = 'resample_{}_close'.format(self.get_ticker_indicator()*self.time5)
dataframe.loc[
(
#(dataframe['state']== "30")
(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "10") |
(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)] == "-99")
(dataframe[state_str].shift(self.time5) == "10") |
(dataframe[close_str] < dataframe[close_str].rolling(window=20).min()) |
(dataframe[close_str] > dataframe[close_str].rolling(window=20).max()*1.05)
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time30)] == "10") &
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time60)] == "10")
),
@@ -507,7 +517,9 @@ class ChanLun_SOL_5(IStrategy):
dataframe.loc[
(
#(dataframe['state'] == "-30")
(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time5)].shift(self.time5) == "-10")
(dataframe[state_str].shift(self.time5) == "-10") |
(dataframe[close_str] > dataframe[close_str].rolling(window=20).max()) |
(dataframe[close_str] < dataframe[close_str].rolling(window=20).min()*0.95)
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time30)] == "-10") &
#(dataframe['resample_{}_state'.format(self.get_ticker_indicator()*self.time60)] == "-10")
),