Test trade entry / exit is called correctly
This commit is contained in:
parent
84329ad2ca
commit
6d6e7196f4
@ -79,10 +79,15 @@ def test_may_execute_sell_stoploss_on_exchange_multi(default_conf, ticker, fee,
|
|||||||
freqtrade.strategy.order_types['stoploss_on_exchange'] = True
|
freqtrade.strategy.order_types['stoploss_on_exchange'] = True
|
||||||
# Switch ordertype to market to close trade immediately
|
# Switch ordertype to market to close trade immediately
|
||||||
freqtrade.strategy.order_types['sell'] = 'market'
|
freqtrade.strategy.order_types['sell'] = 'market'
|
||||||
|
freqtrade.strategy.confirm_trade_entry = MagicMock(return_value=True)
|
||||||
|
freqtrade.strategy.confirm_trade_exit = MagicMock(return_value=True)
|
||||||
patch_get_signal(freqtrade)
|
patch_get_signal(freqtrade)
|
||||||
|
|
||||||
# Create some test data
|
# Create some test data
|
||||||
freqtrade.enter_positions()
|
freqtrade.enter_positions()
|
||||||
|
assert freqtrade.strategy.confirm_trade_entry.call_count == 3
|
||||||
|
freqtrade.strategy.confirm_trade_entry.reset_mock()
|
||||||
|
assert freqtrade.strategy.confirm_trade_exit.call_count == 0
|
||||||
wallets_mock.reset_mock()
|
wallets_mock.reset_mock()
|
||||||
Trade.session = MagicMock()
|
Trade.session = MagicMock()
|
||||||
|
|
||||||
@ -95,6 +100,9 @@ def test_may_execute_sell_stoploss_on_exchange_multi(default_conf, ticker, fee,
|
|||||||
n = freqtrade.exit_positions(trades)
|
n = freqtrade.exit_positions(trades)
|
||||||
assert n == 2
|
assert n == 2
|
||||||
assert should_sell_mock.call_count == 2
|
assert should_sell_mock.call_count == 2
|
||||||
|
assert freqtrade.strategy.confirm_trade_entry.call_count == 0
|
||||||
|
assert freqtrade.strategy.confirm_trade_exit.call_count == 1
|
||||||
|
freqtrade.strategy.confirm_trade_exit.reset_mock()
|
||||||
|
|
||||||
# Only order for 3rd trade needs to be cancelled
|
# Only order for 3rd trade needs to be cancelled
|
||||||
assert cancel_order_mock.call_count == 1
|
assert cancel_order_mock.call_count == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user