Zeus_8_3_2_B_4_2 refonte tendance / changement calcul profit attendu
This commit is contained in:
@@ -91,6 +91,14 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
"max_min": {
|
||||
"color": "#74effc"
|
||||
}
|
||||
},
|
||||
"smooth": {
|
||||
'mid_smooth_deriv1': {
|
||||
"color": "blue"
|
||||
},
|
||||
'mid_smooth_deriv1_1h': {
|
||||
"color": "red"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,7 +163,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# last_candle_12 = dataframe.iloc[-13].squeeze()
|
||||
|
||||
# allow_to_buy = True #(not self.stop_all) #& (not self.all_down)
|
||||
allow_to_buy = not last_candle['tendency'] in ('B--', 'B++') # (rate <= float(limit)) | (entry_tag == 'force_entry')
|
||||
allow_to_buy = True #not last_candle['tendency'] in ('B-', 'B--') # (rate <= float(limit)) | (entry_tag == 'force_entry')
|
||||
self.trades = list()
|
||||
dispo = round(self.wallets.get_available_stake_amount())
|
||||
|
||||
@@ -167,7 +175,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
self.pairs[pair]['current_profit'] = 0
|
||||
|
||||
self.printLog(
|
||||
f"|{'-' * 18}+{'-' * 12}+{'-' * 5}+{'-' * 20}+{'-' * 14}+{'-' * 8}+{'-' * 10}+{'-' * 7}+{'-' * 13}+{'-' * 14}+{'-' * 14}+{'-' * 7}+{'-' * 12}|"
|
||||
f"|{'-' * 18}+{'-' * 12}+{'-' * 5}+{'-' * 20}+{'-' * 14}+{'-' * 8}+{'-' * 10}+{'-' * 8}+{'-' * 13}+"
|
||||
f"{'-' * 14}+{'-' * 14}+{'-' * 4}+{'-' * 7}|"
|
||||
)
|
||||
|
||||
stake_amount = self.adjust_stake_amount(pair, last_candle)
|
||||
@@ -240,6 +249,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
before_last_candle = dataframe.iloc[-2].squeeze()
|
||||
|
||||
expected_profit = self.expectedProfit(pair, last_candle)
|
||||
# print(f"current_time={current_time} current_profit={current_profit} expected_profit={expected_profit}")
|
||||
|
||||
max_touch_before = self.pairs[pair]['max_touch']
|
||||
self.pairs[pair]['last_max'] = max(last_candle['haclose'], self.pairs[pair]['last_max'])
|
||||
@@ -250,13 +260,13 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
self.pairs[pair]['current_profit'] = current_profit
|
||||
pct_first = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3)
|
||||
|
||||
if (last_candle['tendency'] in ('H++', 'H--')) \
|
||||
and (last_candle['tendency_1d'] in ('H++', 'H--')) \
|
||||
and (last_candle['tendency_1d'] in ('H++', 'H--')) :
|
||||
if (last_candle['tendency'] in ('H++', 'H+')) :
|
||||
# and (last_candle['tendency_1h'] in ('H++', 'H+')):
|
||||
# and (last_candle['tendency_1d'] in ('H++', 'H+')) :
|
||||
return None
|
||||
|
||||
# if (last_candle['rsi_1d'] > 50) & (last_candle['percent12'] < 0.0):
|
||||
if (last_candle['percent3'] < 0.0) & (current_profit > 0.05): #last_candle['min_max200'] / 3):
|
||||
if (last_candle['percent3'] < 0.0) & (current_profit > expected_profit): #last_candle['min_max200'] / 3):
|
||||
self.trades = list()
|
||||
return 'mx_' + str(count_of_buys)
|
||||
if (last_candle['percent12'] <= -0.01) & (current_profit >= expected_profit):
|
||||
@@ -321,10 +331,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# f"|{'-' * 18}+{'-' * 12}+{'-' * 12}+{'-' * 20}+{'-' * 14}+{'-' * 8}+{'-' * 10}+{'-' * 7}+{'-' * 13}+{'-' * 14}+{'-' * 14}+{'-' * 7}+{'-' * 12}|"
|
||||
# )
|
||||
self.printLog(
|
||||
f"| {'Date':<16} | {'Action':<10} |{'Pair':<5}| {'Trade Type':<18} | {'Rate':>12} | {'Dispo':>6} | {'Profit':>8} | {'Pct':>6} | {'max_touch':>11} | {'last_lost':>12} | {'last_max':>12} | {'Buys':>5} | {'Stake':>10} |"
|
||||
f"| {'Date':<16} | {'Action':<10} |{'Pair':<5}| {'Trade Type':<18} | {'Rate':>12} | {'Dispo':>6} | {'Profit':>8} | {'Pct':>6} | {'max_touch':>11} | {'last_lost':>12} | {'last_max':>12} |{'Buys':>4}| {'Stake':>5} |"
|
||||
)
|
||||
self.printLog(
|
||||
f"|{'-' * 18}+{'-' * 12}+{'-' * 5}+{'-' * 20}+{'-' * 14}+{'-' * 8}+{'-' * 10}+{'-' * 8}+{'-' * 13}+{'-' * 14}+{'-' * 14}+{'-' * 7}+{'-' * 12}|"
|
||||
f"|{'-' * 18}+{'-' * 12}+{'-' * 5}+{'-' * 20}+{'-' * 14}+{'-' * 8}+{'-' * 10}+{'-' * 8}+{'-' * 13}+{'-' * 14}+{'-' * 14}+{'-' * 4}+{'-' * 7}|"
|
||||
)
|
||||
self.columns_logged += 1
|
||||
date = str(date)[:16] if date else "-"
|
||||
@@ -366,9 +376,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
|
||||
self.printLog(
|
||||
f"| {date:<16} | {action:<10} | {pair[0:3]:<3} | {trade_type or '-':<18} | {rate or '-':>12} | {dispo or '-':>6} "
|
||||
f"| {profit or '-':>8} | {pct_max or '-':>6} | {max_touch or '-':>11} | {last_lost or '-':>12} "
|
||||
f"| {round(self.pairs[pair]['last_max'], 2) or '-':>12} | {buys or '-':>5} | {stake or '-':>10} "
|
||||
f"| {last_candle['tendency'] or '-':>3} | {last_candle['tendency_1h'] or '-':>3} | {last_candle['tendency_1d'] or '-':>3} |"
|
||||
f"| {profit or '-':>8} | {pct_max or '-':>6} | {round(self.pairs[pair]['max_touch'], 2) or '-':>11} | {last_lost or '-':>12} "
|
||||
f"| {round(self.pairs[pair]['last_max'], 2) or '-':>12} |{buys or '-':>4}|{stake or '-':>7}"
|
||||
f"|{round(last_candle['sma5_1d'], 2) or '-':>8}"
|
||||
f"|{last_candle['tendency'] or '-':>3}|{last_candle['tendency_1h'] or '-':>3}|{last_candle['tendency_1d'] or '-':>3}"
|
||||
f"|{round(last_candle['mid_smooth_deriv1']):>3}|{round(last_candle['mid_smooth_deriv1_1h']):>5}|"
|
||||
)
|
||||
|
||||
def printLog(self, str):
|
||||
@@ -388,9 +400,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
if d1 == 0.0:
|
||||
return 'DH' if d2 > 0 else 'DB' #Depart Hausse / Départ Baisse
|
||||
if d1 > d1_lim_sup:
|
||||
return 'H++' if d2 > 0 else 'H--' #Acceleration Hausse / Ralentissement Hausse
|
||||
return 'H++' if d2 > 0 else 'H+' #Acceleration Hausse / Ralentissement Hausse
|
||||
if d1 < d1_lim_inf:
|
||||
return 'B++' if d2 < 0 else 'B--' # Accéleration Baisse / Ralentissement Baisse
|
||||
return 'B--' if d2 < 0 else 'B-' # Accéleration Baisse / Ralentissement Baisse
|
||||
return 'Mid'
|
||||
|
||||
dataframe['tendency'] = dataframe.apply(tag_by_derivatives, axis=1)
|
||||
@@ -436,13 +448,6 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
dataframe["percent48"] = (dataframe["close"] - dataframe["open"].shift(48)) / dataframe["open"].shift(48)
|
||||
dataframe["percent_max_144"] = (dataframe["close"] - dataframe["max144"]) / dataframe["close"]
|
||||
|
||||
dataframe['sma10_s2'] = dataframe['sma10'].shift(1)
|
||||
dataframe['sma20_s2'] = dataframe['sma20'].shift(1)
|
||||
dataframe['percent12_s2'] = dataframe['percent12'].shift(1)
|
||||
|
||||
dataframe['sma5_s5'] = dataframe['sma5'].shift(4)
|
||||
dataframe['sma10_s5'] = dataframe['sma10'].shift(4)
|
||||
dataframe['sma20_s5'] = dataframe['sma20'].shift(4)
|
||||
# print(metadata['pair'])
|
||||
dataframe['rsi'] = talib.RSI(dataframe['close'], length=14)
|
||||
dataframe['rsi_diff'] = dataframe['rsi'].diff()
|
||||
@@ -663,9 +668,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
dataframe['mid_smooth_tag_min'] = (dataframe['mid_smooth'].shift(1)) == 0 & (dataframe['mid_smooth'] > 0)
|
||||
|
||||
# 2. Dérivée première = différence entre deux bougies successives
|
||||
dataframe['mid_smooth_deriv1'] = round(dataframe['mid_smooth'].diff(), 2)
|
||||
dataframe['mid_smooth_deriv1'] = round(100000 * dataframe['mid_smooth'].pct_change(), 2)
|
||||
# 3. Dérivée seconde = différence de la dérivée première
|
||||
dataframe['mid_smooth_deriv2'] = round(dataframe['mid_smooth_deriv1'].diff(), 2)
|
||||
dataframe['mid_smooth_deriv2'] = round(100 * dataframe['mid_smooth_deriv1'].pct_change().rolling(3).mean(), 2)
|
||||
dataframe = self.add_tendency_column(dataframe)
|
||||
return dataframe
|
||||
|
||||
@@ -761,16 +766,16 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# (dataframe["bb_width"] > 0.01)
|
||||
(dataframe['down_count'].shift(1) < - 6)
|
||||
& (dataframe['down_count'] == 0)
|
||||
# & (dataframe['tendency'] != "B++")
|
||||
# & (dataframe['tendency'] != "B--")
|
||||
# & (dataframe['tendency'] != "B-")
|
||||
), ['enter_long', 'enter_tag']] = (1, 'down')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['low'] < dataframe['min200'])
|
||||
& (dataframe['min50'] == dataframe['min200'].shift(3))
|
||||
# & (dataframe['tendency'] != "B++")
|
||||
# & (dataframe['tendency'] != "B--")
|
||||
# & (dataframe['tendency'] != "B-")
|
||||
), ['enter_long', 'enter_tag']] = (1, 'low')
|
||||
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
|
||||
|
||||
@@ -803,7 +808,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
|
||||
return None
|
||||
pair = trade.pair
|
||||
if pair not in ('BTC/USDT', 'BTC/USDC'):
|
||||
if pair not in ('BTC/USDT', 'BTC/USDC', 'XRP/USDT', 'XRP/USDC'):
|
||||
print(f"skip pair {pair}")
|
||||
return None
|
||||
count_of_buys = trade.nr_of_successful_entries
|
||||
@@ -842,7 +847,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
or ((last_candle['min50'] == last_candle_3['min50']) and (last_candle['low'] <= last_candle['min50']))
|
||||
) \
|
||||
and (last_candle['rsi_diff_1h'] >= -5) \
|
||||
and (last_candle['tendency'] in ('P', 'H++', 'DH', 'H--')) \
|
||||
and (last_candle['tendency'] in ('P', 'H++', 'DH', 'H+')) \
|
||||
and ((pct_max < lim)):
|
||||
try:
|
||||
# print(self.adjust_stake_amount(pair, last_candle))
|
||||
@@ -897,6 +902,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
# Stack amount ajusté price=2473.47 min_max=0.15058074985054215 percent=0.8379141364642171 amount=20.0
|
||||
|
||||
first_price = self.pairs[pair]['first_buy']
|
||||
if (first_price == 0):
|
||||
first_price = last_candle['close']
|
||||
|
||||
last_max = last_candle['max200']
|
||||
if self.pairs[pair]['last_max'] > 0:
|
||||
@@ -972,7 +979,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
||||
percent = (max_14_days - current_price) / (min_14_days)
|
||||
|
||||
min_max = dataframe['pct_min_max_1d'] # (max_14_days - min_14_days) / min_14_days
|
||||
expected_profit = min(0.1, max(0.01, dataframe['min_max200'] * 0.5))
|
||||
expected_profit = min(0.01, max(0.01, dataframe['min_max200'] * 0.5))
|
||||
|
||||
# print(
|
||||
# f"Expected profit price={current_price:.4f} min_max={min_max:.4f} min_14={min_14_days:.4f} max_14={max_14_days:.4f} percent={percent:.4f} expected_profit={expected_profit:.4f}")
|
||||
|
||||
Reference in New Issue
Block a user