Improve final exit message
This commit is contained in:
@@ -1824,6 +1824,8 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
'fiat_currency': self.config.get('fiat_display_currency'),
|
'fiat_currency': self.config.get('fiat_display_currency'),
|
||||||
'sub_trade': sub_trade,
|
'sub_trade': sub_trade,
|
||||||
'cumulative_profit': trade.realized_profit,
|
'cumulative_profit': trade.realized_profit,
|
||||||
|
'final_profit_ratio': trade.close_profit if not trade.is_open else None,
|
||||||
|
'is_final_exit': trade.is_open is False,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Send the message
|
# Send the message
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ class RPCExitMsg(__RPCEntryExitMsgBase):
|
|||||||
close_date: datetime
|
close_date: datetime
|
||||||
# current_rate: Optional[float]
|
# current_rate: Optional[float]
|
||||||
order_rate: Optional[float]
|
order_rate: Optional[float]
|
||||||
|
final_profit_ratio: Optional[float]
|
||||||
|
is_final_exit: bool
|
||||||
|
|
||||||
|
|
||||||
class RPCExitCancelMsg(__RPCEntryExitMsgBase):
|
class RPCExitCancelMsg(__RPCEntryExitMsgBase):
|
||||||
|
|||||||
@@ -373,21 +373,29 @@ class Telegram(RPCHandler):
|
|||||||
f"{msg['profit_extra']})")
|
f"{msg['profit_extra']})")
|
||||||
|
|
||||||
is_fill = msg['type'] == RPCMessageType.EXIT_FILL
|
is_fill = msg['type'] == RPCMessageType.EXIT_FILL
|
||||||
|
is_final_exit = msg.get('is_final_exit', False)
|
||||||
is_sub_trade = msg.get('sub_trade')
|
is_sub_trade = msg.get('sub_trade')
|
||||||
is_sub_profit = msg['profit_amount'] != msg.get('cumulative_profit')
|
is_sub_profit = msg['profit_amount'] != msg.get('cumulative_profit')
|
||||||
profit_prefix = ('Sub ' if is_sub_profit else 'Cumulative ') if is_sub_trade else ''
|
profit_prefix = ('Sub ' if is_sub_profit else 'Cumulative ') if is_sub_trade else ''
|
||||||
cp_extra = ''
|
cp_extra = ''
|
||||||
exit_wording = 'Exited' if is_fill else 'Exiting'
|
exit_wording = 'Exited' if is_fill else 'Exiting'
|
||||||
if is_sub_profit and is_sub_trade:
|
if (is_sub_profit and is_sub_trade) or is_final_exit:
|
||||||
if self._rpc._fiat_converter:
|
if self._rpc._fiat_converter:
|
||||||
cp_fiat = self._rpc._fiat_converter.convert_amount(
|
cp_fiat = self._rpc._fiat_converter.convert_amount(
|
||||||
msg['cumulative_profit'], msg['stake_currency'], msg['fiat_currency'])
|
msg['cumulative_profit'], msg['stake_currency'], msg['fiat_currency'])
|
||||||
cp_extra = f" / {cp_fiat:.3f} {msg['fiat_currency']}"
|
cp_extra = f" / {cp_fiat:.3f} {msg['fiat_currency']}"
|
||||||
exit_wording = f"Partially {exit_wording.lower()}"
|
if is_final_exit:
|
||||||
cp_extra = (
|
profit_prefix = 'Sub '
|
||||||
f"*Cumulative Profit:* (`{msg['cumulative_profit']:.8f} "
|
cp_extra = (
|
||||||
f"{msg['stake_currency']}{cp_extra}`)\n"
|
f"*Final Profit:* `{msg['final_profit_ratio']:.2%} "
|
||||||
)
|
f"({msg['cumulative_profit']:.8f} {msg['stake_currency']}{cp_extra})`\n"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
exit_wording = f"Partially {exit_wording.lower()}"
|
||||||
|
cp_extra = (
|
||||||
|
f"*Cumulative Profit:* `({msg['cumulative_profit']:.8f} "
|
||||||
|
f"{msg['stake_currency']}{cp_extra})`\n"
|
||||||
|
)
|
||||||
|
|
||||||
message = (
|
message = (
|
||||||
f"{msg['emoji']} *{self._exchange_from_msg(msg)}:* "
|
f"{msg['emoji']} *{self._exchange_from_msg(msg)}:* "
|
||||||
|
|||||||
Reference in New Issue
Block a user