Add colors / change expectedProfit
This commit is contained in:
@@ -33,6 +33,14 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
|
|
||||||
|
# Couleurs ANSI de base
|
||||||
|
RED = "\033[31m"
|
||||||
|
GREEN = "\033[32m"
|
||||||
|
YELLOW = "\033[33m"
|
||||||
|
BLUE = "\033[34m"
|
||||||
|
MAGENTA = "\033[35m"
|
||||||
|
CYAN = "\033[36m"
|
||||||
|
RESET = "\033[0m"
|
||||||
|
|
||||||
def pprint_df(dframe):
|
def pprint_df(dframe):
|
||||||
print(tabulate(dframe, headers='keys', tablefmt='psql', showindex=False))
|
print(tabulate(dframe, headers='keys', tablefmt='psql', showindex=False))
|
||||||
@@ -54,6 +62,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
"2814": 0.12,
|
"2814": 0.12,
|
||||||
"7675": 0
|
"7675": 0
|
||||||
}
|
}
|
||||||
|
stakes = 50 # days
|
||||||
|
|
||||||
# Stoploss:
|
# Stoploss:
|
||||||
stoploss = -1 # 0.256
|
stoploss = -1 # 0.256
|
||||||
@@ -296,7 +305,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.log_trade(
|
self.log_trade(
|
||||||
last_candle=last_candle,
|
last_candle=last_candle,
|
||||||
date=current_time,
|
date=current_time,
|
||||||
action=("Buy" if allow_to_buy else "Canceled") + " " + str(minutes),
|
action=("🟩Buy" if allow_to_buy else "Canceled") + " " + str(minutes),
|
||||||
pair=pair,
|
pair=pair,
|
||||||
rate=rate,
|
rate=rate,
|
||||||
dispo=dispo,
|
dispo=dispo,
|
||||||
@@ -332,7 +341,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.log_trade(
|
self.log_trade(
|
||||||
last_candle=last_candle,
|
last_candle=last_candle,
|
||||||
date=current_time,
|
date=current_time,
|
||||||
action="Sell " + str(minutes),
|
action="🟥Sell " + str(minutes),
|
||||||
pair=pair,
|
pair=pair,
|
||||||
trade_type=exit_reason,
|
trade_type=exit_reason,
|
||||||
rate=last_candle['close'],
|
rate=last_candle['close'],
|
||||||
@@ -385,6 +394,9 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
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)
|
||||||
|
|
||||||
|
# if last_candle['sma20_deriv1_1d'] > 0 and last_candle['sma5_deriv1_1d'] > 0 and last_candle['mid_smooth_1h_deriv1'] > 0:
|
||||||
|
# return None
|
||||||
|
|
||||||
# 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):
|
||||||
@@ -465,8 +477,8 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
return
|
return
|
||||||
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':>5}| {'Stake':>5} |"
|
||||||
f"Tdc|{'val':>6}| smooth|smoodrv|Distmax|"
|
f"Tdc|{'val':>6}|Distmax|s201d|s5_1d|smt1h|smt2h|"
|
||||||
)
|
)
|
||||||
self.printLineLog()
|
self.printLineLog()
|
||||||
df = pd.DataFrame.from_dict(self.pairs, orient='index')
|
df = pd.DataFrame.from_dict(self.pairs, orient='index')
|
||||||
@@ -528,24 +540,31 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
pct60 = round(100 * self.getPct60D(pair, last_candle), 2)
|
pct60 = round(100 * self.getPct60D(pair, last_candle), 2)
|
||||||
|
|
||||||
|
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_smooth_1h = GREEN if last_candle['mid_smooth_1h_deriv1'] > 0 else RED
|
||||||
|
color_smooth2_1h = GREEN if last_candle['mid_smooth_1h_deriv2'] > 0 else RED
|
||||||
|
|
||||||
self.printLog(
|
self.printLog(
|
||||||
f"| {date:<16} | {action:<10} | {pair[0:3]:<3} | {trade_type or '-':<18} |{rate or '-':>9}| {dispo or '-':>6} "
|
f"| {date:<16} |{action:<10} | {pair[0:3]:<3} | {trade_type or '-':<18} |{rate or '-':>9}| {dispo or '-':>6} "
|
||||||
f"| {profit or '-':>8} | {pct_max or '-':>6} | {round(self.pairs[pair]['max_touch'], 2) or '-':>11} | {last_lost or '-':>12} "
|
f"| {color}{profit or '-':>8}{RESET} | {pct_max or '-':>6} | {round(self.pairs[pair]['max_touch'], 2) or '-':>11} | {last_lost or '-':>12} "
|
||||||
f"| {int(self.pairs[pair]['last_max']) or '-':>7} |{total_counts or '-':>4}|{stake or '-':>7}"
|
f"| {int(self.pairs[pair]['last_max']) or '-':>7} |{total_counts or '-':>5}|{stake or '-':>7}"
|
||||||
f"|{last_candle['tendency_12'] or '-':>3}|" # {last_candle['tendency_1h'] or '-':>3}|{last_candle['tendency_1d'] or '-':>3}"
|
f"|{last_candle['tendency_12'] or '-':>3}|" # {last_candle['tendency_1h'] or '-':>3}|{last_candle['tendency_1d'] or '-':>3}"
|
||||||
# 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['mid_smooth_12'], 4) or '-' :>7}|{round(last_candle['mid_smooth_12_deriv1'], 4) or '-' :>7}|{dist_max:>7}|{pct60:>7}"
|
f"{dist_max:>7}|{color_sma20}{round(last_candle['sma20_deriv1_1d'],2):>5}{RESET}|{color_sma5}{round(last_candle['sma5_deriv1_1d'],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}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def printLineLog(self):
|
def printLineLog(self):
|
||||||
# f"sum1h|sum1d|Tdc|Tdh|Tdd| drv1 |drv_1h|drv_1d|"
|
# f"sum1h|sum1d|Tdc|Tdh|Tdd| drv1 |drv_1h|drv_1d|"
|
||||||
self.printLog(
|
self.printLog(
|
||||||
f"+{'-' * 18}+{'-' * 12}+{'-' * 5}+{'-' * 20}+{'-' * 9}+{'-' * 8}+{'-' * 10}+{'-' * 8}+{'-' * 13}+{'-' * 14}+{'-' * 9}+{'-' * 4}+{'-' * 7}+"
|
f"+{'-' * 18}+{'-' * 12}+{'-' * 5}+{'-' * 20}+{'-' * 9}+{'-' * 8}+{'-' * 10}+{'-' * 8}+{'-' * 13}+{'-' * 14}+{'-' * 9}+{'-' * 5}+{'-' * 7}+"
|
||||||
f"{'-' * 3}"
|
f"{'-' * 3}"
|
||||||
# "+{'-' * 3}+{'-' * 3}
|
# "+{'-' * 3}+{'-' * 3}
|
||||||
f"+{'-' * 6}+{'-' * 7}+{'-' * 7}+{'-' * 7}+"
|
f"+{'-' * 6}+{'-' * 7}+{'-' * 5}+{'-' * 5}+{'-' * 5}+{'-' * 5}+"
|
||||||
)
|
)
|
||||||
|
|
||||||
def printLog(self, str):
|
def printLog(self, str):
|
||||||
@@ -674,9 +693,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
# self.calculeDerivees(informative, 'rsi')
|
# self.calculeDerivees(informative, 'rsi')
|
||||||
#
|
#
|
||||||
informative['sma5'] = talib.SMA(informative, timeperiod=5)
|
informative['sma5'] = talib.SMA(informative, timeperiod=5)
|
||||||
informative['sma14'] = talib.SMA(informative, timeperiod=14)
|
informative['sma20'] = talib.SMA(informative, timeperiod=20)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
# 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'])
|
||||||
|
|
||||||
@@ -1195,7 +1215,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
self.log_trade(
|
self.log_trade(
|
||||||
last_candle=last_candle,
|
last_candle=last_candle,
|
||||||
date=current_time,
|
date=current_time,
|
||||||
action="Loss -",
|
action="🟧 Loss -",
|
||||||
dispo=dispo,
|
dispo=dispo,
|
||||||
pair=trade.pair,
|
pair=trade.pair,
|
||||||
rate=current_rate,
|
rate=current_rate,
|
||||||
@@ -1333,7 +1353,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
count_of_buys = self.pairs[pair]['count_of_buys']
|
count_of_buys = self.pairs[pair]['count_of_buys']
|
||||||
pct_first = self.getPctFirstBuy(pair, last_candle)
|
pct_first = self.getPctFirstBuy(pair, last_candle)
|
||||||
|
|
||||||
expected_profit = max(0.004, abs(pct_first / 3)) # 0.004 + 0.002 * self.pairs[pair]['count_of_buys'] #min(0.01, first_max)
|
expected_profit = max(0.004, abs(pct_first / 10)) # 0.004 + 0.002 * self.pairs[pair]['count_of_buys'] #min(0.01, first_max)
|
||||||
|
|
||||||
# print(
|
# 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}")
|
# 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}")
|
||||||
@@ -1881,7 +1901,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
|
|||||||
|
|
||||||
self.should_enter_trade_count = 0
|
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:
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user