Test nouvelle stratégie max 24h
This commit is contained in:
@@ -124,21 +124,18 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
]
|
]
|
||||||
|
|
||||||
levels = [1, 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
|
levels = [1, 2, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
|
||||||
# startup_candle_count = 12 * 24 * 5
|
startup_candle_count = 12 * 24 * 5
|
||||||
|
|
||||||
# ROI table:
|
# ROI table:
|
||||||
minimal_roi = {
|
minimal_roi = {
|
||||||
"0": 0.564,
|
"1440": 0
|
||||||
"567": 0.273,
|
|
||||||
"2814": 0.12,
|
|
||||||
"7675": 0
|
|
||||||
}
|
}
|
||||||
stakes = 40
|
stakes = 40
|
||||||
|
|
||||||
# Stoploss:
|
# Stoploss:
|
||||||
stoploss = -1 # 0.256
|
stoploss = -1 # 0.256
|
||||||
# Custom stoploss
|
# Custom stoploss
|
||||||
use_custom_stoploss = False
|
use_custom_stoploss = True
|
||||||
|
|
||||||
trailing_stop = True
|
trailing_stop = True
|
||||||
trailing_stop_positive = 0.15
|
trailing_stop_positive = 0.15
|
||||||
@@ -257,6 +254,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
columns_logged = False
|
columns_logged = False
|
||||||
pairs = {
|
pairs = {
|
||||||
pair: {
|
pair: {
|
||||||
|
'first_amount': 0,
|
||||||
"first_buy": 0,
|
"first_buy": 0,
|
||||||
"last_buy": 0.0,
|
"last_buy": 0.0,
|
||||||
"last_min": 999999999999999.5,
|
"last_min": 999999999999999.5,
|
||||||
@@ -329,52 +327,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
pct = DecimalParameter(0.005, 0.05, default=0.012, decimals=3, space='buy', optimize=True, load=True)
|
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.0022, decimals=4, space='buy', optimize=True, load=True)
|
pct_inc = DecimalParameter(0.0001, 0.003, default=0.0022, decimals=4, space='buy', optimize=True, load=True)
|
||||||
|
|
||||||
indic_5m_slope_sup_buy = CategoricalParameter(indicators, default="sma60", space='buy')
|
|
||||||
# indic_deriv_5m_slop_sup_buy = CategoricalParameter(indicators, default="sma12", space='buy', optimize=True, load=True)
|
|
||||||
# deriv_5m_slope_sup_buy = DecimalParameter(-0.1, 0.5, default=0, decimals=2, space='buy', optimize=True, load=True)
|
|
||||||
|
|
||||||
indic_5m_slope_inf_buy = CategoricalParameter(indicators, default="sma60", space='buy')
|
|
||||||
# indic_deriv_5m_slop_inf_buy = CategoricalParameter(indicators, default="sma12", space='buy', optimize=True, load=True)
|
|
||||||
# deriv_5m_slope_inf_buy = DecimalParameter(-0.1, 0.5, 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_5m_slope_sup_sell = CategoricalParameter(indicators, default="sma60", space='sell')
|
|
||||||
indic_deriv_5m_slope_sup_sell = CategoricalParameter(indicators, default="sma60", space='sell')
|
|
||||||
deriv_5m_slope_sup_sell = DecimalParameter(-0.1, 0.5, default=0, decimals=2, space='sell', optimize=True, load=True)
|
|
||||||
|
|
||||||
indic_5m_slope_inf_sell = CategoricalParameter(indicators, default="sma60", space='sell')
|
|
||||||
indic_deriv_5m_slope_inf_sell = CategoricalParameter(indicators, default="sma60", space='sell')
|
|
||||||
deriv_5m_slope_inf_sell = DecimalParameter(-0.1, 0.5, default=0, decimals=2, space='sell', optimize=True, load=True)
|
|
||||||
|
|
||||||
deriv1_buy_protect = DecimalParameter(-0.3, 0.1, default=-0.1, decimals=2, space='protection', optimize=True, load=True)
|
deriv1_buy_protect = DecimalParameter(-0.3, 0.1, default=-0.1, decimals=2, space='protection', optimize=True, load=True)
|
||||||
rsi_buy_protect = IntParameter(50, 90, default=70, space='protection', optimize=True, load=True)
|
rsi_buy_protect = IntParameter(50, 90, default=70, space='protection', optimize=True, load=True)
|
||||||
indic_5m_slope_sup = CategoricalParameter(indicators, default="sma60", space='protection')
|
indic_5m_slope_sup = CategoricalParameter(indicators, default="sma60", space='protection')
|
||||||
indic_1h_slope_sup = CategoricalParameter(indicators, default="sma5", space='protection')
|
indic_1h_slope_sup = CategoricalParameter(indicators, default="sma5", space='protection')
|
||||||
|
|
||||||
# indic_percent_sell = CategoricalParameter(indicators_percent, default="sma60", space='sell')
|
|
||||||
|
|
||||||
# percent_5m_sell = DecimalParameter(-0.1, -0.0, 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)
|
|
||||||
|
|
||||||
labels = ['B3', 'B2', 'B1', 'N0', 'H1', 'H2', 'H3']
|
labels = ['B3', 'B2', 'B1', 'N0', 'H1', 'H2', 'H3']
|
||||||
index_labels = ['B3', 'B2', 'B1', 'N0', 'H1', 'H2', 'H3']
|
index_labels = ['B3', 'B2', 'B1', 'N0', 'H1', 'H2', 'H3']
|
||||||
ordered_labels = ['B3', 'B2', 'B1', 'N0', 'H1', 'H2', 'H3']
|
ordered_labels = ['B3', 'B2', 'B1', 'N0', 'H1', 'H2', 'H3']
|
||||||
@@ -456,6 +413,18 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
if not self.should_enter_trade(pair, last_candle, current_time):
|
if not self.should_enter_trade(pair, last_candle, current_time):
|
||||||
allow_to_buy = False
|
allow_to_buy = False
|
||||||
|
|
||||||
|
# On récupère le dernier trade ouvert (toutes paires)
|
||||||
|
last_date = self.pairs[pair]['last_date']
|
||||||
|
|
||||||
|
if not last_date:
|
||||||
|
last_date = dataframe.iloc[-1]["date"]
|
||||||
|
self.pairs[pair]['last_date'] = last_date
|
||||||
|
|
||||||
|
now = dataframe.iloc[-1]["date"]
|
||||||
|
|
||||||
|
if now - last_date >= timedelta(hours=24):
|
||||||
|
allow_to_buy = True
|
||||||
|
|
||||||
if allow_to_buy:
|
if allow_to_buy:
|
||||||
self.trades = list()
|
self.trades = list()
|
||||||
self.pairs[pair]['first_buy'] = rate
|
self.pairs[pair]['first_buy'] = rate
|
||||||
@@ -466,7 +435,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.pairs[pair]['current_profit'] = 0
|
self.pairs[pair]['current_profit'] = 0
|
||||||
self.pairs[pair]['last_max'] = max(last_candle['close'], self.pairs[pair]['last_max'])
|
self.pairs[pair]['last_max'] = max(last_candle['close'], self.pairs[pair]['last_max'])
|
||||||
self.pairs[pair]['last_min'] = min(last_candle['close'], self.pairs[pair]['last_min'])
|
self.pairs[pair]['last_min'] = min(last_candle['close'], self.pairs[pair]['last_min'])
|
||||||
|
self.pairs[pair]['last_date'] = current_time
|
||||||
dispo = round(self.wallets.get_available_stake_amount())
|
dispo = round(self.wallets.get_available_stake_amount())
|
||||||
self.printLineLog()
|
self.printLineLog()
|
||||||
|
|
||||||
@@ -499,7 +468,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
profit =trade.calc_profit(rate)
|
profit =trade.calc_profit(rate)
|
||||||
force = self.pairs[pair]['force_sell']
|
force = self.pairs[pair]['force_sell']
|
||||||
allow_to_sell = (last_candle['hapercent'] < 0 and profit > 0) or force or (exit_reason == 'force_exit') or (exit_reason == 'stop_loss')
|
allow_to_sell = (last_candle['hapercent'] < 0 and profit > 0) or force or (exit_reason == 'sma48') or (exit_reason == 'force_exit') or (exit_reason == 'stop_loss')
|
||||||
|
|
||||||
minutes = int(round((current_time - trade.date_last_filled_utc).total_seconds() / 60, 0))
|
minutes = int(round((current_time - trade.date_last_filled_utc).total_seconds() / 60, 0))
|
||||||
|
|
||||||
@@ -534,7 +503,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.pairs[pair]['current_trade'] = None
|
self.pairs[pair]['current_trade'] = None
|
||||||
# else:
|
# else:
|
||||||
# print(f"STOP triggered for {pair} ({exit_reason}) but condition blocked", "warning")
|
# print(f"STOP triggered for {pair} ({exit_reason}) but condition blocked", "warning")
|
||||||
return (allow_to_sell) | (exit_reason == 'force_exit') | (exit_reason == 'stop_loss')
|
return (allow_to_sell) | (exit_reason == 'force_exit') | (exit_reason == 'stop_loss') | force
|
||||||
|
|
||||||
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
|
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
|
||||||
proposed_stake: float, min_stake: float, max_stake: float,
|
proposed_stake: float, min_stake: float, max_stake: float,
|
||||||
@@ -580,21 +549,15 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.pairs[pair]['current_profit'] = profit
|
self.pairs[pair]['current_profit'] = profit
|
||||||
|
|
||||||
dispo = round(self.wallets.get_available_stake_amount())
|
dispo = round(self.wallets.get_available_stake_amount())
|
||||||
hours_since_first_buy = (current_time - trade.open_date_utc).seconds / 3600.0
|
hours_since_first_buy = round((current_time - trade.open_date_utc).seconds / 3600.0, 1)
|
||||||
days_since_first_buy = (current_time - trade.open_date_utc).days
|
days_since_first_buy = (current_time - trade.open_date_utc).days
|
||||||
hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0
|
hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0
|
||||||
|
|
||||||
# trend = last_candle['trend_class']
|
|
||||||
#
|
|
||||||
# indic_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_5m_sell')
|
|
||||||
# indic_deriv1_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_deriv1_5m_sell')
|
|
||||||
# indic_deriv2_5m_sell = self.getParamValue( pair, trend, 'sell', 'indic_deriv2_5m_sell')
|
|
||||||
|
|
||||||
if hours % 4 == 0:
|
if hours % 4 == 0:
|
||||||
self.log_trade(
|
self.log_trade(
|
||||||
last_candle=last_candle,
|
last_candle=last_candle,
|
||||||
date=current_time,
|
date=current_time,
|
||||||
action="🔴 CURRENT" if self.pairs[pair]['stop'] else "🟢 CURRENT",
|
action="🔴 CURRENT" if self.pairs[pair]['stop'] else "🟢 CURRENT " + str(hours_since_first_buy),
|
||||||
dispo=dispo,
|
dispo=dispo,
|
||||||
pair=pair,
|
pair=pair,
|
||||||
rate=last_candle['close'],
|
rate=last_candle['close'],
|
||||||
@@ -612,32 +575,16 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# if (last_candle['sma24_deriv1'] < 0 and before_last_candle['sma24_deriv1'] >= 0) and (current_profit > expected_profit):
|
# if (last_candle['sma24_deriv1'] < 0 and before_last_candle['sma24_deriv1'] >= 0) and (current_profit > expected_profit):
|
||||||
# return 'Drv_' + str(count_of_buys)
|
# return 'Drv_' + str(count_of_buys)
|
||||||
pair_name = self.getShortName(pair)
|
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 == "B-" or trend == "B--") 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'] == 1 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 == "B-" or trend == "B--") and last_candle[f"{self.indic_5m_sell.value}_deriv1"] <= self.indic_deriv1_5m_sell.value \
|
if current_profit < - 0.02 and last_candle['sma48'] < before_last_candle['sma48'] - 10:
|
||||||
# and last_candle[f"{self.indic_5m_sell.value}_deriv2"] <= self.indic_deriv2_5m_sell.value:
|
self.pairs[pair]['force_sell'] = True
|
||||||
# return None
|
self.pairs[pair]['force_buy'] = False #(self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] > 3)
|
||||||
|
return str(count_of_buys) + '_' + 'stop48_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
||||||
|
|
||||||
|
if hours_since_first_buy >= 23.9 :
|
||||||
|
self.pairs[pair]['force_sell'] = True
|
||||||
|
self.pairs[pair]['force_buy'] = False #(self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] > 3)
|
||||||
|
return str(count_of_buys) + '_' + 'hours_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
||||||
|
|
||||||
if last_candle['max_rsi_24'] > 85 and profit > max(5, expected_profit) and (last_candle['hapercent'] < 0) and last_candle['sma60_deriv1'] < 0.05:
|
if last_candle['max_rsi_24'] > 85 and profit > max(5, expected_profit) and (last_candle['hapercent'] < 0) and last_candle['sma60_deriv1'] < 0.05:
|
||||||
self.pairs[pair]['force_sell'] = False
|
self.pairs[pair]['force_sell'] = False
|
||||||
@@ -650,12 +597,12 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
return str(count_of_buys) + '_' + 'Frc_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
return str(count_of_buys) + '_' + 'Frc_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
||||||
|
|
||||||
if profit > max(5, expected_profit) and baisse > 0.30:
|
if profit > max(5, expected_profit) and baisse > 0.30:
|
||||||
self.pairs[pair]['force_sell'] = False
|
self.pairs[pair]['force_sell'] = True
|
||||||
self.pairs[pair]['force_buy'] = (self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] > 3)
|
self.pairs[pair]['force_buy'] = (self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] > 3)
|
||||||
return str(count_of_buys) + '_' + 'B30_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
return str(count_of_buys) + '_' + 'B30_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
||||||
|
|
||||||
if max_profit > 0.5 * count_of_buys and baisse > 0.15 and last_candle['sma12_state'] <= 0 and last_candle['sma60_state'] <= - 1:
|
if max_profit > 0.5 * count_of_buys and baisse > 0.15 and last_candle['sma12_state'] <= 0 and last_candle['sma60_state'] <= - 1:
|
||||||
self.pairs[pair]['force_sell'] = False
|
self.pairs[pair]['force_sell'] = True
|
||||||
self.pairs[pair]['force_buy'] = (self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] > 3)
|
self.pairs[pair]['force_buy'] = (self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] > 3)
|
||||||
return str(count_of_buys) + '_' + 'B15_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
return str(count_of_buys) + '_' + 'B15_' + pair_name + '_' + str(self.pairs[pair]['has_gain'])
|
||||||
|
|
||||||
@@ -831,16 +778,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# 🟡 Dérivée 1 > 0 et dérivée 2 < 0: tendance haussière qui ralentit → essoufflement potentiel.
|
# 🟡 Dérivée 1 > 0 et dérivée 2 < 0: tendance haussière qui ralentit → essoufflement potentiel.
|
||||||
# 🔴 Dérivée 1 < 0 et dérivée 2 < 0: tendance baissière qui s’accélère.
|
# 🔴 Dérivée 1 < 0 et dérivée 2 < 0: tendance baissière qui s’accélère.
|
||||||
# 🟠 Dérivée 1 < 0 et dérivée 2 > 0: tendance baissière qui ralentit → possible bottom.
|
# 🟠 Dérivée 1 < 0 et dérivée 2 > 0: tendance baissière qui ralentit → possible bottom.
|
||||||
# trend = last_candle['trend_class_1d']
|
|
||||||
#
|
|
||||||
# indic_5m = self.getParamValue(pair, trend, 'buy', 'indic_5m')
|
|
||||||
# indic_deriv1_5m = self.getParamValue(pair, trend, 'buy', 'indic_deriv1_5m')
|
|
||||||
# indic_deriv2_5m = self.getParamValue(pair, trend, 'buy', 'indic_deriv2_5m')
|
|
||||||
#
|
|
||||||
# indic_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_5m_sell')
|
|
||||||
# indic_deriv1_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_deriv1_5m_sell')
|
|
||||||
# indic_deriv2_5m_sell = self.getParamValue(pair, trend, 'sell', 'indic_deriv2_5m_sell')
|
|
||||||
|
|
||||||
|
|
||||||
self.printLog(
|
self.printLog(
|
||||||
f"| {date:<16} |{action:<10} | {pair[0:3]:<3} | {trade_type or '-':<18} |{rate or '-':>9}| {dispo or '-':>6} "
|
f"| {date:<16} |{action:<10} | {pair[0:3]:<3} | {trade_type or '-':<18} |{rate or '-':>9}| {dispo or '-':>6} "
|
||||||
@@ -856,7 +793,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# f"|{last_candle['min60_1d']}|{last_candle['max60_1d']}"
|
# f"|{last_candle['min60_1d']}|{last_candle['max60_1d']}"
|
||||||
# f"|{last_candle['mid_smooth_tdc_5_1d'] or '-':>3}|{last_candle['mid_smooth_tdc_5_1h'] or '-':>3}|{last_candle['mid_smooth_tdc_5'] or '-':>3}"
|
# f"|{last_candle['mid_smooth_tdc_5_1d'] or '-':>3}|{last_candle['mid_smooth_tdc_5_1h'] or '-':>3}|{last_candle['mid_smooth_tdc_5'] or '-':>3}"
|
||||||
f"|{last_candle['mid_smooth_5_state_1d'] or '-':>3}|{last_candle['mid_smooth_24_state_1h'] or '-':>3}|{last_candle['mid_smooth_5_state_1h'] or '-':>3}|{last_candle['mid_smooth_5_state'] or '-':>3}"
|
f"|{last_candle['mid_smooth_5_state_1d'] or '-':>3}|{last_candle['mid_smooth_24_state_1h'] or '-':>3}|{last_candle['mid_smooth_5_state_1h'] or '-':>3}|{last_candle['mid_smooth_5_state'] or '-':>3}"
|
||||||
f"|{last_candle['trend_class_1d']:>5} {last_candle['trend_class_1h']:>5}" # {indic_5m} {indic_deriv1_5m} {indic_deriv2_5m} {indic_5m_sell} {indic_deriv1_5m_sell} {indic_deriv2_5m_sell}"
|
f"|{last_candle['trend_class_1d']:>5} {last_candle['trend_class_1h']:>5}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def getLastLost(self, last_candle, pair):
|
def getLastLost(self, last_candle, pair):
|
||||||
@@ -1921,14 +1858,14 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
|
|
||||||
# dérivée relative simple
|
# dérivée relative simple
|
||||||
dataframe[d1_col] = (dataframe[name] - dataframe[name].shift(1)) / dataframe[name].shift(1)
|
dataframe[d1_col] = factor1 * ((dataframe[name] - dataframe[name].shift(3)) / dataframe[name].shift(3))
|
||||||
# lissage EMA
|
# lissage EMA
|
||||||
dataframe[d1_col] = factor1 * dataframe[d1_col].ewm(span=ema_period, adjust=False).mean()
|
# dataframe[d1_col] = factor1 * dataframe[d1_col].ewm(span=ema_period, adjust=False).mean()
|
||||||
|
|
||||||
# dataframe[d1_col] = dataframe[d1_col].rolling(window=ema_period, center=True).median()
|
# dataframe[d1_col] = dataframe[d1_col].rolling(window=ema_period, center=True).median()
|
||||||
|
|
||||||
dataframe[d2_col] = dataframe[d1_col] - dataframe[d1_col].shift(1)
|
dataframe[d2_col] = factor2 * (dataframe[d1_col] - dataframe[d1_col].shift(1))
|
||||||
dataframe[d2_col] = factor2 * dataframe[d2_col].ewm(span=ema_period, adjust=False).mean()
|
# dataframe[d2_col] = factor2 * dataframe[d2_col].ewm(span=ema_period, adjust=False).mean()
|
||||||
|
|
||||||
# epsilon adaptatif via rolling percentile
|
# epsilon adaptatif via rolling percentile
|
||||||
p_low_d1 = dataframe[d1_col].rolling(window=window, min_periods=1).quantile(0.05)
|
p_low_d1 = dataframe[d1_col].rolling(window=window, min_periods=1).quantile(0.05)
|
||||||
@@ -2006,116 +1943,13 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
pair = metadata['pair']
|
pair = metadata['pair']
|
||||||
# trend = self.getTrend(dataframe)
|
|
||||||
# # params = self.loadParamsFor(pair, trend)
|
|
||||||
#
|
|
||||||
# indic_5m = self.getParamValue(pair, trend, 'buy', 'indic_5m')
|
|
||||||
# indic_deriv1_5m = self.getParamValue( pair, trend, 'buy', 'indic_deriv1_5m')
|
|
||||||
# indic_deriv2_5m = self.getParamValue( pair, trend, 'buy', 'indic_deriv2_5m')
|
|
||||||
|
|
||||||
# dataframe.loc[
|
|
||||||
# (
|
|
||||||
# (dataframe['mid_smooth_3'].shift(1) < dataframe['mid_smooth_3'])
|
|
||||||
# & (dataframe['hapercent'] > 0)
|
|
||||||
# & ((dataframe['max_rsi_24_1h'] < 70) | (dataframe['close'] < dataframe['close_1d']))
|
|
||||||
# & (dataframe['open'] <= dataframe['bb_middleband'])
|
|
||||||
# & (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, '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)
|
|
||||||
# & (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)
|
|
||||||
# & (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, '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.loc[
|
||||||
(
|
(
|
||||||
(dataframe['percent3'] < -0.03)
|
# (dataframe["mid_smooth_5_deriv1_1d"] > 0)
|
||||||
& (dataframe['percent'] > 0)
|
# (dataframe["sma48_deriv2"] > 0)
|
||||||
), ['enter_long', 'enter_tag']] = (1, 'pct3')
|
(dataframe['sma48'] > dataframe['sma48'].shift(1) + 20)
|
||||||
|
), ['enter_long', 'enter_tag']] = (1, 'sma48')
|
||||||
dataframe.loc[
|
|
||||||
(
|
|
||||||
(dataframe["sma24"].shift(2) >= dataframe["sma24"].shift(1))
|
|
||||||
& (dataframe["sma24"].shift(1) <= dataframe["sma24"])
|
|
||||||
& (dataframe['percent3_1h'] < -0.03)
|
|
||||||
), ['enter_long', 'enter_tag']] = (1, 'pct3_1h')
|
|
||||||
|
|
||||||
dataframe.loc[
|
|
||||||
(
|
|
||||||
(dataframe[f"{self.indic_5m_slope_sup_buy.value}"].shift(2) >= dataframe[f"{self.indic_5m_slope_sup_buy.value}"].shift(1))
|
|
||||||
& (dataframe[f"{self.indic_5m_slope_sup_buy.value}"].shift(1) <= dataframe[f"{self.indic_5m_slope_sup_buy.value}"])
|
|
||||||
& (dataframe['slope_norm_1d'] < dataframe['slope_norm_1h'])
|
|
||||||
& (dataframe['stop_buying'] == False)
|
|
||||||
# & (dataframe[f"{self.indic_deriv_5m_buy.value}_deriv1"] > self.deriv_5m_buy.value)
|
|
||||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
|
||||||
# & (dataframe[f"hapercent"] >= -0.001)
|
|
||||||
), ['enter_long', 'enter_tag']] = (1, f"{self.indic_5m_slope_sup.value}_sup")
|
|
||||||
|
|
||||||
dataframe.loc[
|
|
||||||
(
|
|
||||||
(dataframe[f"{self.indic_5m_slope_inf_buy.value}"].shift(2) >= dataframe[f"{self.indic_5m_slope_inf_buy.value}"].shift(1))
|
|
||||||
& (dataframe[f"{self.indic_5m_slope_inf_buy.value}"].shift(1) <= dataframe[f"{self.indic_5m_slope_inf_buy.value}"])
|
|
||||||
& (dataframe['slope_norm_1d'] > dataframe['slope_norm_1h'])
|
|
||||||
& (dataframe['stop_buying'] == False)
|
|
||||||
# & (dataframe[f"{self.indic_deriv_5m_buy.value}_deriv1"] > self.deriv_5m_buy.value)
|
|
||||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
|
||||||
# & (dataframe[f"hapercent"] >= -0.001)
|
|
||||||
), ['enter_long', 'enter_tag']] = (1, f"{self.indic_5m_slope_inf_buy.value}_inf")
|
|
||||||
|
|
||||||
dataframe.loc[
|
|
||||||
(
|
|
||||||
(dataframe['stop_buying'] == False)
|
|
||||||
& (dataframe['stop_buying'].shift(1) == True)
|
|
||||||
# & (dataframe[f"{self.indic_deriv_5m_buy.value}_deriv1"] > self.deriv_5m_buy.value)
|
|
||||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
|
||||||
# & (dataframe[f"hapercent"] >= -0.001)
|
|
||||||
), ['enter_long', 'enter_tag']] = (1, f"end")
|
|
||||||
|
|
||||||
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
|
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
|
||||||
|
|
||||||
@@ -2270,40 +2104,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
# dataframe.loc[
|
# dataframe.loc[
|
||||||
# (
|
# (
|
||||||
# (dataframe['mid_smooth_deriv1'] == 0)
|
# (dataframe['sma48'] < dataframe['sma48'].shift(1) - 10)
|
||||||
# & (dataframe['mid_smooth_deriv1'].shift(1) > 0)
|
# ), ['exit_long', 'exit_tag']] = (1, 'sma48')
|
||||||
# ), ['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_slope_sup_sell.value}"].shift(2) < dataframe[f"{self.indic_5m_slope_sup_sell.value}"].shift(1))
|
|
||||||
& (dataframe[f"{self.indic_5m_slope_sup_sell.value}"].shift(1) > dataframe[f"{self.indic_5m_slope_sup_sell.value}"])
|
|
||||||
& (dataframe[f"{self.indic_deriv_5m_slope_sup_sell.value}_deriv1"] < self.deriv_5m_slope_sup_sell.value)
|
|
||||||
& (dataframe['slope_norm_1d'] > dataframe['slope_norm_1h'])
|
|
||||||
), ['exit_long', 'exit_tag']] = (1, f"{self.indic_5m_slope_sup_sell.value}_sup")
|
|
||||||
|
|
||||||
dataframe.loc[
|
|
||||||
(
|
|
||||||
(dataframe[f"{self.indic_5m_slope_inf_sell.value}"].shift(2) < dataframe[f"{self.indic_5m_slope_inf_sell.value}"].shift(1))
|
|
||||||
& (dataframe[f"{self.indic_5m_slope_inf_sell.value}"].shift(1) > dataframe[f"{self.indic_5m_slope_inf_sell.value}"])
|
|
||||||
& (dataframe[f"{self.indic_deriv_5m_slope_inf_sell.value}_deriv1"] < self.deriv_5m_slope_inf_sell.value)
|
|
||||||
& (dataframe['slope_norm_1d'] < dataframe['slope_norm_1h'])
|
|
||||||
), ['exit_long', 'exit_tag']] = (1, f"{self.indic_5m_slope_inf_sell.value}_inf")
|
|
||||||
|
|
||||||
dataframe.loc[
|
|
||||||
(
|
|
||||||
(dataframe['stop_buying'] == True)
|
|
||||||
& (dataframe['stop_buying'].shift(1) == False)
|
|
||||||
# & (dataframe[f"{self.indic_deriv_5m_buy.value}_deriv1"] > self.deriv_5m_buy.value)
|
|
||||||
# & (dataframe[f"sma60_deriv1"] >= -0.2)
|
|
||||||
# & (dataframe[f"hapercent"] >= -0.001)
|
|
||||||
), ['enter_long', 'enter_tag']] = (1, f"start")
|
|
||||||
|
|
||||||
# dataframe.loc[
|
|
||||||
# (
|
|
||||||
# (dataframe[f"{self.indic_percent_sell.value}"] < self.percent_5m_sell.value)
|
|
||||||
# ), ['exit_long', 'exit_tag']] = (1, f"{self.indic_percent_sell.value}")
|
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
@@ -2443,7 +2245,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
print(exception)
|
print(exception)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if (profit > self.pairs[pair]['previous_profit'] and profit > self.pairs[pair]['expected_profit'] and hours > 6
|
if (profit > self.pairs[pair]['previous_profit'] and profit > self.pairs[pair]['expected_profit'] and hours > 6
|
||||||
# and last_candle['sma60_deriv1'] > 0
|
# and last_candle['sma60_deriv1'] > 0
|
||||||
and last_candle['max_rsi_12_1h'] < 75
|
and last_candle['max_rsi_12_1h'] < 75
|
||||||
and last_candle['rsi_1d'] < 58
|
and last_candle['rsi_1d'] < 58
|
||||||
@@ -2542,6 +2344,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# Calculer le minimum des 14 derniers jours
|
# Calculer le minimum des 14 derniers jours
|
||||||
nb_pairs = len(self.dp.current_whitelist())
|
nb_pairs = len(self.dp.current_whitelist())
|
||||||
|
|
||||||
|
return self.config.get('stake_amount')
|
||||||
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)
|
# pct60 = round(100 * self.getPctClose60D(pair, last_candle), 2)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user