mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 04:03:55 +00:00
Improve resiliance by using non-exchange controlled order attributes.
This commit is contained in:
parent
b0396af4c4
commit
24e806f081
|
@ -1300,7 +1300,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||||
timedout = (order.status == 'open' and order.order_date_utc < timeout_threshold)
|
timedout = (order.status == 'open' and order.order_date_utc < timeout_threshold)
|
||||||
if timedout:
|
if timedout:
|
||||||
return True
|
return True
|
||||||
time_method = (self.check_exit_timeout if order.side == trade.exit_side
|
time_method = (self.check_exit_timeout if order.ft_order_side == trade.exit_side
|
||||||
else self.check_entry_timeout)
|
else self.check_entry_timeout)
|
||||||
|
|
||||||
return strategy_safe_wrapper(time_method,
|
return strategy_safe_wrapper(time_method,
|
||||||
|
|
|
@ -3011,8 +3011,8 @@ def test_manage_open_orders_exit_usercustom(
|
||||||
freqtrade.manage_open_orders()
|
freqtrade.manage_open_orders()
|
||||||
assert cancel_order_mock.call_count == 0
|
assert cancel_order_mock.call_count == 0
|
||||||
assert rpc_mock.call_count == 1
|
assert rpc_mock.call_count == 1
|
||||||
assert freqtrade.strategy.check_exit_timeout.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 == 0
|
assert freqtrade.strategy.check_entry_timeout.call_count == (1 if is_short else 0)
|
||||||
|
|
||||||
freqtrade.strategy.check_exit_timeout = MagicMock(side_effect=KeyError)
|
freqtrade.strategy.check_exit_timeout = MagicMock(side_effect=KeyError)
|
||||||
freqtrade.strategy.check_entry_timeout = MagicMock(side_effect=KeyError)
|
freqtrade.strategy.check_entry_timeout = MagicMock(side_effect=KeyError)
|
||||||
|
@ -3020,8 +3020,8 @@ def test_manage_open_orders_exit_usercustom(
|
||||||
freqtrade.manage_open_orders()
|
freqtrade.manage_open_orders()
|
||||||
assert cancel_order_mock.call_count == 0
|
assert cancel_order_mock.call_count == 0
|
||||||
assert rpc_mock.call_count == 1
|
assert rpc_mock.call_count == 1
|
||||||
assert freqtrade.strategy.check_exit_timeout.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 == 0
|
assert freqtrade.strategy.check_entry_timeout.call_count == (1 if is_short else 0)
|
||||||
|
|
||||||
# Return True - sells!
|
# Return True - sells!
|
||||||
freqtrade.strategy.check_exit_timeout = MagicMock(return_value=True)
|
freqtrade.strategy.check_exit_timeout = MagicMock(return_value=True)
|
||||||
|
@ -3029,8 +3029,8 @@ def test_manage_open_orders_exit_usercustom(
|
||||||
freqtrade.manage_open_orders()
|
freqtrade.manage_open_orders()
|
||||||
assert cancel_order_mock.call_count == 1
|
assert cancel_order_mock.call_count == 1
|
||||||
assert rpc_mock.call_count == 2
|
assert rpc_mock.call_count == 2
|
||||||
assert freqtrade.strategy.check_exit_timeout.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 == 0
|
assert freqtrade.strategy.check_entry_timeout.call_count == (1 if is_short else 0)
|
||||||
trade = Trade.session.scalars(select(Trade)).first()
|
trade = Trade.session.scalars(select(Trade)).first()
|
||||||
# cancelling didn't succeed - order-id remains open.
|
# cancelling didn't succeed - order-id remains open.
|
||||||
assert trade.open_order_id is not None
|
assert trade.open_order_id is not None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user