Add test for new /status telegram message

This commit is contained in:
Matthias
2022-02-03 19:41:45 +01:00
parent 29879bb415
commit 1e6362debf
5 changed files with 53 additions and 10 deletions

View File

@@ -213,8 +213,6 @@ class RPC:
order['type'], order['side'], order['remaining']
) if order else None,
))
cp_cfg = self._config
trade_dict['position_adjustment_enable'] = cp_cfg['position_adjustment_enable']
results.append(trade_dict)
return results

View File

@@ -391,8 +391,8 @@ class Telegram(RPCHandler):
sumA += (filled_trades[y]["amount"] * filled_trades[y]["average"])
sumB += filled_trades[y]["amount"]
prev_avg_price = sumA/sumB
price_to_1st_buy = (cur_buy_average - filled_trades[0]["average"]) \
/ filled_trades[0]["average"]
price_to_1st_buy = ((cur_buy_average - filled_trades[0]["average"])
/ filled_trades[0]["average"])
minus_on_buy = (cur_buy_average - prev_avg_price)/prev_avg_price
dur_buys = current_buy_datetime - arrow.get(filled_trades[x-1]["order_filled_date"])
days = dur_buys.days
@@ -433,13 +433,12 @@ class Telegram(RPCHandler):
trade_ids = [int(i) for i in context.args if i.isnumeric()]
results = self._rpc._rpc_trade_status(trade_ids=trade_ids)
position_adjust = self._config.get('position_adjustment_enable', False)
messages = []
for r in results:
r['open_date_hum'] = arrow.get(r['open_date']).humanize()
r['num_entries'] = len(r['filled_entry_orders'])
r['sell_reason'] = r.get('sell_reason', "")
r['position_adjustment_enable'] = r.get('position_adjustment_enable', False)
lines = [
"*Trade ID:* `{trade_id}` `(since {open_date_hum})`",
"*Current Pair:* {pair}",
@@ -448,8 +447,8 @@ class Telegram(RPCHandler):
"*Sell Reason:* `{sell_reason}`" if r['sell_reason'] else "",
]
if r['position_adjustment_enable']:
lines.append("*Number of Buy(s):* `{num_buys}`")
if position_adjust:
lines.append("*Number of Buy(s):* `{num_entries}`")
lines.extend([
"*Open Rate:* `{open_rate:.8f}`",