From 9f34f824af42610839717ce7c06b99181dd69a7b Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 19 Mar 2022 13:20:14 +0100 Subject: [PATCH] Fix hyperopt when using futures markets --- freqtrade/exchange/exchange.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 656557e78..108100222 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -22,7 +22,7 @@ from pandas import DataFrame from freqtrade.constants import (DEFAULT_AMOUNT_RESERVE_PERCENT, NON_OPEN_EXCHANGE_STATES, ListPairsWithTimeframes, PairWithTimeframe) from freqtrade.data.converter import ohlcv_to_dataframe, trades_dict_to_list -from freqtrade.enums import CandleType, MarginMode, TradingMode +from freqtrade.enums import OPTIMIZE_MODES, CandleType, MarginMode, TradingMode from freqtrade.exceptions import (DDosProtection, ExchangeError, InsufficientFundsError, InvalidOrderException, OperationalException, PricingError, RetryableOrderError, TemporaryError) @@ -47,8 +47,6 @@ http.cookies.Morsel._reserved["samesite"] = "SameSite" # type: ignore class Exchange: - _config: Dict = {} - # Parameters to add directly to buy/sell calls (like agreeing to trading agreement) _params: Dict = {} @@ -93,6 +91,7 @@ class Exchange: self._leverage_tiers: Dict[str, List[Dict]] = {} self.loop = asyncio.new_event_loop() asyncio.set_event_loop(self.loop) + self._config: Dict = {} self._config.update(config) @@ -2480,7 +2479,9 @@ class Exchange: :return: (maintenance margin ratio, maintenance amount) """ - if self.exchange_has('fetchLeverageTiers') or self.exchange_has('fetchMarketLeverageTiers'): + if (self._config.get('runmode') in OPTIMIZE_MODES + or self.exchange_has('fetchLeverageTiers') + or self.exchange_has('fetchMarketLeverageTiers')): if pair not in self._leverage_tiers: raise InvalidOrderException(