TEST mid_smooth_5_deriv1_1d
This commit is contained in:
@@ -17,18 +17,17 @@
|
||||
"max_open_trades": 80
|
||||
},
|
||||
"buy": {
|
||||
"buy_horizon_predict_1h": 2
|
||||
"buy_horizon_predict_1h": 3,
|
||||
"mise_factor_buy": 0.07
|
||||
},
|
||||
"sell": {},
|
||||
"protection": {
|
||||
"sma20_deriv1_1d_start_protection": 0.0,
|
||||
"sma20_deriv1_1d_stop_protection": 0.0,
|
||||
"sma5_deriv1_1d_start_protection": 0.0,
|
||||
"sma5_deriv1_1d_stop_protection": 0.0,
|
||||
"sma5_deriv2_1d_start_protection": 0.0,
|
||||
"sma5_deriv1_1d_restart_protection": 0.06,
|
||||
"sma5_deriv1_1d_stop_protection": -0.03,
|
||||
"sma5_deriv2_1d_restart_protection": 0.0,
|
||||
"sma5_deriv2_1d_stop_protection": 0.0
|
||||
}
|
||||
},
|
||||
"ft_stratparam_v": 1,
|
||||
"export_time": "2025-09-27 06:44:29.575217+00:00"
|
||||
"export_time": "2025-09-27 19:01:48.513825+00:00"
|
||||
}
|
||||
@@ -211,21 +211,21 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
trades = list()
|
||||
max_profit_pairs = {}
|
||||
|
||||
sma20_deriv1_1d_stop_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection',
|
||||
# sma20_deriv1_1d_stop_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection',
|
||||
# optimize=True, load=True)
|
||||
sma5_deriv1_1d_stop_protection = DecimalParameter(-0.2, 0, default=0.05, decimals=2, space='protection',
|
||||
optimize=True, load=True)
|
||||
sma5_deriv1_1d_stop_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection',
|
||||
optimize=True, load=True)
|
||||
sma5_deriv2_1d_stop_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=1, space='protection', optimize=True,
|
||||
sma5_deriv2_1d_stop_protection = DecimalParameter(-0.2, 0, default=0.05, decimals=1, space='protection', optimize=True,
|
||||
load=True)
|
||||
|
||||
sma20_deriv1_1d_start_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection',
|
||||
# sma20_deriv1_1d_start_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection',
|
||||
# optimize=True, load=True)
|
||||
sma5_deriv1_1d_restart_protection = DecimalParameter(0, 0.2, default=0.05, decimals=2, space='protection',
|
||||
optimize=True, load=True)
|
||||
sma5_deriv1_1d_start_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=2, space='protection',
|
||||
optimize=True, load=True)
|
||||
sma5_deriv2_1d_start_protection = DecimalParameter(-0.2, 0.2, default=0.05, decimals=1, space='protection', optimize=True,
|
||||
sma5_deriv2_1d_restart_protection = DecimalParameter(0, 0.2, default=0.05, decimals=1, space='protection', optimize=True,
|
||||
load=True)
|
||||
|
||||
# sma5_deriv1_1d_protection = DecimalParameter(-0.1, 0.0, default=-0.05, decimals=2, space='protection', optimize=True, load=True)
|
||||
mise_factor_buy = DecimalParameter(0.01, 0.2, default=0.05, decimals=2, space='buy', optimize=True, load=True)
|
||||
|
||||
# Récupération des labels ordonnés
|
||||
# labels = ['B5', 'B4', 'B3', 'B2', 'B1', 'N0', 'H1', 'H2', 'H3', 'H4', 'H5']
|
||||
@@ -447,11 +447,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
days_since_first_buy = (current_time - trade.open_date_utc).days
|
||||
hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0
|
||||
|
||||
if self.pairs[pair]['stop'] and hours % 6 == 0:
|
||||
if hours % 4 == 0:
|
||||
self.log_trade(
|
||||
last_candle=last_candle,
|
||||
date=current_time,
|
||||
action="🟠 CURRENT",
|
||||
action="🔴 CURRENT" if self.pairs[pair]['stop'] else "🟢 CURRENT",
|
||||
dispo=dispo,
|
||||
pair=pair,
|
||||
rate=last_candle['close'],
|
||||
@@ -611,8 +611,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
|
||||
color = GREEN if profit > 0 else RED
|
||||
color_sma20 = GREEN if last_candle['sma20_deriv1_1d'] > 0 else RED
|
||||
color_sma5 = GREEN if last_candle['sma5_deriv1_1d'] > 0 else RED
|
||||
color_sma5_2 = GREEN if last_candle['sma5_deriv2_1d'] > 0 else RED
|
||||
color_sma5 = GREEN if last_candle['mid_smooth_5_deriv1_1d'] > 0 else RED
|
||||
color_sma5_2 = GREEN if last_candle['mid_smooth_5_deriv2_1d'] > 0 else RED
|
||||
color_sma5_1h = GREEN if last_candle['sma5_deriv1_1h'] > 0 else RED
|
||||
color_sma5_2h = GREEN if last_candle['sma5_deriv2_1h'] > 0 else RED
|
||||
color_smooth_1h = GREEN if last_candle['mid_smooth_1h_deriv1'] > 0 else RED
|
||||
@@ -638,7 +638,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# f"{round(last_candle['mid_smooth_24_deriv2'],3) or '-' :>6}|{round(last_candle['mid_smooth_1h_deriv2'],3) or '-':>6}|{round(last_candle['mid_smooth_deriv2_1d'],3) or '-':>6}|"
|
||||
f"{round(val, 1) or '-' :>6}|"
|
||||
f"{dist_max:>7}|{color_sma20}{round(last_candle['sma20_deriv1_1d'], 2):>5}{RESET}"
|
||||
f"|{color_sma5}{round(last_candle['sma5_deriv1_1d'], 2):>5}{RESET}|{color_sma5_2}{round(last_candle['sma5_deriv2_1d'], 2):>5}{RESET}"
|
||||
f"|{color_sma5}{round(last_candle['mid_smooth_5_deriv1_1d'], 2):>5}{RESET}|{color_sma5_2}{round(last_candle['mid_smooth_5_deriv2_1d'], 2):>5}{RESET}"
|
||||
f"|{color_sma5_1h}{round(last_candle['sma5_deriv1_1h'], 2):>5}{RESET}|{color_sma5_2h}{round(last_candle['sma5_deriv2_1h'], 2):>5}{RESET}"
|
||||
f"|{color_smooth_1h}{round(last_candle['mid_smooth_1h_deriv1'], 2):>5}{RESET}|{color_smooth2_1h}{round(last_candle['mid_smooth_1h_deriv2'], 2):>5}{RESET}"
|
||||
# f"|{last_candle['min60_1d']}|{last_candle['max60_1d']}"
|
||||
@@ -663,16 +663,18 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
)
|
||||
|
||||
def printLog(self, str):
|
||||
if self.config.get('runmode') == 'hyperopt' or self.dp.runmode.value in ('hyperopt'):
|
||||
return;
|
||||
if not self.dp.runmode.value in ('backtest', 'hyperopt', 'lookahead-analysis'):
|
||||
logger.info(str)
|
||||
else:
|
||||
if not self.dp.runmode.value in ('hyperopt'):
|
||||
print(str)
|
||||
|
||||
def add_tendency_column(self, dataframe: pd.DataFrame, suffixe='') -> pd.DataFrame:
|
||||
def add_tendency_column(self, dataframe: pd.DataFrame, name, suffixe='') -> pd.DataFrame:
|
||||
def tag_by_derivatives(row):
|
||||
d1 = row[f"mid_smooth{suffixe}_deriv1"]
|
||||
d2 = row[f"mid_smooth{suffixe}_deriv2"]
|
||||
d1 = row[f"{name}{suffixe}_deriv1"]
|
||||
d2 = row[f"{name}{suffixe}_deriv2"]
|
||||
d1_lim_inf = -0.01
|
||||
d1_lim_sup = 0.01
|
||||
if d1 >= d1_lim_inf and d1 <= d1_lim_sup: # and d2 >= d2_lim_inf and d2 <= d2_lim_sup:
|
||||
@@ -797,6 +799,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
|
||||
################### INFORMATIVE 1d
|
||||
informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe="1d")
|
||||
heikinashi = qtpylib.heikinashi(informative)
|
||||
informative['haopen'] = heikinashi['open']
|
||||
informative['haclose'] = heikinashi['close']
|
||||
informative['hapercent'] = (informative['haclose'] - informative['haopen']) / informative['haclose']
|
||||
# informative = self.calculateDerivation(informative, window=5, factor_1=10000, factor_2=1000)
|
||||
# informative['volatility'] = talib.STDDEV(informative['close'], timeperiod=14) / informative['close']
|
||||
# informative['atr'] = (talib.ATR(informative['high'], informative['low'], informative['close'], timeperiod=14)) / informative['close']
|
||||
@@ -820,6 +826,12 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
self.calculeDerivees(informative, 'sma5', factor_1=10, factor_2=1)
|
||||
self.calculeDerivees(informative, 'sma20', factor_1=10, factor_2=1)
|
||||
|
||||
informative = self.add_tendency_column(informative, "", "sma5")
|
||||
informative = self.add_tendency_column(informative, "", "sma20")
|
||||
|
||||
# mid_smooth_5_deriv1_1d / mid_smooth_5_deriv2_1d
|
||||
informative = self.calculateDerivation(informative, window=5, suffixe="_5")
|
||||
|
||||
macd, macdsignal, macdhist = talib.MACD(
|
||||
informative['close'],
|
||||
fastperiod=12,
|
||||
@@ -1023,7 +1035,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# 3. Dérivée seconde = différence de la dérivée première
|
||||
dataframe[f"mid_smooth{suffixe}_deriv2"] = round(
|
||||
factor_2 * dataframe[f"mid_smooth{suffixe}_deriv1"].rolling(window=3).mean().diff(), 4)
|
||||
dataframe = self.add_tendency_column(dataframe, suffixe)
|
||||
dataframe = self.add_tendency_column(dataframe, "mid_smooth", suffixe)
|
||||
return dataframe
|
||||
|
||||
def getOpenTrades(self):
|
||||
@@ -1414,7 +1426,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
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 * pct_first / 0.05) # min(200, self.adjust_stake_amount(pair, last_candle) * self.fibo[count_of_buys])
|
||||
self.adjust_stake_amount(pair, last_candle) - 10 * pct_first / self.mise_factor_buy.value) # min(200, self.adjust_stake_amount(pair, last_candle) * self.fibo[count_of_buys])
|
||||
|
||||
trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
|
||||
self.pairs[trade.pair]['count_of_buys'] += 1
|
||||
@@ -2168,9 +2180,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# 🔴 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.
|
||||
|
||||
if not pair.startswith('BTC'):
|
||||
if self.pairs[pair]['stop'] and last_candle['sma5_deriv1_1d'] > self.sma5_deriv1_1d_stop_protection.value \
|
||||
and last_candle['sma5_deriv2_1d'] > self.sma5_deriv2_1d_stop_protection.value:
|
||||
# if not pair.startswith('BTC'):
|
||||
if self.pairs[pair]['stop'] \
|
||||
and last_candle['mid_smooth_5_deriv1_1d'] > self.sma5_deriv1_1d_restart_protection.value \
|
||||
and last_candle['mid_smooth_5_deriv2_1d'] > self.sma5_deriv2_1d_restart_protection.value:
|
||||
self.pairs[pair]['stop'] = False
|
||||
self.log_trade(
|
||||
last_candle=last_candle,
|
||||
@@ -2185,13 +2198,14 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
stake=0
|
||||
)
|
||||
else:
|
||||
if self.pairs[pair]['stop'] == False and last_candle['sma5_deriv1_1d'] < - self.sma5_deriv1_1d_start_protection.value \
|
||||
and last_candle['sma5_deriv2_1d'] < - self.sma5_deriv2_1d_start_protection.value:
|
||||
if self.pairs[pair]['stop'] == False \
|
||||
and last_candle['mid_smooth_5_deriv1_1d'] < self.sma5_deriv1_1d_stop_protection.value \
|
||||
and last_candle['mid_smooth_5_deriv2_1d'] < self.sma5_deriv2_1d_stop_protection.value:
|
||||
self.pairs[pair]['stop'] = True
|
||||
self.log_trade(
|
||||
last_candle=last_candle,
|
||||
date=current_time,
|
||||
action="🔴🔴🔴🔴🔴 🔴STOP",
|
||||
action="🔴STOP",
|
||||
dispo=0,
|
||||
pair=pair,
|
||||
rate=last_candle['close'],
|
||||
|
||||
Reference in New Issue
Block a user