adding SL and SL percentage to telegram msg
This commit is contained in:
parent
941921dd0f
commit
0e5b0ebda6
@ -97,9 +97,13 @@ class RPC(object):
|
|||||||
current_rate = self._freqtrade.get_sell_rate(trade.pair, False)
|
current_rate = self._freqtrade.get_sell_rate(trade.pair, False)
|
||||||
except DependencyException:
|
except DependencyException:
|
||||||
current_rate = NAN
|
current_rate = NAN
|
||||||
|
|
||||||
current_profit = trade.calc_profit_percent(current_rate)
|
current_profit = trade.calc_profit_percent(current_rate)
|
||||||
fmt_close_profit = (f'{round(trade.close_profit * 100, 2):.2f}%'
|
fmt_close_profit = (f'{round(trade.close_profit * 100, 2):.2f}%'
|
||||||
if trade.close_profit else None)
|
if trade.close_profit else None)
|
||||||
|
sl_percentage = round(((trade.stop_loss - current_rate) / current_rate) * 100, 2)
|
||||||
|
txt_sl_percentage = f'{sl_percentage}%'
|
||||||
|
|
||||||
results.append(dict(
|
results.append(dict(
|
||||||
trade_id=trade.id,
|
trade_id=trade.id,
|
||||||
pair=trade.pair,
|
pair=trade.pair,
|
||||||
@ -110,8 +114,8 @@ class RPC(object):
|
|||||||
amount=round(trade.amount, 8),
|
amount=round(trade.amount, 8),
|
||||||
close_profit=fmt_close_profit,
|
close_profit=fmt_close_profit,
|
||||||
current_profit=round(current_profit * 100, 2),
|
current_profit=round(current_profit * 100, 2),
|
||||||
initial_stoploss=trade.initial_stop_loss,
|
stop_loss=trade.stop_loss,
|
||||||
stoploss=trade.stop_loss,
|
stop_loss_percentage=txt_sl_percentage,
|
||||||
open_order='({} {} rem={:.8f})'.format(
|
open_order='({} {} rem={:.8f})'.format(
|
||||||
order['type'], order['side'], order['remaining']
|
order['type'], order['side'], order['remaining']
|
||||||
) if order else None,
|
) if order else None,
|
||||||
|
@ -204,9 +204,10 @@ class Telegram(RPC):
|
|||||||
"*Current Rate:* `{current_rate:.8f}`",
|
"*Current Rate:* `{current_rate:.8f}`",
|
||||||
"*Close Profit:* `{close_profit}`" if r['close_profit'] else "",
|
"*Close Profit:* `{close_profit}`" if r['close_profit'] else "",
|
||||||
"*Current Profit:* `{current_profit:.2f}%`",
|
"*Current Profit:* `{current_profit:.2f}%`",
|
||||||
|
"*Stoploss:* `{stop_loss:.8f}` ({stop_loss_percentage})",
|
||||||
"*Open Order:* `{open_order}`" if r['open_order'] else "",
|
"*Open Order:* `{open_order}`" if r['open_order'] else "",
|
||||||
]
|
]
|
||||||
messages.append("\n".join(filter(None ,lines)).format(**r))
|
messages.append("\n".join(filter(None, lines)).format(**r))
|
||||||
|
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
self._send_msg(msg, bot=bot)
|
self._send_msg(msg, bot=bot)
|
||||||
|
@ -201,6 +201,8 @@ def test_status(default_conf, update, mocker, fee, ticker, markets) -> None:
|
|||||||
'amount': 90.99181074,
|
'amount': 90.99181074,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'current_profit': -0.59,
|
'current_profit': -0.59,
|
||||||
|
'stop_loss': 1.099e-05,
|
||||||
|
'stop_loss_percentage': '-2%',
|
||||||
'open_order': '(limit buy rem=0.00000000)'
|
'open_order': '(limit buy rem=0.00000000)'
|
||||||
}]),
|
}]),
|
||||||
_status_table=status_table,
|
_status_table=status_table,
|
||||||
|
Loading…
Reference in New Issue
Block a user