Remove further tech. debt introduced in this PR.

This commit is contained in:
Matthias 2022-07-24 11:08:32 +02:00
parent d1cdb8a30c
commit 44fba79531
3 changed files with 16 additions and 7 deletions

View File

@ -1399,6 +1399,10 @@ class FreqtradeBot(LoggingMixin):
cancelled = False cancelled = False
order_obj = trade.select_order_by_order_id(order['id']) order_obj = trade.select_order_by_order_id(order['id'])
if not order_obj:
raise DependencyException(
f"Order_obj not found for {order['id']}. This should not have happened.")
sub_trade = order_obj.amount != trade.amount sub_trade = order_obj.amount != trade.amount
self._notify_exit_cancel( self._notify_exit_cancel(
trade, trade,
@ -1590,10 +1594,8 @@ class FreqtradeBot(LoggingMixin):
'stake_currency': self.config['stake_currency'], 'stake_currency': self.config['stake_currency'],
'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,
} }
if sub_trade:
# TODO: this should not be conditional.
msg['cumulative_profit'] = trade.realized_profit
# Send the message # Send the message
self.rpc.send_msg(msg) self.rpc.send_msg(msg)

View File

@ -961,6 +961,7 @@ def test_telegram_forceexit_handle(default_conf, update, ticker, fee,
'close_rate': ANY, 'close_rate': ANY,
'stake_amount': 0.0009999999999054, 'stake_amount': 0.0009999999999054,
'sub_trade': False, 'sub_trade': False,
'cumulative_profit': 0.0,
} == last_msg } == last_msg
@ -1031,7 +1032,8 @@ def test_telegram_force_exit_down_handle(default_conf, update, ticker, fee,
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'stake_amount': 0.0009999999999054, 'stake_amount': 0.0009999999999054,
'sub_trade': False 'sub_trade': False,
'cumulative_profit': 0.0,
} == last_msg } == last_msg
@ -1092,7 +1094,8 @@ def test_forceexit_all_handle(default_conf, update, ticker, fee, mocker) -> None
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'stake_amount': 0.0009999999999054, 'stake_amount': 0.0009999999999054,
'sub_trade': False 'sub_trade': False,
'cumulative_profit': 0.0,
} == msg } == msg

View File

@ -3249,6 +3249,7 @@ def test_execute_trade_exit_up(default_conf_usdt, ticker_usdt, fee, ticker_usdt_
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'sub_trade': False, 'sub_trade': False,
'cumulative_profit': 0.0,
'stake_amount': pytest.approx(60), 'stake_amount': pytest.approx(60),
} == last_msg } == last_msg
@ -3311,6 +3312,7 @@ def test_execute_trade_exit_down(default_conf_usdt, ticker_usdt, fee, ticker_usd
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'sub_trade': False, 'sub_trade': False,
'cumulative_profit': 0.0,
'stake_amount': pytest.approx(60), 'stake_amount': pytest.approx(60),
} == last_msg } == last_msg
@ -3394,6 +3396,7 @@ def test_execute_trade_exit_custom_exit_price(
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'sub_trade': False, 'sub_trade': False,
'cumulative_profit': 0.0,
'stake_amount': pytest.approx(60), 'stake_amount': pytest.approx(60),
} == last_msg } == last_msg
@ -3464,6 +3467,7 @@ def test_execute_trade_exit_down_stoploss_on_exchange_dry_run(
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'sub_trade': False, 'sub_trade': False,
'cumulative_profit': 0.0,
'stake_amount': pytest.approx(60), 'stake_amount': pytest.approx(60),
} == last_msg } == last_msg
@ -3725,6 +3729,7 @@ def test_execute_trade_exit_market_order(
'close_date': ANY, 'close_date': ANY,
'close_rate': ANY, 'close_rate': ANY,
'sub_trade': False, 'sub_trade': False,
'cumulative_profit': 0.0,
'stake_amount': pytest.approx(60), 'stake_amount': pytest.approx(60),
} == last_msg } == last_msg
@ -4719,9 +4724,8 @@ def test_order_book_exit_pricing(
return_value={'bids': [[]], 'asks': [[]]}) return_value={'bids': [[]], 'asks': [[]]})
with pytest.raises(PricingError): with pytest.raises(PricingError):
freqtrade.handle_trade(trade) freqtrade.handle_trade(trade)
pair = 'ETH/USDT'
assert log_has_re( assert log_has_re(
rf"{pair} - Exit Price at location 1 from orderbook could not be determined\..*", r"ETH/USDT - Exit Price at location 1 from orderbook could not be determined\..*",
caplog) caplog)