mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
feat: prevent freqAI startup on exchanges without history
closes #10570
This commit is contained in:
parent
235d38752c
commit
01b7ad4a3f
|
@ -337,6 +337,7 @@ class Exchange:
|
|||
self.validate_pricing(config["exit_pricing"])
|
||||
self.validate_pricing(config["entry_pricing"])
|
||||
self.validate_orderflow(config["exchange"])
|
||||
self.validate_freqai(config)
|
||||
|
||||
def _init_ccxt(
|
||||
self, exchange_config: Dict[str, Any], sync: bool, ccxt_kwargs: Dict[str, Any]
|
||||
|
@ -826,6 +827,13 @@ class Exchange:
|
|||
f"Trade data not available for {self.name}. Can't use orderflow feature."
|
||||
)
|
||||
|
||||
def validate_freqai(self, config: Config) -> None:
|
||||
freqai_enabled = config.get("freqai", {}).get("enabled", False)
|
||||
if freqai_enabled and not self._ft_has["ohlcv_has_history"]:
|
||||
raise ConfigurationError(
|
||||
f"Historic OHLCV data not available for {self.name}. Can't use freqAI."
|
||||
)
|
||||
|
||||
def validate_required_startup_candles(self, startup_candles: int, timeframe: str) -> int:
|
||||
"""
|
||||
Checks if required startup_candles is more than ohlcv_candle_limit().
|
||||
|
|
|
@ -342,6 +342,27 @@ def test_validate_orderflow(default_conf, mocker, caplog):
|
|||
ex.validate_orderflow({"use_public_trades": True})
|
||||
|
||||
|
||||
def test_validate_freqai_compat(default_conf, mocker, caplog):
|
||||
caplog.set_level(logging.INFO)
|
||||
# Test kraken - as it doesn't support historic trades data.
|
||||
ex = get_patched_exchange(mocker, default_conf, exchange="kraken")
|
||||
mocker.patch(f"{EXMS}.exchange_has", return_value=True)
|
||||
|
||||
default_conf["freqai"] = {"enabled": False}
|
||||
ex.validate_freqai(default_conf)
|
||||
|
||||
default_conf["freqai"] = {"enabled": True}
|
||||
with pytest.raises(ConfigurationError, match=r"Historic OHLCV data not available for.*"):
|
||||
ex.validate_freqai(default_conf)
|
||||
|
||||
# Binance supports historic data.
|
||||
ex = get_patched_exchange(mocker, default_conf, exchange="binance")
|
||||
default_conf["freqai"] = {"enabled": True}
|
||||
ex.validate_freqai(default_conf)
|
||||
default_conf["freqai"] = {"enabled": False}
|
||||
ex.validate_freqai(default_conf)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"price,precision_mode,precision,expected",
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue
Block a user