Extract sell_smoij logic into it's own function

This commit is contained in:
Matthias
2020-06-06 13:32:06 +02:00
parent f34bcc5fd3
commit b2316cdd00
2 changed files with 46 additions and 18 deletions

View File

@@ -154,25 +154,16 @@ class Telegram(RPC):
microsecond=0) - msg['open_date'].replace(microsecond=0)
msg['duration_min'] = msg['duration'].total_seconds() / 60
if float(msg['profit_percent']) >= 5.0:
message = ("\N{ROCKET} *{exchange}:* Selling {pair}\n").format(**msg)
msg['emoij'] = self._get_sell_emoij(msg)
elif float(msg['profit_percent']) >= 0.0:
message = "\N{EIGHT SPOKED ASTERISK} *{exchange}:* Selling {pair}\n"
elif msg['sell_reason'] == "stop_loss":
message = ("\N{WARNING SIGN} *{exchange}:* Selling {pair}\n").format(**msg)
else:
message = ("\N{CROSS MARK} *{exchange}:* Selling {pair}\n").format(**msg)
message += ("*Amount:* `{amount:.8f}`\n"
"*Open Rate:* `{open_rate:.8f}`\n"
"*Current Rate:* `{current_rate:.8f}`\n"
"*Close Rate:* `{limit:.8f}`\n"
"*Sell Reason:* `{sell_reason}`\n"
"*Duration:* `{duration} ({duration_min:.1f} min)`\n"
"*Profit:* `{profit_percent:.2f}%`").format(**msg)
message = ("{emoij} *{exchange}:* Selling {pair}\n"
"*Amount:* `{amount:.8f}`\n"
"*Open Rate:* `{open_rate:.8f}`\n"
"*Current Rate:* `{current_rate:.8f}`\n"
"*Close Rate:* `{limit:.8f}`\n"
"*Sell Reason:* `{sell_reason}`\n"
"*Duration:* `{duration} ({duration_min:.1f} min)`\n"
"*Profit:* `{profit_percent:.2f}%`").format(**msg)
# Check if all sell properties are available.
# This might not be the case if the message origin is triggered by /forcesell
@@ -201,6 +192,20 @@ class Telegram(RPC):
self._send_msg(message)
def _get_sell_emoij(self, msg):
"""
Get emoji for sell-side
"""
if float(msg['profit_percent']) >= 5.0:
return "\N{ROCKET}"
elif float(msg['profit_percent']) >= 0.0:
return "\N{EIGHT SPOKED ASTERISK}"
elif msg['sell_reason'] == "stop_loss":
return"\N{WARNING SIGN}"
else:
return "\N{CROSS MARK}"
@authorized_only
def _status(self, update: Update, context: CallbackContext) -> None:
"""