Multiple paire detection / limit 3
This commit is contained in:
@@ -156,18 +156,15 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
pair: {
|
pair: {
|
||||||
"first_buy": 0,
|
"first_buy": 0,
|
||||||
"last_max": 0,
|
"last_max": 0,
|
||||||
"trade_info": {},
|
|
||||||
"max_touch": 0.0,
|
"max_touch": 0.0,
|
||||||
"last_sell": 0.0,
|
"last_sell": 0.0,
|
||||||
"last_buy": 0.0,
|
"last_buy": 0.0,
|
||||||
|
'total_amount': 0.0,
|
||||||
'count_of_buys': 0,
|
'count_of_buys': 0,
|
||||||
'current_profit': 0,
|
'current_profit': 0,
|
||||||
'expected_profit': 0,
|
|
||||||
"last_candle": {},
|
"last_candle": {},
|
||||||
"last_trade": None,
|
"last_trade": None,
|
||||||
"last_count_of_buys": 0,
|
"last_count_of_buys": 0,
|
||||||
'base_stake_amount': 0,
|
|
||||||
'stop_buy': False,
|
|
||||||
'last_date': 0,
|
'last_date': 0,
|
||||||
'stop': False,
|
'stop': False,
|
||||||
'max_profit': 0,
|
'max_profit': 0,
|
||||||
@@ -279,6 +276,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
stake_amount = self.adjust_stake_amount(pair, last_candle)
|
stake_amount = self.adjust_stake_amount(pair, last_candle)
|
||||||
|
|
||||||
|
self.pairs[pair]['total_amount'] = stake_amount
|
||||||
|
|
||||||
self.log_trade(
|
self.log_trade(
|
||||||
last_candle=last_candle,
|
last_candle=last_candle,
|
||||||
date=current_time,
|
date=current_time,
|
||||||
@@ -366,6 +365,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.pairs[pair]['count_of_buys'] = count_of_buys
|
self.pairs[pair]['count_of_buys'] = count_of_buys
|
||||||
self.pairs[pair]['current_profit'] = current_profit
|
self.pairs[pair]['current_profit'] = current_profit
|
||||||
self.pairs[pair]['max_profit'] = max(self.pairs[pair]['max_profit'], current_profit)
|
self.pairs[pair]['max_profit'] = max(self.pairs[pair]['max_profit'], current_profit)
|
||||||
|
self.pairs[pair]['total_amount'] = 0
|
||||||
|
|
||||||
# if (last_candle['mid_smooth_deriv1'] >= 0):
|
# if (last_candle['mid_smooth_deriv1'] >= 0):
|
||||||
# return None
|
# return None
|
||||||
@@ -929,9 +929,6 @@ 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
|
||||||
pair = trade.pair
|
pair = trade.pair
|
||||||
|
|
||||||
if not self.should_enter_trade(pair):
|
|
||||||
return None
|
|
||||||
|
|
||||||
pct_first = 0
|
pct_first = 0
|
||||||
if self.pairs[pair]['first_buy']:
|
if self.pairs[pair]['first_buy']:
|
||||||
pct_first = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3)
|
pct_first = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3)
|
||||||
@@ -958,6 +955,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
print("skip dataframe")
|
print("skip dataframe")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if not self.should_enter_trade(pair):
|
||||||
|
return None
|
||||||
|
|
||||||
# if self.dp.runmode.value in ('dry_run'):
|
# if self.dp.runmode.value in ('dry_run'):
|
||||||
# if pair not in ('BTC/USDT', 'BTC/USDC', 'XRP/USDT', 'XRP/USDC', 'ETH/USDT', 'ETH/USDC', 'SOL/USDT', 'SOL/USDT'):
|
# if pair not in ('BTC/USDT', 'BTC/USDC', 'XRP/USDT', 'XRP/USDC', 'ETH/USDT', 'ETH/USDC', 'SOL/USDT', 'SOL/USDT'):
|
||||||
# # print(f"skip pair {pair}")
|
# # print(f"skip pair {pair}")
|
||||||
@@ -1094,6 +1094,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
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.pairs[trade.pair]['count_of_buys'] += 1
|
self.pairs[trade.pair]['count_of_buys'] += 1
|
||||||
|
self.pairs[pair]['total_amount'] += stake_amount
|
||||||
self.log_trade(
|
self.log_trade(
|
||||||
last_candle=last_candle,
|
last_candle=last_candle,
|
||||||
date=current_time,
|
date=current_time,
|
||||||
@@ -1110,6 +1111,19 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
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
|
||||||
|
|
||||||
|
# for pair, values in self.pairs.items():
|
||||||
|
# print(f"\n{pair}")
|
||||||
|
# for key, value in values.items():
|
||||||
|
# print(f" {key:20}: {value}")
|
||||||
|
|
||||||
|
df = pd.DataFrame.from_dict(self.pairs, orient='index')
|
||||||
|
colonnes_a_exclure = ['last_candle', 'last_trade', 'last_palier_index', 'stop']
|
||||||
|
df_filtered = df[df['count_of_buys'] > 0].drop(columns=colonnes_a_exclure)
|
||||||
|
# df_filtered = df_filtered["first_buy", "last_max", "max_touch", "last_sell","last_buy", 'count_of_buys', 'current_profit']
|
||||||
|
|
||||||
|
print(df_filtered)
|
||||||
|
|
||||||
return stake_amount
|
return stake_amount
|
||||||
except Exception as exception:
|
except Exception as exception:
|
||||||
print(exception)
|
print(exception)
|
||||||
@@ -1720,28 +1734,26 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
non_btc_pairs = [p for p in self.pairs if not p.startswith('BTC')]
|
non_btc_pairs = [p for p in self.pairs if not p.startswith('BTC')]
|
||||||
|
|
||||||
# Compter les positions actives sur les paires non-BTC
|
# Compter les positions actives sur les paires non-BTC
|
||||||
has_more_than_3 = False
|
max_nb_trades = 0
|
||||||
total_non_btc = 0
|
total_non_btc = 0
|
||||||
|
max_pair = ''
|
||||||
for p in non_btc_pairs:
|
for p in non_btc_pairs:
|
||||||
nb_trades = self.pairs[p]['count_of_buys']
|
max_nb_trades = max(max_nb_trades, self.pairs[p]['count_of_buys'])
|
||||||
if nb_trades > 0:
|
if (max_nb_trades == self.pairs[p]['count_of_buys'] and max_nb_trades > limit):
|
||||||
if nb_trades > limit and pair != p:
|
max_pair = p
|
||||||
has_more_than_3 = True
|
total_non_btc += self.pairs[p]['count_of_buys']
|
||||||
total_non_btc += nb_trades
|
|
||||||
|
|
||||||
this_pair_count = self.pairs[p]['count_of_buys']
|
this_pair_count = self.pairs[p]['count_of_buys']
|
||||||
|
|
||||||
if total_non_btc >= 12:
|
# if total_non_btc >= 12:
|
||||||
# print("total_non_btc > 10")
|
# # print("total_non_btc > 10")
|
||||||
return False
|
# return False
|
||||||
|
|
||||||
if this_pair_count >= limit:
|
if max_pair != '':
|
||||||
|
#if this_pair_count >= limit:
|
||||||
# Si une autre paire non-BTC a aussi >3 trades, blocage
|
# Si une autre paire non-BTC a aussi >3 trades, blocage
|
||||||
# for other_pair, count in pair_counts.items():
|
# if max_pair == pair:
|
||||||
# if other_pair != pair and count >= 3:
|
# print(f"{pair} Cette paire {max_pair} est la seule avec >=3 / {max_nb_trades}")
|
||||||
# return False
|
return max_pair == pair
|
||||||
if not has_more_than_3:
|
|
||||||
print(f"{pair} Cette paire est la seule avec >=3 / {this_pair_count}")
|
|
||||||
return not has_more_than_3
|
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user