Fix some tests and comments

This commit is contained in:
Matthias
2024-01-19 06:48:32 +01:00
parent dc9c4da95e
commit 9f3c6f2dcc
+4 -8
View File
@@ -1198,8 +1198,7 @@ def test_handle_stoploss_on_exchange(mocker, default_conf_usdt, fee, caplog, is_
assert trade.amount == amount_before assert trade.amount == amount_before
# Fourth case: when stoploss is set and it is hit # Fourth case: when stoploss is set and it is hit
# should unset stoploss_order_id and return true # should return true as a trade actually happened
# as a trade actually happened
caplog.clear() caplog.clear()
stop_order_dict.update({'id': "103_1"}) stop_order_dict.update({'id': "103_1"})
@@ -1871,7 +1870,6 @@ def test_stoploss_on_exchange_price_rounding(
price_to_precision=price_mock, price_to_precision=price_mock,
) )
freqtrade = get_patched_freqtradebot(mocker, default_conf_usdt) freqtrade = get_patched_freqtradebot(mocker, default_conf_usdt)
open_trade_usdt.stoploss_order_id = '13434334'
open_trade_usdt.stop_loss = 222.55 open_trade_usdt.stop_loss = 222.55
freqtrade.handle_trailing_stoploss_on_exchange(open_trade_usdt, {}) freqtrade.handle_trailing_stoploss_on_exchange(open_trade_usdt, {})
@@ -2078,7 +2076,7 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee, limit_orde
freqtrade.enter_positions() freqtrade.enter_positions()
trade = Trade.session.scalars(select(Trade)).first() trade = Trade.session.scalars(select(Trade)).first()
trade.is_open = True trade.is_open = True
trade.stoploss_order_id = '100'
trade.stoploss_last_update = dt_now() trade.stoploss_last_update = dt_now()
trade.orders.append( trade.orders.append(
Order( Order(
@@ -4194,8 +4192,7 @@ def test_may_execute_trade_exit_after_stoploss_on_exchange_hit(
assert not trade.has_open_orders assert not trade.has_open_orders
# Assuming stoploss on exchange is hit # Assuming stoploss on exchange is hit
# stoploss_order_id should become None # trade should be sold at the price of stoploss, with exit_reaeon STOPLOSS_ON_EXCHANGE
# and trade should be sold at the price of stoploss
stoploss_executed = MagicMock(return_value={ stoploss_executed = MagicMock(return_value={
"id": "123", "id": "123",
"timestamp": 1542707426845, "timestamp": 1542707426845,
@@ -5721,7 +5718,6 @@ def test_handle_insufficient_funds(mocker, default_conf_usdt, fee, is_short, cap
def reset_open_orders(trade): def reset_open_orders(trade):
trade.stoploss_order_id = None
trade.is_short = is_short trade.is_short = is_short
create_mock_trades(fee, is_short=is_short) create_mock_trades(fee, is_short=is_short)
@@ -5779,7 +5775,7 @@ def test_handle_insufficient_funds(mocker, default_conf_usdt, fee, is_short, cap
assert log_has_re(r"Trying to refind Order\(.*", caplog) assert log_has_re(r"Trying to refind Order\(.*", caplog)
assert mock_fo.call_count == 1 assert mock_fo.call_count == 1
assert mock_uts.call_count == 2 assert mock_uts.call_count == 2
# stoploss_order_id is "refound" and added to the trade # stoploss order is "refound" and added to the trade
assert not trade.has_open_orders assert not trade.has_open_orders
assert trade.has_open_sl_orders is True assert trade.has_open_sl_orders is True