fix tests related to position adjustment

This commit is contained in:
Axel-CH 2024-10-07 15:31:26 -04:00
parent 3d6e186b30
commit c01996d1d1
2 changed files with 3 additions and 3 deletions

View File

@ -5942,13 +5942,13 @@ def test_check_and_call_adjust_trade_position(mocker, default_conf_usdt, fee, ca
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=(10, "aaaa")) freqtrade.strategy.adjust_trade_position = MagicMock(return_value=(10, "aaaa"))
freqtrade.process_open_trade_positions() freqtrade.process_open_trade_positions()
assert log_has_re(r"Max adjustment entries for .* has been reached\.", caplog) assert log_has_re(r"Max adjustment entries for .* has been reached\.", caplog)
assert freqtrade.strategy.adjust_trade_position.call_count == 1 assert freqtrade.strategy.adjust_trade_position.call_count == 3
caplog.clear() caplog.clear()
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=(-0.0005, "partial_exit_c")) freqtrade.strategy.adjust_trade_position = MagicMock(return_value=(-0.0005, "partial_exit_c"))
freqtrade.process_open_trade_positions() freqtrade.process_open_trade_positions()
assert log_has_re(r"LIMIT_SELL has been fulfilled.*", caplog) assert log_has_re(r"LIMIT_SELL has been fulfilled.*", caplog)
assert freqtrade.strategy.adjust_trade_position.call_count == 1 assert freqtrade.strategy.adjust_trade_position.call_count == 3
trade = Trade.get_trades(trade_filter=[Trade.id == 5]).first() trade = Trade.get_trades(trade_filter=[Trade.id == 5]).first()
assert trade.orders[-1].ft_order_tag == "partial_exit_c" assert trade.orders[-1].ft_order_tag == "partial_exit_c"
assert trade.is_open assert trade.is_open

View File

@ -436,7 +436,7 @@ def test_dca_order_adjust(default_conf_usdt, ticker_usdt, leverage, fee, mocker)
# Replace new order with diff. order at a lower price # Replace new order with diff. order at a lower price
freqtrade.strategy.adjust_entry_price = MagicMock(return_value=1.95) freqtrade.strategy.adjust_entry_price = MagicMock(return_value=1.95)
freqtrade.strategy.adjust_trade_position = MagicMock(return_value=None)
freqtrade.process() freqtrade.process()
trade = Trade.get_trades().first() trade = Trade.get_trades().first()
assert len(trade.orders) == 4 assert len(trade.orders) == 4