Test buy mid_smooth_1h_deriv1
This commit is contained in:
@@ -173,7 +173,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
'last_date': 0,
|
'last_date': 0,
|
||||||
'stop': False,
|
'stop': False,
|
||||||
'max_profit': 0,
|
'max_profit': 0,
|
||||||
'last_palier_index': -1
|
'last_palier_index': -1,
|
||||||
|
'baisse': 0,
|
||||||
|
'mx': 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"]
|
||||||
@@ -240,6 +242,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
# buy_level_predict_1h = IntParameter(2, 5, default=4, space='buy')
|
# buy_level_predict_1h = IntParameter(2, 5, default=4, space='buy')
|
||||||
|
|
||||||
|
should_enter_trade_count = 0
|
||||||
|
|
||||||
def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str,
|
def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str,
|
||||||
current_time: datetime, entry_tag: Optional[str], **kwargs) -> bool:
|
current_time: datetime, entry_tag: Optional[str], **kwargs) -> bool:
|
||||||
|
|
||||||
@@ -377,6 +381,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
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
|
self.pairs[pair]['total_amount'] = 0
|
||||||
|
|
||||||
|
self.pairs[pair]['baisse'] = baisse
|
||||||
|
self.pairs[pair]['mx'] = mx
|
||||||
|
|
||||||
# if (last_candle['mid_smooth_deriv1'] >= 0):
|
# if (last_candle['mid_smooth_deriv1'] >= 0):
|
||||||
# return None
|
# return None
|
||||||
# if (last_candle['tendency'] in ('H++', 'H+')) and (last_candle['rsi'] < 80):
|
# if (last_candle['tendency'] in ('H++', 'H+')) and (last_candle['rsi'] < 80):
|
||||||
@@ -384,24 +391,25 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
#
|
#
|
||||||
# if (last_candle['sma20_deriv1'] < 0 and before_last_candle['sma20_deriv1'] >= 0) and (current_profit > expected_profit):
|
# if (last_candle['sma20_deriv1'] < 0 and before_last_candle['sma20_deriv1'] >= 0) and (current_profit > expected_profit):
|
||||||
# return 'Drv_' + str(count_of_buys)
|
# return 'Drv_' + str(count_of_buys)
|
||||||
|
pair_name = pair.replace("/USDT", '').replace("/USDC", '')
|
||||||
if 1 <= count_of_buys <= 3:
|
if 1 <= count_of_buys <= 3:
|
||||||
if ((before_last_candle_2['mid_smooth_3_deriv1'] <= before_last_candle['mid_smooth_3_deriv1'])
|
if ((before_last_candle_2['mid_smooth_3_deriv1'] <= before_last_candle['mid_smooth_3_deriv1'])
|
||||||
& (before_last_candle['mid_smooth_3_deriv1'] >= last_candle['mid_smooth_3_deriv1'])) \
|
& (before_last_candle['mid_smooth_3_deriv1'] >= last_candle['mid_smooth_3_deriv1'])) \
|
||||||
and (current_profit > expected_profit):
|
and (current_profit > expected_profit):
|
||||||
return 'Drv3_' + pair + '_' + str(count_of_buys)
|
|
||||||
|
return 'Drv3_' + pair_name + '_' + str(count_of_buys)
|
||||||
|
|
||||||
if 4 <= count_of_buys <= 6:
|
if 4 <= count_of_buys <= 6:
|
||||||
if ((before_last_candle_2['mid_smooth_12_deriv1'] <= before_last_candle['mid_smooth_12_deriv1'])
|
if ((before_last_candle_2['mid_smooth_12_deriv1'] <= before_last_candle['mid_smooth_12_deriv1'])
|
||||||
& (before_last_candle['mid_smooth_12_deriv1'] >= last_candle['mid_smooth_12_deriv1'])) \
|
& (before_last_candle['mid_smooth_12_deriv1'] >= last_candle['mid_smooth_12_deriv1'])) \
|
||||||
and (current_profit > expected_profit):
|
and (current_profit > expected_profit):
|
||||||
return 'Drv13_' + pair + '_' + str(count_of_buys)
|
return 'Drv13_' + pair_name + '_' + str(count_of_buys)
|
||||||
|
|
||||||
if 7 <= count_of_buys:
|
if 7 <= count_of_buys:
|
||||||
if ((before_last_candle_24['sma24_deriv1_1h'] <= before_last_candle_12['sma24_deriv1_1h'])
|
if ((before_last_candle_24['sma24_deriv1_1h'] <= before_last_candle_12['sma24_deriv1_1h'])
|
||||||
& (before_last_candle_12['sma24_deriv1_1h'] >= last_candle['sma24_deriv1_1h'])) \
|
& (before_last_candle_12['sma24_deriv1_1h'] >= last_candle['sma24_deriv1_1h'])) \
|
||||||
and (current_profit > expected_profit):
|
and (current_profit > expected_profit):
|
||||||
return 'Drv24_' + pair + '_' + str(count_of_buys)
|
return 'Drv24_' + pair_name + '_' + str(count_of_buys)
|
||||||
|
|
||||||
# if (baisse > mx) & (current_profit > expected_profit):
|
# if (baisse > mx) & (current_profit > expected_profit):
|
||||||
# self.trades = list()
|
# self.trades = list()
|
||||||
@@ -454,7 +462,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
if self.columns_logged % 30 == 0:
|
if self.columns_logged % 30 == 0:
|
||||||
self.printLog(
|
self.printLog(
|
||||||
f"| {'Date':<16} | {'Action':<10} |{'Pair':<5}| {'Trade Type':<18} |{'Rate':>8} | {'Dispo':>6} | {'Profit':>8} | {'Pct':>6} | {'max_touch':>11} | {'last_lost':>12} | {'last_max':>7}|{'Buys':>4}| {'Stake':>5} |"
|
f"| {'Date':<16} | {'Action':<10} |{'Pair':<5}| {'Trade Type':<18} |{'Rate':>8} | {'Dispo':>6} | {'Profit':>8} | {'Pct':>6} | {'max_touch':>11} | {'last_lost':>12} | {'last_max':>7}|{'Buys':>4}| {'Stake':>5} |"
|
||||||
f"Tdc|{'val':>6}| sma5 |smooth |Distmax"
|
f"Tdc|{'val':>6}| smooth|smoodrv|Distmax|baisse| mx |"
|
||||||
)
|
)
|
||||||
self.printLineLog()
|
self.printLineLog()
|
||||||
df = pd.DataFrame.from_dict(self.pairs, orient='index')
|
df = pd.DataFrame.from_dict(self.pairs, orient='index')
|
||||||
@@ -522,7 +530,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# f"|{round(last_candle['mid_smooth_24_deriv1'],3) or '-':>6}|{round(last_candle['mid_smooth_1h_deriv1'],3) or '-':>6}|{round(last_candle['mid_smooth_deriv1_1d'],3) or '-' :>6}|"
|
# f"|{round(last_candle['mid_smooth_24_deriv1'],3) or '-':>6}|{round(last_candle['mid_smooth_1h_deriv1'],3) or '-':>6}|{round(last_candle['mid_smooth_deriv1_1d'],3) or '-' :>6}|"
|
||||||
# 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(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"{round(val, 1) or '-' :>6}|"
|
||||||
f"{round(last_candle['sma5_deriv1_1h'], 4) or '-' :>7}|{round(last_candle['mid_smooth_1h_deriv1'], 4) or '-' :>7}|{dist_max:>7}"
|
f"{round(last_candle['mid_smooth_12'], 4) or '-' :>7}|{round(last_candle['mid_smooth_12_deriv1'], 4) or '-' :>7}|{dist_max:>7}|{round(self.pairs[pair]['baisse'], 3):>7}|{round(self.pairs[pair]['mx'], 4):>7}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def printLineLog(self):
|
def printLineLog(self):
|
||||||
@@ -846,20 +854,20 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
dataframe.loc[
|
dataframe.loc[
|
||||||
(
|
(
|
||||||
# (dataframe['deriv2_1h'].shift(2) >= dataframe['deriv2_1h'].shift(1))
|
# (dataframe['mid_smooth_1h_deriv1'].shift(2) >= dataframe['mid_smooth_1h_deriv1'].shift(1))
|
||||||
# & (dataframe['deriv2_1h'].shift(1) <= dataframe['deriv2_1h'])
|
# & (dataframe['mid_smooth_1h_deriv1'].shift(1) <= dataframe['mid_smooth_1h_deriv1'])
|
||||||
# (dataframe['deriv1_1h'] >= -0.01)
|
|
||||||
# & (dataframe['deriv2_1h'] >= -0.00)
|
(dataframe['mid_smooth_1h_deriv1'].shift(2) >= dataframe['mid_smooth_1h_deriv1'].shift(1))
|
||||||
(dataframe['mid_smooth_3_deriv1'].shift(2) >= dataframe['mid_smooth_3_deriv1'].shift(1))
|
& (dataframe['mid_smooth_1h_deriv1'].shift(1) <= dataframe['mid_smooth_1h_deriv1'])
|
||||||
& (dataframe['mid_smooth_3_deriv1'].shift(1) <= dataframe['mid_smooth_3_deriv1'])
|
& (dataframe['close'] < dataframe['bb_middleband'])
|
||||||
#
|
|
||||||
#
|
|
||||||
# (dataframe['mid_smooth_1h_deriv1'] >= 0)
|
|
||||||
# & (dataframe['mid_smooth_1h_deriv1'] >= 0)
|
|
||||||
# & (dataframe['mid_smooth_1h_deriv1'].shift(1) <= 0)
|
|
||||||
# & (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_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['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['hapercent3'] * 100 < -0.2), dataframe['close'], np.nan)
|
dataframe['perte_02'] = np.where((dataframe['hapercent3'] * 100 < -0.2), dataframe['close'], np.nan)
|
||||||
|
|
||||||
@@ -1807,7 +1815,13 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
max_nb_trades = 0
|
max_nb_trades = 0
|
||||||
total_non_btc = 0
|
total_non_btc = 0
|
||||||
max_pair = ''
|
max_pair = ''
|
||||||
|
count_decrease = 0
|
||||||
for p in non_btc_pairs:
|
for p in non_btc_pairs:
|
||||||
|
# dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
|
||||||
|
# last_candle = dataframe.iloc[-1].squeeze()
|
||||||
|
# if last_candle['sma5_deriv1_1h'] < -0.5:
|
||||||
|
# count_decrease += 1
|
||||||
|
|
||||||
max_nb_trades = max(max_nb_trades, self.pairs[p]['count_of_buys'])
|
max_nb_trades = max(max_nb_trades, self.pairs[p]['count_of_buys'])
|
||||||
if (max_nb_trades == self.pairs[p]['count_of_buys'] and max_nb_trades > limit):
|
if (max_nb_trades == self.pairs[p]['count_of_buys'] and max_nb_trades > limit):
|
||||||
max_pair = p
|
max_pair = p
|
||||||
@@ -1815,6 +1829,18 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
pct_max = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3)
|
pct_max = round((last_candle['close'] - self.pairs[pair]['first_buy']) / self.pairs[pair]['first_buy'], 3)
|
||||||
|
|
||||||
|
# val = self.getProbaHausse(last_candle)
|
||||||
|
# if (val < 40):
|
||||||
|
# return False
|
||||||
|
|
||||||
|
# if count_decrease == len(non_btc_pairs):
|
||||||
|
# self.should_enter_trade_count += 1
|
||||||
|
# char="."
|
||||||
|
# print(f"should_enter_trade canceled all pairs decreased {'':{char}>{self.should_enter_trade_count}}")
|
||||||
|
# return False
|
||||||
|
|
||||||
|
self.should_enter_trade_count = 0
|
||||||
|
|
||||||
if max_pair != '':
|
if max_pair != '':
|
||||||
return max_pair == pair or pct_max < - 0.25
|
return max_pair == pair or pct_max < - 0.25
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user