Disallow usage of DefaultStrategy

This commit is contained in:
Matthias 2019-11-01 19:50:42 +01:00
parent 98baae9456
commit e492d47621

View File

@ -1,4 +1,4 @@
from freqtrade.loggers import setup_logging import csv
import logging import logging
import sys import sys
from collections import OrderedDict from collections import OrderedDict
@ -6,18 +6,20 @@ from pathlib import Path
from typing import Any, Dict, List from typing import Any, Dict, List
import arrow import arrow
import csv
import rapidjson import rapidjson
from tabulate import tabulate from tabulate import tabulate
from freqtrade import OperationalException from freqtrade import OperationalException
from freqtrade.configuration import Configuration, TimeRange, remove_credentials from freqtrade.configuration import (Configuration, TimeRange,
from freqtrade.configuration.directory_operations import create_userdata_dir, copy_sample_files remove_credentials)
from freqtrade.configuration.directory_operations import (copy_sample_files,
create_userdata_dir)
from freqtrade.constants import DEFAULT_STRATEGY
from freqtrade.data.history import (convert_trades_to_ohlcv, from freqtrade.data.history import (convert_trades_to_ohlcv,
refresh_backtest_ohlcv_data, refresh_backtest_ohlcv_data,
refresh_backtest_trades_data) refresh_backtest_trades_data)
from freqtrade.exchange import (available_exchanges, ccxt_exchanges, market_is_active, from freqtrade.exchange import (available_exchanges, ccxt_exchanges,
symbol_is_pair) market_is_active, symbol_is_pair)
from freqtrade.misc import plural, render_template from freqtrade.misc import plural, render_template
from freqtrade.resolvers import ExchangeResolver from freqtrade.resolvers import ExchangeResolver
from freqtrade.state import RunMode from freqtrade.state import RunMode
@ -94,6 +96,9 @@ def start_new_strategy(args: Dict[str, Any]) -> None:
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
if "strategy" in args and args["strategy"]: if "strategy" in args and args["strategy"]:
if args["strategy"] == DEFAULT_STRATEGY:
raise OperationalException("DefaultStrategy is not allowed as name.")
new_path = config['user_data_dir'] / "strategies" / (args["strategy"] + ".py") new_path = config['user_data_dir'] / "strategies" / (args["strategy"] + ".py")
if new_path.exists(): if new_path.exists():