Update telegram notifications to properly detect shorts

This commit is contained in:
Matthias
2022-03-04 19:42:29 +01:00
parent 9576fab621
commit 8943d42509
4 changed files with 9 additions and 7 deletions

View File

@@ -171,7 +171,7 @@ class RPC:
# calculate profit and send message to user
if trade.is_open:
try:
closing_side = "buy" if trade.is_short else "sell"
closing_side = trade.exit_side
current_rate = self._freqtrade.exchange.get_rate(
trade.pair, refresh=False, side=closing_side)
except (ExchangeError, PricingError):

View File

@@ -398,7 +398,7 @@ class Telegram(RPCHandler):
first_avg = filled_orders[0]["safe_price"]
for x, order in enumerate(filled_orders):
if order['ft_order_side'] != 'buy':
if not order['ft_is_entry']:
continue
cur_entry_datetime = arrow.get(order["order_filled_date"])
cur_entry_amount = order["amount"]
@@ -465,7 +465,7 @@ class Telegram(RPCHandler):
messages = []
for r in results:
r['open_date_hum'] = arrow.get(r['open_date']).humanize()
r['num_entries'] = len([o for o in r['orders'] if o['ft_order_side'] == 'buy'])
r['num_entries'] = len([o for o in r['orders'] if o['ft_is_entry']])
r['sell_reason'] = r.get('sell_reason', "")
lines = [
"*Trade ID:* `{trade_id}`" +