Calcul 20250101-20250714 726.194 105.996$
This commit is contained in:
@@ -183,7 +183,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
'stop': False,
|
'stop': False,
|
||||||
'max_profit': 0,
|
'max_profit': 0,
|
||||||
'last_palier_index': -1,
|
'last_palier_index': -1,
|
||||||
'total_amount': 0
|
'total_amount': 0,
|
||||||
|
'has_gain': 0
|
||||||
}
|
}
|
||||||
for pair in ["BTC/USDC", "ETH/USDC", "DOGE/USDC", "XRP/USDC", "SOL/USDC",
|
for pair in ["BTC/USDC", "ETH/USDC", "DOGE/USDC", "XRP/USDC", "SOL/USDC",
|
||||||
"BTC/USDT", "ETH/USDT", "DOGE/USDT", "XRP/USDT", "SOL/USDT"]
|
"BTC/USDT", "ETH/USDT", "DOGE/USDT", "XRP/USDT", "SOL/USDT"]
|
||||||
@@ -375,6 +376,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
dispo=dispo,
|
dispo=dispo,
|
||||||
profit=round(trade.calc_profit(rate, amount), 2)
|
profit=round(trade.calc_profit(rate, amount), 2)
|
||||||
)
|
)
|
||||||
|
self.pairs[pair]['has_gain'] = 0
|
||||||
self.pairs[pair]['current_profit'] = 0
|
self.pairs[pair]['current_profit'] = 0
|
||||||
self.pairs[pair]['total_amount'] = 0
|
self.pairs[pair]['total_amount'] = 0
|
||||||
self.pairs[pair]['count_of_buys'] = 0
|
self.pairs[pair]['count_of_buys'] = 0
|
||||||
@@ -733,7 +735,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# print("##################")
|
# print("##################")
|
||||||
# self.calculateStats(informative, 'sma5_deriv1', 'futur_percent_3')
|
# self.calculateStats(informative, 'sma5_deriv1', 'futur_percent_3')
|
||||||
|
|
||||||
self.calculePlateaux(informative, 24, 0.01)
|
# self.calculePlateaux(informative, 6, 0.005)
|
||||||
|
|
||||||
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1h", ffill=True)
|
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1h", ffill=True)
|
||||||
|
|
||||||
@@ -762,9 +764,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.calculeDerivees(informative, 'sma5', factor_1=10, factor_2=1)
|
self.calculeDerivees(informative, 'sma5', factor_1=10, factor_2=1)
|
||||||
self.calculeDerivees(informative, 'sma20', factor_1=10, factor_2=1)
|
self.calculeDerivees(informative, 'sma20', factor_1=10, factor_2=1)
|
||||||
|
|
||||||
informative['inversion_haute'] = (informative['sma20'].shift(2) < informative['sma20'].shift(1)) & (informative['sma20'].shift(1) > informative['sma20'])
|
|
||||||
informative['inversion_basse'] = (informative['sma20'].shift(2) > informative['sma20'].shift(1)) & (informative['sma20'].shift(1) < informative['sma20'])
|
|
||||||
|
|
||||||
# informative['futur_percent_3'] = 100 * ((informative['sma5'].shift(-3) - informative['sma5']) / informative['sma5'])
|
# informative['futur_percent_3'] = 100 * ((informative['sma5'].shift(-3) - informative['sma5']) / informative['sma5'])
|
||||||
|
|
||||||
# if self.dp.runmode.value in ('backtest'):
|
# if self.dp.runmode.value in ('backtest'):
|
||||||
@@ -787,7 +786,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
# self.calculateProbabilite2Index(informative, futur_cols, indic_1, indic_2)
|
# self.calculateProbabilite2Index(informative, futur_cols, indic_1, indic_2)
|
||||||
|
|
||||||
self.calculePlateaux(informative, 14, 0.01)
|
# self.calculePlateaux(informative, 14, 0.01)
|
||||||
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1d", ffill=True)
|
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1d", ffill=True)
|
||||||
|
|
||||||
dataframe['last_price'] = dataframe['close']
|
dataframe['last_price'] = dataframe['close']
|
||||||
@@ -909,6 +908,14 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# indic_1 = 'mid_smooth_1h_deriv1'
|
# indic_1 = 'mid_smooth_1h_deriv1'
|
||||||
# indic_2 = 'mid_smooth_1h_deriv2'
|
# indic_2 = 'mid_smooth_1h_deriv2'
|
||||||
# self.calculateProbabilite2Index(dataframe, futur_cols, indic_1, indic_2)
|
# self.calculateProbabilite2Index(dataframe, futur_cols, indic_1, indic_2)
|
||||||
|
dataframe['can_sell'] = np.where((dataframe['mid_smooth_3'].shift(1) > dataframe['mid_smooth_3']), dataframe['close'], np.nan)
|
||||||
|
|
||||||
|
dataframe['can_buy'] = np.where((dataframe['mid_smooth_3'].shift(1) < dataframe['mid_smooth_3']), dataframe['close'], np.nan)
|
||||||
|
|
||||||
|
dataframe['perte_02'] = np.where((dataframe['percent3'] * 100 < -0.2), dataframe['close'], np.nan)
|
||||||
|
|
||||||
|
dataframe['mid_smooth_1h_deriv2_inv'] = np.where((dataframe['mid_smooth_1h_deriv2'].shift(2) >= dataframe['mid_smooth_1h_deriv2'].shift(1))
|
||||||
|
& (dataframe['mid_smooth_1h_deriv2'].shift(1) <= dataframe['mid_smooth_1h_deriv2']), dataframe['close'], np.nan)
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
@@ -1005,9 +1012,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
dataframe.loc[
|
dataframe.loc[
|
||||||
(
|
(
|
||||||
|
|
||||||
valid_inversion & inversion_last5
|
# (valid_inversion & inversion_last5 )
|
||||||
|
(dataframe['mid_smooth_3'].shift(1) < dataframe['mid_smooth_3'])
|
||||||
& (dataframe['hapercent'] > 0)
|
& (dataframe['hapercent'] > 0)
|
||||||
& (dataframe['max_rsi_12'] < 70)
|
& (dataframe['max_rsi_12'] < 70)
|
||||||
|
& (dataframe['open'] <= dataframe['bb_middleband'])
|
||||||
|
|
||||||
# valid_inversion
|
# valid_inversion
|
||||||
# ((dataframe['bb_cross_down'] < - 0.1)
|
# ((dataframe['bb_cross_down'] < - 0.1)
|
||||||
@@ -1025,17 +1034,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# & (dataframe['mid_smooth_1h_deriv1'] >= dataframe['mid_smooth_1h_deriv1'].shift(1))
|
# & (dataframe['mid_smooth_1h_deriv1'] >= dataframe['mid_smooth_1h_deriv1'].shift(1))
|
||||||
), ['enter_long', 'enter_tag']] = (1, 'smth')
|
), ['enter_long', 'enter_tag']] = (1, 'smth')
|
||||||
|
|
||||||
dataframe['can_sell'] = np.where(((dataframe['mid_smooth_1h_deriv1'].shift(2) <= dataframe['mid_smooth_1h_deriv1'].shift(1))\
|
|
||||||
& (dataframe['mid_smooth_1h_deriv1'].shift(1) >= dataframe['mid_smooth_1h_deriv1'])), dataframe['close'], np.nan)
|
|
||||||
|
|
||||||
dataframe['can_buy'] = np.where(((dataframe['mid_smooth_12_deriv2'].shift(1) < 0)\
|
|
||||||
& (dataframe['mid_smooth_12_deriv2'].shift(1) <= dataframe['mid_smooth_12_deriv2'])), dataframe['close'], np.nan)
|
|
||||||
|
|
||||||
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)
|
||||||
dataframe['perte_02'] = np.where((dataframe['percent3'] * 100 < -0.2), dataframe['close'], np.nan)
|
|
||||||
|
|
||||||
dataframe['mid_smooth_1h_deriv2_inv'] = np.where((dataframe['mid_smooth_1h_deriv2'].shift(2) >= dataframe['mid_smooth_1h_deriv2'].shift(1))
|
|
||||||
& (dataframe['mid_smooth_1h_deriv2'].shift(1) <= dataframe['mid_smooth_1h_deriv2']), dataframe['close'], np.nan)
|
|
||||||
|
|
||||||
# self.paliers = self.get_dca_stakes()
|
# self.paliers = self.get_dca_stakes()
|
||||||
|
|
||||||
@@ -1388,31 +1387,31 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# self.pairs[trade.pair]['last_candle'] = last_candle
|
# self.pairs[trade.pair]['last_candle'] = last_candle
|
||||||
# return -trade.stake_amount
|
# return -trade.stake_amount
|
||||||
|
|
||||||
# if (count_of_buys < limit_buy and pct_max > pct and current_profit > 0.004) \
|
if (False and count_of_buys < limit_buy and pct_max > 0.004 and hours > 2 and condition
|
||||||
# and (last_candle['rsi_deriv1_1h'] >= -5) \
|
and last_candle['rsi'] < 65 and last_candle['rsi_deriv1'] > 0):
|
||||||
# and (last_candle['tendency'] in ('P', 'H++', 'DH', 'H+')) \
|
try:
|
||||||
# and (last_candle['mid_smooth_deriv1'] > 0.015):
|
self.pairs[pair]['has_gain'] += 1
|
||||||
# try:
|
stake_amount = self.pairs[pair]['first_amount']
|
||||||
# trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
|
trade_type = last_candle['enter_tag'] if last_candle['enter_long'] == 1 else 'pct48'
|
||||||
# self.log_trade(
|
self.log_trade(
|
||||||
# last_candle=last_candle,
|
last_candle=last_candle,
|
||||||
# date=current_time,
|
date=current_time,
|
||||||
# action="Gain +",
|
action="Gain +",
|
||||||
# dispo=dispo,
|
dispo=dispo,
|
||||||
# pair=trade.pair,
|
pair=trade.pair,
|
||||||
# rate=current_rate,
|
rate=current_rate,
|
||||||
# trade_type=trade_type,
|
trade_type=str(round(pct_max,4)),
|
||||||
# profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 2),
|
profit=round(current_profit, 4), # round(current_profit * trade.stake_amount, 2),
|
||||||
# buys=trade.nr_of_successful_entries + 1,
|
buys=trade.nr_of_successful_entries + 1,
|
||||||
# stake=round(stake_amount, 2)
|
stake=round(stake_amount, 2)
|
||||||
# )
|
)
|
||||||
# self.pairs[trade.pair]['last_buy'] = current_rate
|
self.pairs[trade.pair]['last_buy'] = current_rate
|
||||||
# self.pairs[trade.pair]['max_touch'] = last_candle['close']
|
# self.pairs[trade.pair]['max_touch'] = last_candle['close']
|
||||||
# self.pairs[trade.pair]['last_candle'] = last_candle
|
self.pairs[trade.pair]['last_candle'] = last_candle
|
||||||
# return stake_amount
|
return stake_amount
|
||||||
# except Exception as exception:
|
except Exception as exception:
|
||||||
# print(exception)
|
print(exception)
|
||||||
# return None
|
return None
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -1476,7 +1475,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
base_stake_amount = self.config.get('stake_amount') # Montant de base configuré
|
base_stake_amount = self.config.get('stake_amount') # Montant de base configuré
|
||||||
# pct60 = round(100 * self.getPctClose60D(pair, last_candle), 2)
|
# pct60 = round(100 * self.getPctClose60D(pair, last_candle), 2)
|
||||||
|
|
||||||
if not pair in ('BTC/USDT', 'BTC/USDC'):
|
if True: #not pair in ('BTC/USDT', 'BTC/USDC'):
|
||||||
# factors = [1, 1.2, 1.3, 1.4]
|
# factors = [1, 1.2, 1.3, 1.4]
|
||||||
if self.pairs[pair]['count_of_buys'] == 0:
|
if self.pairs[pair]['count_of_buys'] == 0:
|
||||||
pctClose60 = self.getPctClose60D(pair, last_candle)
|
pctClose60 = self.getPctClose60D(pair, last_candle)
|
||||||
@@ -1550,7 +1549,14 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
return out_max - position * (out_max - out_min)
|
return out_max - position * (out_max - out_min)
|
||||||
|
|
||||||
def expectedProfit(self, pair: str, last_candle: DataFrame):
|
def expectedProfit(self, pair: str, last_candle: DataFrame):
|
||||||
pct_to_max = 0.004 + 0.001 * self.pairs[pair]['count_of_buys']
|
lim = 0.008
|
||||||
|
pct = 0.002
|
||||||
|
if pair == "BTC/USDT" or pair == "BTC/USDC":
|
||||||
|
lim = 0.004
|
||||||
|
pct = 0.001
|
||||||
|
pct_to_max = lim + pct * self.pairs[pair]['count_of_buys']
|
||||||
|
# if self.pairs[pair]['count_of_buys'] > 6:
|
||||||
|
# pct_to_max = 0.006 * self.pairs[pair]['count_of_buys']
|
||||||
# pctClose60 = self.getPctClose60D(pair, last_candle)
|
# pctClose60 = self.getPctClose60D(pair, last_candle)
|
||||||
|
|
||||||
# max_60 = last_candle['max60_1d']
|
# max_60 = last_candle['max60_1d']
|
||||||
@@ -2075,21 +2081,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
limit = 3
|
limit = 3
|
||||||
|
|
||||||
# if self.pairs[pair]['count_of_buys'] > 3:
|
|
||||||
# if last_candle['inversion_basse_1d']:
|
|
||||||
# if self.pairs[pair]['stop'] == True :
|
|
||||||
# self.pairs[pair]['stop'] = False
|
|
||||||
# print(f"start buying {last_candle['sma20_deriv1_1d']} {last_candle['sma20_deriv2_1d']}")
|
|
||||||
# else:
|
|
||||||
# if last_candle['inversion_haute_1d']:
|
|
||||||
# if self.pairs[pair]['stop'] == False:
|
|
||||||
# self.pairs[pair]['stop'] = True
|
|
||||||
# print(f"stop buying {last_candle['rsi6_1d']} {last_candle['percent_1d']} {last_candle['sma20_deriv1_1d']} {last_candle['sma20_deriv2_1d']}")
|
|
||||||
# return False
|
|
||||||
#
|
|
||||||
# if self.pairs[pair]['stop']:
|
|
||||||
# return False
|
|
||||||
|
|
||||||
if pair.startswith('BTC'):
|
if pair.startswith('BTC'):
|
||||||
return True # BTC toujours autorisé
|
return True # BTC toujours autorisé
|
||||||
|
|
||||||
@@ -2115,7 +2106,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
pct_max = self.getPctFirstBuy(pair, last_candle) #self.getPctLastBuy(pair, last_candle)
|
pct_max = self.getPctFirstBuy(pair, last_candle) #self.getPctLastBuy(pair, last_candle)
|
||||||
|
|
||||||
val = self.getProbaHausseSma5d(last_candle)
|
val = self.getProbaHausseSma5d(last_candle)
|
||||||
if (val < 15):
|
if val < 15:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# if count_decrease == len(non_btc_pairs):
|
# if count_decrease == len(non_btc_pairs):
|
||||||
@@ -2124,16 +2115,17 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# print(f"should_enter_trade canceled all pairs decreased {'':{char}>{self.should_enter_trade_count}}")
|
# print(f"should_enter_trade canceled all pairs decreased {'':{char}>{self.should_enter_trade_count}}")
|
||||||
# return False
|
# return False
|
||||||
|
|
||||||
# if self.pairs[pair]['count_of_buys'] >= 3:
|
if self.pairs[pair]['count_of_buys'] >= 3:
|
||||||
# if last_candle['sma20_deriv1_1d'] < 0 and last_candle['sma5_deriv1_1d'] < 0 and last_candle['sma24_deriv1_1h'] < 0:
|
if (last_candle['sma20_deriv1_1d'] < -0.05 and last_candle['sma5_deriv1_1d'] < -0.05)\
|
||||||
# return False
|
or (last_candle['sma5_deriv1_1d'] < -0.1 and last_candle['sma24_deriv1_1h'] < -0.1):
|
||||||
|
return False
|
||||||
|
|
||||||
self.should_enter_trade_count = 0
|
self.should_enter_trade_count = 0
|
||||||
|
|
||||||
# if max_pair != pair and self.pairs[pair]['total_amount'] > 300:
|
# if max_pair != pair and self.pairs[pair]['total_amount'] > 300:
|
||||||
# return False
|
# return False
|
||||||
|
|
||||||
if (max_pair != ''): # & (self.pairs[pair]['count_of_buys'] >= limit - 1) :
|
if (max_pair != '') & (self.pairs[pair]['count_of_buys'] >= limit) :
|
||||||
trade = self.pairs[max_pair]['current_trade']
|
trade = self.pairs[max_pair]['current_trade']
|
||||||
current_time = current_time.astimezone(timezone.utc)
|
current_time = current_time.astimezone(timezone.utc)
|
||||||
open_date = trade.open_date.astimezone(timezone.utc)
|
open_date = trade.open_date.astimezone(timezone.utc)
|
||||||
@@ -2141,7 +2133,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
days_since_open = (current_time_utc - open_date).days
|
days_since_open = (current_time_utc - open_date).days
|
||||||
pct_max_max = self.getPctFirstBuy(max_pair, last_candle)
|
pct_max_max = self.getPctFirstBuy(max_pair, last_candle)
|
||||||
# print(f"days_since_open {days_since_open} max_pair={max_pair} pair={pair}")
|
# print(f"days_since_open {days_since_open} max_pair={max_pair} pair={pair}")
|
||||||
return max_pair == pair or pct_max < - 0.25 or (pct_max_max < - 0.15 and max_pair != pair and days_since_open > 60)
|
return max_pair == pair or pct_max < - 0.25 or (pct_max_max < - 0.15 and max_pair != pair and days_since_open > 30)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user