Rename update_open_trades to clarify it's only called at startup

This commit is contained in:
Matthias 2021-09-30 07:24:16 +02:00
parent bd27993e79
commit 5f23af5802
2 changed files with 6 additions and 6 deletions

View File

@ -139,7 +139,7 @@ class FreqtradeBot(LoggingMixin):
# Only update open orders on startup
# This will update the database after the initial migration
self.update_open_orders()
self.startup_update_open_orders()
def process(self) -> None:
"""
@ -237,7 +237,7 @@ class FreqtradeBot(LoggingMixin):
open_trades = len(Trade.get_open_trades())
return max(0, self.config['max_open_trades'] - open_trades)
def update_open_orders(self):
def startup_update_open_orders(self):
"""
Updates open orders based on order list kept in the database.
Mainly updates the state of orders - but may also close trades

View File

@ -4033,16 +4033,16 @@ def test_check_for_open_trades(mocker, default_conf, fee):
@pytest.mark.usefixtures("init_persistence")
def test_update_open_orders(mocker, default_conf, fee, caplog):
def test_startup_update_open_orders(mocker, default_conf, fee, caplog):
freqtrade = get_patched_freqtradebot(mocker, default_conf)
create_mock_trades(fee)
freqtrade.update_open_orders()
freqtrade.startup_update_open_orders()
assert not log_has_re(r"Error updating Order .*", caplog)
caplog.clear()
freqtrade.config['dry_run'] = False
freqtrade.update_open_orders()
freqtrade.startup_update_open_orders()
assert log_has_re(r"Error updating Order .*", caplog)
caplog.clear()
@ -4053,7 +4053,7 @@ def test_update_open_orders(mocker, default_conf, fee, caplog):
'status': 'closed',
})
mocker.patch('freqtrade.exchange.Exchange.fetch_order', return_value=matching_buy_order)
freqtrade.update_open_orders()
freqtrade.startup_update_open_orders()
# Only stoploss and sell orders are kept open
assert len(Order.get_open_orders()) == 2