Make _reload_markets() public
This commit is contained in:
parent
6744f8f052
commit
7d451638a8
@ -264,7 +264,7 @@ class Exchange:
|
|||||||
except ccxt.BaseError as e:
|
except ccxt.BaseError as e:
|
||||||
logger.warning('Unable to initialize markets. Reason: %s', e)
|
logger.warning('Unable to initialize markets. Reason: %s', e)
|
||||||
|
|
||||||
def _reload_markets(self) -> None:
|
def reload_markets(self) -> None:
|
||||||
"""Reload markets if refresh interval has passed """
|
"""Reload markets if refresh interval has passed """
|
||||||
# Check whether markets have to be reloaded
|
# Check whether markets have to be reloaded
|
||||||
if (self._last_markets_refresh > 0) and (
|
if (self._last_markets_refresh > 0) and (
|
||||||
|
@ -139,8 +139,8 @@ class FreqtradeBot:
|
|||||||
:return: True if one or more trades has been created or closed, False otherwise
|
:return: True if one or more trades has been created or closed, False otherwise
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Check whether markets have to be reloaded
|
# Check whether markets have to be reloaded and reload them when it's needed
|
||||||
self.exchange._reload_markets()
|
self.exchange.reload_markets()
|
||||||
|
|
||||||
# Query trades from persistence layer
|
# Query trades from persistence layer
|
||||||
trades = Trade.get_open_trades()
|
trades = Trade.get_open_trades()
|
||||||
|
@ -337,7 +337,7 @@ def test__load_markets(default_conf, mocker, caplog):
|
|||||||
assert ex.markets == expected_return
|
assert ex.markets == expected_return
|
||||||
|
|
||||||
|
|
||||||
def test__reload_markets(default_conf, mocker, caplog):
|
def test_reload_markets(default_conf, mocker, caplog):
|
||||||
caplog.set_level(logging.DEBUG)
|
caplog.set_level(logging.DEBUG)
|
||||||
initial_markets = {'ETH/BTC': {}}
|
initial_markets = {'ETH/BTC': {}}
|
||||||
|
|
||||||
@ -356,17 +356,17 @@ def test__reload_markets(default_conf, mocker, caplog):
|
|||||||
assert exchange.markets == initial_markets
|
assert exchange.markets == initial_markets
|
||||||
|
|
||||||
# less than 10 minutes have passed, no reload
|
# less than 10 minutes have passed, no reload
|
||||||
exchange._reload_markets()
|
exchange.reload_markets()
|
||||||
assert exchange.markets == initial_markets
|
assert exchange.markets == initial_markets
|
||||||
|
|
||||||
# more than 10 minutes have passed, reload is executed
|
# more than 10 minutes have passed, reload is executed
|
||||||
exchange._last_markets_refresh = arrow.utcnow().timestamp - 15 * 60
|
exchange._last_markets_refresh = arrow.utcnow().timestamp - 15 * 60
|
||||||
exchange._reload_markets()
|
exchange.reload_markets()
|
||||||
assert exchange.markets == updated_markets
|
assert exchange.markets == updated_markets
|
||||||
assert log_has('Performing scheduled market reload..', caplog)
|
assert log_has('Performing scheduled market reload..', caplog)
|
||||||
|
|
||||||
|
|
||||||
def test__reload_markets_exception(default_conf, mocker, caplog):
|
def test_reload_markets_exception(default_conf, mocker, caplog):
|
||||||
caplog.set_level(logging.DEBUG)
|
caplog.set_level(logging.DEBUG)
|
||||||
|
|
||||||
api_mock = MagicMock()
|
api_mock = MagicMock()
|
||||||
@ -375,7 +375,7 @@ def test__reload_markets_exception(default_conf, mocker, caplog):
|
|||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
|
exchange = get_patched_exchange(mocker, default_conf, api_mock, id="binance")
|
||||||
|
|
||||||
# less than 10 minutes have passed, no reload
|
# less than 10 minutes have passed, no reload
|
||||||
exchange._reload_markets()
|
exchange.reload_markets()
|
||||||
assert exchange._last_markets_refresh == 0
|
assert exchange._last_markets_refresh == 0
|
||||||
assert log_has_re(r"Could not reload markets.*", caplog)
|
assert log_has_re(r"Could not reload markets.*", caplog)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user