remove old codes when we only can do partial entries

This commit is contained in:
Stefano Ariestasia 2023-09-07 18:05:46 +09:00
parent c5f26e72e1
commit 7ccff18437

View File

@ -532,40 +532,24 @@ class Telegram(RPCHandler):
cur_entry_amount = order["filled"] or order["amount"] cur_entry_amount = order["filled"] or order["amount"]
cur_entry_average = order["safe_price"] cur_entry_average = order["safe_price"]
lines.append(" ") lines.append(" ")
lines.append(f"*{wording} #{order_nr}:*")
if order_nr == 1: if order_nr == 1:
lines.append(f"*{wording} #{order_nr}:*")
lines.append( lines.append(
f"*Amount:* {cur_entry_amount:.8g} " f"*Amount:* {cur_entry_amount:.8g} "
f"({round_coin_value(order['cost'], quote_currency)})" f"({round_coin_value(order['cost'], quote_currency)})"
) )
lines.append(f"*Average Price:* {cur_entry_average:.8g}") lines.append(f"*Average Price:* {cur_entry_average:.8g}")
else: else:
sum_stake = 0
sum_amount = 0
for y in range(order_nr):
loc_order = filled_orders[y]
if loc_order['is_open'] is True:
# Skip open orders (e.g. stop orders)
continue
amount = loc_order["filled"] or loc_order["amount"]
sum_stake += amount * loc_order["safe_price"]
sum_amount += amount
prev_avg_price = sum_stake / sum_amount
# TODO: This calculation ignores fees. # TODO: This calculation ignores fees.
price_to_1st_entry = ((cur_entry_average - first_avg) / first_avg) price_to_1st_entry = ((cur_entry_average - first_avg) / first_avg)
minus_on_entry = 0
if prev_avg_price:
minus_on_entry = (cur_entry_average - prev_avg_price) / prev_avg_price
lines.append(f"*{wording} #{order_nr}:* at {minus_on_entry:.2%} avg Profit")
if is_open: if is_open:
lines.append("({})".format(dt_humanize(order["order_filled_date"], lines.append("({})".format(dt_humanize(order["order_filled_date"],
granularity=["day", "hour", "minute"]))) granularity=["day", "hour", "minute"])))
lines.append(f"*Amount:* {cur_entry_amount:.8g} " lines.append(f"*Amount:* {cur_entry_amount:.8g} "
f"({round_coin_value(order['cost'], quote_currency)})") f"({round_coin_value(order['cost'], quote_currency)})")
lines.append(f"*Average {wording} Price:* {cur_entry_average:.8g} " lines.append(f"*Average {wording} Price:* {cur_entry_average:.8g} "
f"({price_to_1st_entry:.2%} from 1st entry Rate)") f"({price_to_1st_entry:.2%} from 1st entry rate)")
lines.append(f"*Order filled:* {order['order_filled_date']}") lines.append(f"*Order Filled:* {order['order_filled_date']}")
lines_detail.append("\n".join(lines)) lines_detail.append("\n".join(lines))