Zeus_8_3_2_B_4_2 test Sell
This commit is contained in:
@@ -252,29 +252,29 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
|
||||
indicators = {'sma5', 'sma12', 'sma24', 'sma60', 'mid_smooth_3', 'mid_smooth_5', 'mid_smooth_12', 'mid_smooth_24'}
|
||||
|
||||
mises = IntParameter(5, 50, default=10, space='buy', optimize=False, load=False)
|
||||
mises = IntParameter(1, 50, default=10, space='buy', optimize=True, load=True)
|
||||
|
||||
pct = DecimalParameter(0.005, 0.05, default=0.012, decimals=3, space='buy', optimize=False, load=False)
|
||||
pct_inc = DecimalParameter(0.0001, 0.003, default=0.005, decimals=4, space='buy', optimize=False, load=False)
|
||||
pct = DecimalParameter(0.005, 0.05, default=0.012, decimals=3, space='buy', optimize=True, load=True)
|
||||
pct_inc = DecimalParameter(0.0001, 0.003, default=0.005, decimals=4, space='buy', optimize=True, load=True)
|
||||
|
||||
indic_5m = CategoricalParameter(indicators, default="sma60", space='buy')
|
||||
indic_deriv1_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True)
|
||||
indic_deriv2_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True)
|
||||
# indic_deriv1_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True)
|
||||
# indic_deriv2_5m = DecimalParameter(-2, 2, default=0, decimals=2, space='buy', optimize=True, load=True)
|
||||
|
||||
# indic_1h = CategoricalParameter(indicators, default="sma60", space='buy')
|
||||
# indic_deriv1_1h = DecimalParameter(-5, 5, default=0, decimals=1, space='buy', optimize=True, load=True)
|
||||
# indic_deriv2_1h = DecimalParameter(-10, 10, default=0, decimals=1, space='buy', optimize=True, load=True)
|
||||
|
||||
indic_1d_p = CategoricalParameter(indicators, default="sma60", space='protection')
|
||||
indic_deriv1_1d_p_stop = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
indic_deriv2_1d_p_stop = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
indic_deriv1_1d_p_start = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
indic_deriv2_1d_p_start = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
# indic_1d_p = CategoricalParameter(indicators, default="sma60", space='protection')
|
||||
# indic_deriv1_1d_p_stop = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
# indic_deriv2_1d_p_stop = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
# indic_deriv1_1d_p_start = DecimalParameter(-2, 2, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
# indic_deriv2_1d_p_start = DecimalParameter(-4, 4, default=0, decimals=1, space='protection', optimize=True, load=True)
|
||||
|
||||
|
||||
indic_5m_sell = CategoricalParameter(indicators, default="sma60", space='sell')
|
||||
indic_deriv1_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True)
|
||||
indic_deriv2_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True)
|
||||
# indic_deriv1_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True)
|
||||
# indic_deriv2_5m_sell = DecimalParameter(-2, 2, default=0, decimals=2, space='sell', optimize=True, load=True)
|
||||
|
||||
# indic_deriv1_1h_sell = DecimalParameter(-5, 5, default=0, decimals=1, space='sell', optimize=True, load=True)
|
||||
# indic_deriv2_1h_sell = DecimalParameter(-10, 10, default=0, decimals=1, space='sell', optimize=True, load=True)
|
||||
@@ -515,26 +515,26 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
pair_name = self.getShortName(pair)
|
||||
# if (current_profit > expected_profit) and last_candle['can_sell']:
|
||||
# return 'Can_' + pair_name + '_' + str(count_of_buys)
|
||||
trend = last_candle['trend_class_1d']
|
||||
if (trend == "BR1" or trend == "BR2") and self.pairs[pair]['has_gain'] == 0: # and (last_candle[f"{indic_5m_sell}_deriv1"] <= indic_deriv1_5m_sell and last_candle[f"{indic_5m_sell}_deriv2"] <= indic_deriv2_5m_sell):
|
||||
|
||||
if (last_candle['max_rsi_12_1h'] > 75) and last_candle['trend_class_1h'] == 'BU1' and profit > max(5, expected_profit) and (last_candle['hapercent'] < 0):
|
||||
self.pairs[pair]['stop'] = True
|
||||
self.log_trade(
|
||||
last_candle=last_candle,
|
||||
date=current_time,
|
||||
action="🔴STOP",
|
||||
dispo=dispo,
|
||||
pair=pair,
|
||||
rate=last_candle['close'],
|
||||
trade_type='',
|
||||
profit=self.pairs[pair]['current_profit'],
|
||||
buys=self.pairs[pair]['count_of_buys'],
|
||||
stake=0
|
||||
)
|
||||
return "MAX_RSI"
|
||||
|
||||
return None
|
||||
# trend = last_candle['trend_class_1d']
|
||||
# if (trend == "BR1" or trend == "BR2") and self.pairs[pair]['has_gain'] == 0: # and (last_candle[f"{indic_5m_sell}_deriv1"] <= indic_deriv1_5m_sell and last_candle[f"{indic_5m_sell}_deriv2"] <= indic_deriv2_5m_sell):
|
||||
#
|
||||
# if (last_candle['max_rsi_12_1h'] > 75) and last_candle['trend_class_1h'] == 'BU1' and profit > max(5, expected_profit) and (last_candle['hapercent'] < 0):
|
||||
# self.pairs[pair]['stop'] = True
|
||||
# self.log_trade(
|
||||
# last_candle=last_candle,
|
||||
# date=current_time,
|
||||
# action="🔴STOP",
|
||||
# dispo=dispo,
|
||||
# pair=pair,
|
||||
# rate=last_candle['close'],
|
||||
# trade_type='',
|
||||
# profit=self.pairs[pair]['current_profit'],
|
||||
# buys=self.pairs[pair]['count_of_buys'],
|
||||
# stake=0
|
||||
# )
|
||||
# return "MAX_RSI"
|
||||
#
|
||||
# return None
|
||||
|
||||
# if (trend == "BR1" or trend == "BR2") and last_candle[f"{self.indic_5m_sell.value}_deriv1"] <= self.indic_deriv1_5m_sell.value \
|
||||
# and last_candle[f"{self.indic_5m_sell.value}_deriv2"] <= self.indic_deriv2_5m_sell.value:
|
||||
@@ -957,6 +957,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
|
||||
dataframe["percent"] = (dataframe["close"] - dataframe["open"]) / dataframe["open"]
|
||||
dataframe["percent3"] = (dataframe["close"] - dataframe["open"].shift(3)) / dataframe["open"].shift(3)
|
||||
dataframe["percent12"] = (dataframe["close"] - dataframe["open"].shift(12)) / dataframe["open"].shift(12)
|
||||
dataframe["percent24"] = (dataframe["close"] - dataframe["open"].shift(24)) / dataframe["open"].shift(24)
|
||||
|
||||
if self.dp.runmode.value in ('backtest'):
|
||||
dataframe['futur_percent'] = 100 * (dataframe['close'].shift(-1) - dataframe['close']) / dataframe['close']
|
||||
@@ -1229,11 +1231,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
|
||||
dataframe[tendency_col] = dataframe.apply(tag_by_derivatives, axis=1)
|
||||
|
||||
if timeframe == '1h' and verbose and self.dp.runmode.value in ('backtest'):
|
||||
print("##################")
|
||||
print(f"# STAT {timeframe} {name}{suffixe}")
|
||||
print("##################")
|
||||
self.calculateProbabilite2Index(dataframe, futur_cols=['futur_percent'], indic_1=f"{name}{suffixe}_deriv1", indic_2=f"{name}{suffixe}_deriv2")
|
||||
# if timeframe == '1h' and verbose and self.dp.runmode.value in ('backtest'):
|
||||
# print("##################")
|
||||
# print(f"# STAT {timeframe} {name}{suffixe}")
|
||||
# print("##################")
|
||||
# self.calculateProbabilite2Index(dataframe, futur_cols=['futur_percent'], indic_1=f"{name}{suffixe}_deriv1", indic_2=f"{name}{suffixe}_deriv2")
|
||||
|
||||
return dataframe
|
||||
|
||||
@@ -1263,29 +1265,31 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value)
|
||||
# ), ['enter_long', 'enter_tag']] = (1, 'smth')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['sma24_deriv2'].shift(1) < 0)
|
||||
& (dataframe['sma24_deriv2'] > 0)
|
||||
& ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d']))
|
||||
& (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value)
|
||||
& (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value)
|
||||
# & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value)
|
||||
# & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value)
|
||||
), ['enter_long', 'enter_tag']] = (1, 'invert')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['sma24_deriv1'] > 0)
|
||||
& (dataframe['sma60_deriv1'].shift(1) < 0)
|
||||
& (dataframe['sma60_deriv1'] > 0)
|
||||
& ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d']))
|
||||
& (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value)
|
||||
& (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value)
|
||||
# & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value)
|
||||
# & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value)
|
||||
), ['enter_long', 'enter_tag']] = (1, 'raise')
|
||||
|
||||
# dataframe.loc[
|
||||
# (
|
||||
# (dataframe['sma24_deriv2'].shift(1) < 0)
|
||||
# & (dataframe['sma24_deriv2'] > 0)
|
||||
# & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d']))
|
||||
# & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value)
|
||||
# & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value)
|
||||
# # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value)
|
||||
# # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value)
|
||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
||||
# ), ['enter_long', 'enter_tag']] = (1, 'invert')
|
||||
#
|
||||
# dataframe.loc[
|
||||
# (
|
||||
# (dataframe['sma24_deriv1'] > 0)
|
||||
# & (dataframe['sma60_deriv1'].shift(1) < 0)
|
||||
# & (dataframe['sma60_deriv1'] > 0)
|
||||
# & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d']))
|
||||
# & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value)
|
||||
# & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value)
|
||||
# # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value)
|
||||
# # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value)
|
||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
||||
# ), ['enter_long', 'enter_tag']] = (1, 'raise')
|
||||
#
|
||||
# dataframe.loc[
|
||||
# (
|
||||
# (dataframe['sma60_deriv1'].shift(1) < 0)
|
||||
@@ -1295,18 +1299,32 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value)
|
||||
# # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value)
|
||||
# # & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value)
|
||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
||||
# ), ['enter_long', 'enter_tag']] = (1, 'stg_inv')
|
||||
#
|
||||
# dataframe.loc[
|
||||
# (
|
||||
# (dataframe['mid_smooth_24'].shift(24) >= dataframe['mid_smooth_24'].shift(12))
|
||||
# & (dataframe['mid_smooth_24'].shift(12) <= dataframe['mid_smooth_24'])
|
||||
# & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d']))
|
||||
# & (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value)
|
||||
# & (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value)
|
||||
# # & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value)
|
||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
||||
# ), ['enter_long', 'enter_tag']] = (1, 'smth3_inv')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['mid_smooth_3_1h'].shift(24) >= dataframe['mid_smooth_3_1h'].shift(12))
|
||||
& (dataframe['mid_smooth_3_1h'].shift(12) <= dataframe['mid_smooth_3_1h'])
|
||||
& ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d']))
|
||||
& (dataframe[f"{self.indic_5m.value}_deriv1"] >= self.indic_deriv1_5m.value)
|
||||
& (dataframe[f"{self.indic_5m.value}_deriv2"] >= self.indic_deriv2_5m.value)
|
||||
# & (dataframe[f"{indic_1h}_deriv1"] >= self.indic_deriv1_1h.value)
|
||||
# & (dataframe[f"{indic_1h}_deriv2"] >= self.indic_deriv2_1h.value)
|
||||
), ['enter_long', 'enter_tag']] = (1, 'smth3_inv')
|
||||
(dataframe['percent3'] < -0.03)
|
||||
& (dataframe['percent'] > 0)
|
||||
), ['enter_long', 'enter_tag']] = (1, 'pct3')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe[f"{self.indic_5m.value}"].shift(2) >= dataframe[f"{self.indic_5m.value}"].shift(1))
|
||||
& (dataframe[f"{self.indic_5m.value}"].shift(1) <= dataframe['sma5'])
|
||||
& (dataframe[f"sma60_deriv1"] >= -0.2)
|
||||
), ['enter_long', 'enter_tag']] = (1, 'sma5')
|
||||
|
||||
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
|
||||
|
||||
@@ -1464,6 +1482,15 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# (dataframe['mid_smooth_deriv1'] == 0)
|
||||
# & (dataframe['mid_smooth_deriv1'].shift(1) > 0)
|
||||
# ), ['sell', 'exit_long']] = (1, 'sell_sma5_pct_1h')
|
||||
|
||||
# {indic_5m_sell} {indic_deriv1_5m_sell} {indic_deriv2_5m_sell}
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe[f"{self.indic_5m_sell.value}"].shift(2) < dataframe[f"{self.indic_5m_sell.value}"].shift(1))
|
||||
& (dataframe[f"{self.indic_5m_sell.value}"].shift(1) > dataframe[f"{self.indic_5m_sell.value}"])
|
||||
& (dataframe[f"sma60_deriv1"] > 0.3)
|
||||
), ['exit_long', 'exit_tag']] = (1, 'sma5')
|
||||
|
||||
return dataframe
|
||||
|
||||
def adjust_trade_position(self, trade: Trade, current_time: datetime,
|
||||
@@ -1562,10 +1589,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# return None
|
||||
|
||||
max_amount = self.config.get('stake_amount') * 2.5
|
||||
# stake_amount = min(stake_amount, self.wallets.get_available_stake_amount())
|
||||
stake_amount = min(min(max_amount, self.wallets.get_available_stake_amount()),
|
||||
self.adjust_stake_amount(pair,
|
||||
last_candle) - 10 * last_lost / self.mise_factor_buy.value) # min(200, self.adjust_stake_amount(pair, last_candle) * self.fibo[count_of_buys])
|
||||
self.adjust_stake_amount(pair, last_candle) * abs(last_lost / self.mise_factor_buy.value))
|
||||
|
||||
if self.wallets.get_available_stake_amount() > stake_amount:
|
||||
trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
|
||||
@@ -1699,7 +1724,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# Calculer le minimum des 14 derniers jours
|
||||
nb_pairs = len(self.dp.current_whitelist())
|
||||
|
||||
base_stake_amount = self.config.get('stake_amount') #/ (self.mises.value * nb_pairs) # Montant de base configuré
|
||||
base_stake_amount = self.config.get('stake_amount') / (self.mises.value) # * nb_pairs) # Montant de base configuré
|
||||
# pct60 = round(100 * self.getPctClose60D(pair, last_candle), 2)
|
||||
|
||||
if True: # not pair in ('BTC/USDT', 'BTC/USDC'):
|
||||
|
||||
Reference in New Issue
Block a user