mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-16 12:51:14 +00:00
More usages for ConfigurationError
This commit is contained in:
@@ -9,7 +9,7 @@ from freqtrade.configuration import setup_utils_configuration
|
|||||||
from freqtrade.configuration.directory_operations import copy_sample_files, create_userdata_dir
|
from freqtrade.configuration.directory_operations import copy_sample_files, create_userdata_dir
|
||||||
from freqtrade.constants import USERPATH_STRATEGIES
|
from freqtrade.constants import USERPATH_STRATEGIES
|
||||||
from freqtrade.enums import RunMode
|
from freqtrade.enums import RunMode
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import ConfigurationError, OperationalException
|
||||||
from freqtrade.util import render_template, render_template_with_fallback
|
from freqtrade.util import render_template, render_template_with_fallback
|
||||||
|
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ def start_new_strategy(args: Dict[str, Any]) -> None:
|
|||||||
deploy_new_strategy(args['strategy'], new_path, args['template'])
|
deploy_new_strategy(args['strategy'], new_path, args['template'])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise OperationalException("`new-strategy` requires --strategy to be set.")
|
raise ConfigurationError("`new-strategy` requires --strategy to be set.")
|
||||||
|
|
||||||
|
|
||||||
def clean_ui_subdir(directory: Path):
|
def clean_ui_subdir(directory: Path):
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import numpy as np
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
from freqtrade.constants import LAST_BT_RESULT_FN, IntOrInf
|
from freqtrade.constants import LAST_BT_RESULT_FN, IntOrInf
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import ConfigurationError, OperationalException
|
||||||
from freqtrade.misc import file_dump_json, json_load
|
from freqtrade.misc import file_dump_json, json_load
|
||||||
from freqtrade.optimize.backtest_caching import get_backtest_metadata_filename
|
from freqtrade.optimize.backtest_caching import get_backtest_metadata_filename
|
||||||
from freqtrade.persistence import LocalTrade, Trade, init_db
|
from freqtrade.persistence import LocalTrade, Trade, init_db
|
||||||
@@ -106,7 +106,7 @@ def get_latest_hyperopt_file(
|
|||||||
directory = Path(directory)
|
directory = Path(directory)
|
||||||
if predef_filename:
|
if predef_filename:
|
||||||
if Path(predef_filename).is_absolute():
|
if Path(predef_filename).is_absolute():
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
"--hyperopt-filename expects only the filename, not an absolute path.")
|
"--hyperopt-filename expects only the filename, not an absolute path.")
|
||||||
return directory / predef_filename
|
return directory / predef_filename
|
||||||
return directory / get_latest_hyperopt_filename(directory)
|
return directory / get_latest_hyperopt_filename(directory)
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ from freqtrade.constants import (DEFAULT_AMOUNT_RESERVE_PERCENT, NON_OPEN_EXCHAN
|
|||||||
ListPairsWithTimeframes, MakerTaker, OBLiteral, PairWithTimeframe)
|
ListPairsWithTimeframes, MakerTaker, OBLiteral, PairWithTimeframe)
|
||||||
from freqtrade.data.converter import clean_ohlcv_dataframe, ohlcv_to_dataframe, trades_dict_to_list
|
from freqtrade.data.converter import clean_ohlcv_dataframe, ohlcv_to_dataframe, trades_dict_to_list
|
||||||
from freqtrade.enums import OPTIMIZE_MODES, CandleType, MarginMode, PriceType, RunMode, TradingMode
|
from freqtrade.enums import OPTIMIZE_MODES, CandleType, MarginMode, PriceType, RunMode, TradingMode
|
||||||
from freqtrade.exceptions import (DDosProtection, ExchangeError, InsufficientFundsError,
|
from freqtrade.exceptions import (ConfigurationError, DDosProtection, ExchangeError,
|
||||||
InvalidOrderException, OperationalException, PricingError,
|
InsufficientFundsError, InvalidOrderException,
|
||||||
RetryableOrderError, TemporaryError)
|
OperationalException, PricingError, RetryableOrderError,
|
||||||
|
TemporaryError)
|
||||||
from freqtrade.exchange.common import (API_FETCH_ORDER_RETRY_COUNT, remove_exchange_credentials,
|
from freqtrade.exchange.common import (API_FETCH_ORDER_RETRY_COUNT, remove_exchange_credentials,
|
||||||
retrier, retrier_async)
|
retrier, retrier_async)
|
||||||
from freqtrade.exchange.exchange_utils import (ROUND, ROUND_DOWN, ROUND_UP, CcxtModuleType,
|
from freqtrade.exchange.exchange_utils import (ROUND, ROUND_DOWN, ROUND_UP, CcxtModuleType,
|
||||||
@@ -527,7 +528,7 @@ class Exchange:
|
|||||||
)
|
)
|
||||||
quote_currencies = self.get_quote_currencies()
|
quote_currencies = self.get_quote_currencies()
|
||||||
if stake_currency not in quote_currencies:
|
if stake_currency not in quote_currencies:
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f"{stake_currency} is not available as stake on {self.name}. "
|
f"{stake_currency} is not available as stake on {self.name}. "
|
||||||
f"Available currencies are: {', '.join(quote_currencies)}")
|
f"Available currencies are: {', '.join(quote_currencies)}")
|
||||||
|
|
||||||
@@ -595,7 +596,7 @@ class Exchange:
|
|||||||
f"is therefore not supported. ccxt fetchOHLCV: {self.exchange_has('fetchOHLCV')}")
|
f"is therefore not supported. ccxt fetchOHLCV: {self.exchange_has('fetchOHLCV')}")
|
||||||
|
|
||||||
if timeframe and (timeframe not in self.timeframes):
|
if timeframe and (timeframe not in self.timeframes):
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f"Invalid timeframe '{timeframe}'. This exchange supports: {self.timeframes}")
|
f"Invalid timeframe '{timeframe}'. This exchange supports: {self.timeframes}")
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -603,7 +604,7 @@ class Exchange:
|
|||||||
and self._config['runmode'] != RunMode.UTIL_EXCHANGE
|
and self._config['runmode'] != RunMode.UTIL_EXCHANGE
|
||||||
and timeframe_to_minutes(timeframe) < 1
|
and timeframe_to_minutes(timeframe) < 1
|
||||||
):
|
):
|
||||||
raise OperationalException("Timeframes < 1m are currently not supported by Freqtrade.")
|
raise ConfigurationError("Timeframes < 1m are currently not supported by Freqtrade.")
|
||||||
|
|
||||||
def validate_ordertypes(self, order_types: Dict) -> None:
|
def validate_ordertypes(self, order_types: Dict) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -611,7 +612,7 @@ class Exchange:
|
|||||||
"""
|
"""
|
||||||
if any(v == 'market' for k, v in order_types.items()):
|
if any(v == 'market' for k, v in order_types.items()):
|
||||||
if not self.exchange_has('createMarketOrder'):
|
if not self.exchange_has('createMarketOrder'):
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f'Exchange {self.name} does not support market orders.')
|
f'Exchange {self.name} does not support market orders.')
|
||||||
self.validate_stop_ordertypes(order_types)
|
self.validate_stop_ordertypes(order_types)
|
||||||
|
|
||||||
@@ -621,7 +622,7 @@ class Exchange:
|
|||||||
"""
|
"""
|
||||||
if (order_types.get("stoploss_on_exchange")
|
if (order_types.get("stoploss_on_exchange")
|
||||||
and not self._ft_has.get("stoploss_on_exchange", False)):
|
and not self._ft_has.get("stoploss_on_exchange", False)):
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f'On exchange stoploss is not supported for {self.name}.'
|
f'On exchange stoploss is not supported for {self.name}.'
|
||||||
)
|
)
|
||||||
if self.trading_mode == TradingMode.FUTURES:
|
if self.trading_mode == TradingMode.FUTURES:
|
||||||
@@ -631,17 +632,17 @@ class Exchange:
|
|||||||
and 'stoploss_price_type' in order_types
|
and 'stoploss_price_type' in order_types
|
||||||
and order_types['stoploss_price_type'] not in price_mapping
|
and order_types['stoploss_price_type'] not in price_mapping
|
||||||
):
|
):
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f'On exchange stoploss price type is not supported for {self.name}.'
|
f'On exchange stoploss price type is not supported for {self.name}.'
|
||||||
)
|
)
|
||||||
|
|
||||||
def validate_pricing(self, pricing: Dict) -> None:
|
def validate_pricing(self, pricing: Dict) -> None:
|
||||||
if pricing.get('use_order_book', False) and not self.exchange_has('fetchL2OrderBook'):
|
if pricing.get('use_order_book', False) and not self.exchange_has('fetchL2OrderBook'):
|
||||||
raise OperationalException(f'Orderbook not available for {self.name}.')
|
raise ConfigurationError(f'Orderbook not available for {self.name}.')
|
||||||
if (not pricing.get('use_order_book', False) and (
|
if (not pricing.get('use_order_book', False) and (
|
||||||
not self.exchange_has('fetchTicker')
|
not self.exchange_has('fetchTicker')
|
||||||
or not self._ft_has['tickers_have_price'])):
|
or not self._ft_has['tickers_have_price'])):
|
||||||
raise OperationalException(f'Ticker pricing not available for {self.name}.')
|
raise ConfigurationError(f'Ticker pricing not available for {self.name}.')
|
||||||
|
|
||||||
def validate_order_time_in_force(self, order_time_in_force: Dict) -> None:
|
def validate_order_time_in_force(self, order_time_in_force: Dict) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -649,7 +650,7 @@ class Exchange:
|
|||||||
"""
|
"""
|
||||||
if any(v.upper() not in self._ft_has["order_time_in_force"]
|
if any(v.upper() not in self._ft_has["order_time_in_force"]
|
||||||
for k, v in order_time_in_force.items()):
|
for k, v in order_time_in_force.items()):
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f'Time in force policies are not supported for {self.name} yet.')
|
f'Time in force policies are not supported for {self.name} yet.')
|
||||||
|
|
||||||
def validate_required_startup_candles(self, startup_candles: int, timeframe: str) -> int:
|
def validate_required_startup_candles(self, startup_candles: int, timeframe: str) -> int:
|
||||||
@@ -671,12 +672,12 @@ class Exchange:
|
|||||||
|
|
||||||
if required_candle_call_count > 5:
|
if required_candle_call_count > 5:
|
||||||
# Only allow 5 calls per pair to somewhat limit the impact
|
# Only allow 5 calls per pair to somewhat limit the impact
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f"This strategy requires {startup_candles} candles to start, "
|
f"This strategy requires {startup_candles} candles to start, "
|
||||||
"which is more than 5x "
|
"which is more than 5x "
|
||||||
f"the amount of candles {self.name} provides for {timeframe}.")
|
f"the amount of candles {self.name} provides for {timeframe}.")
|
||||||
elif required_candle_call_count > 1:
|
elif required_candle_call_count > 1:
|
||||||
raise OperationalException(
|
raise ConfigurationError(
|
||||||
f"This strategy requires {startup_candles} candles to start, which is more than "
|
f"This strategy requires {startup_candles} candles to start, which is more than "
|
||||||
f"the amount of candles {self.name} provides for {timeframe}.")
|
f"the amount of candles {self.name} provides for {timeframe}.")
|
||||||
if required_candle_call_count > 1:
|
if required_candle_call_count > 1:
|
||||||
@@ -3094,3 +3095,4 @@ class Exchange:
|
|||||||
# describes the min amt for a tier, and the lowest tier will always go down to 0
|
# describes the min amt for a tier, and the lowest tier will always go down to 0
|
||||||
else:
|
else:
|
||||||
raise ExchangeError(f"Cannot get maintenance ratio using {self.name}")
|
raise ExchangeError(f"Cannot get maintenance ratio using {self.name}")
|
||||||
|
raise ExchangeError(f"Cannot get maintenance ratio using {self.name}")
|
||||||
|
|||||||
Reference in New Issue
Block a user