mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Fix exit_timeout test
This commit is contained in:
parent
c7683a7b61
commit
b49a118764
|
@ -2976,11 +2976,12 @@ def test_manage_open_orders_exit_usercustom(
|
|||
) -> None:
|
||||
default_conf_usdt["unfilledtimeout"] = {"entry": 1440, "exit": 1440, "exit_timeout_count": 1}
|
||||
open_trade_usdt.open_order_id = limit_sell_order_old['id']
|
||||
order = Order.parse_from_ccxt_object(limit_sell_order_old, 'mocked', 'sell')
|
||||
open_trade_usdt.orders[0] = order
|
||||
if is_short:
|
||||
limit_sell_order_old['side'] = 'buy'
|
||||
open_trade_usdt.is_short = is_short
|
||||
open_exit_order = Order.parse_from_ccxt_object(limit_sell_order_old, 'mocked',
|
||||
'buy' if is_short else 'sell')
|
||||
open_trade_usdt.orders[-1] = open_exit_order
|
||||
|
||||
rpc_mock = patch_RPCManager(mocker)
|
||||
cancel_order_mock = MagicMock()
|
||||
|
@ -3011,8 +3012,8 @@ def test_manage_open_orders_exit_usercustom(
|
|||
freqtrade.manage_open_orders()
|
||||
assert cancel_order_mock.call_count == 0
|
||||
assert rpc_mock.call_count == 1
|
||||
assert freqtrade.strategy.check_exit_timeout.call_count == (0 if is_short else 1)
|
||||
assert freqtrade.strategy.check_entry_timeout.call_count == (1 if is_short else 0)
|
||||
assert freqtrade.strategy.check_exit_timeout.call_count == 1
|
||||
assert freqtrade.strategy.check_entry_timeout.call_count == 0
|
||||
|
||||
freqtrade.strategy.check_exit_timeout = MagicMock(side_effect=KeyError)
|
||||
freqtrade.strategy.check_entry_timeout = MagicMock(side_effect=KeyError)
|
||||
|
@ -3020,8 +3021,8 @@ def test_manage_open_orders_exit_usercustom(
|
|||
freqtrade.manage_open_orders()
|
||||
assert cancel_order_mock.call_count == 0
|
||||
assert rpc_mock.call_count == 1
|
||||
assert freqtrade.strategy.check_exit_timeout.call_count == (0 if is_short else 1)
|
||||
assert freqtrade.strategy.check_entry_timeout.call_count == (1 if is_short else 0)
|
||||
assert freqtrade.strategy.check_exit_timeout.call_count == 1
|
||||
assert freqtrade.strategy.check_entry_timeout.call_count == 0
|
||||
|
||||
# Return True - sells!
|
||||
freqtrade.strategy.check_exit_timeout = MagicMock(return_value=True)
|
||||
|
@ -3029,8 +3030,8 @@ def test_manage_open_orders_exit_usercustom(
|
|||
freqtrade.manage_open_orders()
|
||||
assert cancel_order_mock.call_count == 1
|
||||
assert rpc_mock.call_count == 2
|
||||
assert freqtrade.strategy.check_exit_timeout.call_count == (0 if is_short else 1)
|
||||
assert freqtrade.strategy.check_entry_timeout.call_count == (1 if is_short else 0)
|
||||
assert freqtrade.strategy.check_exit_timeout.call_count == 1
|
||||
assert freqtrade.strategy.check_entry_timeout.call_count == 0
|
||||
trade = Trade.session.scalars(select(Trade)).first()
|
||||
# cancelling didn't succeed - order-id remains open.
|
||||
assert trade.open_order_id is not None
|
||||
|
|
Loading…
Reference in New Issue
Block a user