freqtrade_origin/freqtrade/commands/build_config_commands.py

54 lines
1.6 KiB
Python
Raw Normal View History

import logging
from pathlib import Path
from typing import Any
2024-03-14 19:39:34 +00:00
from freqtrade.enums import RunMode
from freqtrade.exceptions import OperationalException
2020-09-28 17:39:41 +00:00
logger = logging.getLogger(__name__)
def start_new_config(args: dict[str, Any]) -> None:
"""
Create a new strategy from a template
2021-06-25 13:45:49 +00:00
Asking the user questions to fill out the template accordingly.
"""
from freqtrade.configuration.deploy_config import (
ask_user_config,
ask_user_overwrite,
deploy_new_config,
)
2024-10-03 03:33:52 +00:00
from freqtrade.configuration.directory_operations import chown_user_directory
2024-05-12 14:27:03 +00:00
config_path = Path(args["config"][0])
2021-04-08 18:07:52 +00:00
chown_user_directory(config_path.parent)
2020-02-01 13:12:21 +00:00
if config_path.exists():
2020-02-01 13:22:40 +00:00
overwrite = ask_user_overwrite(config_path)
if overwrite:
config_path.unlink()
else:
raise OperationalException(
2020-02-09 10:41:29 +00:00
f"Configuration file `{config_path}` already exists. "
2024-05-12 14:27:03 +00:00
"Please delete it or use a different configuration file name."
)
2020-02-01 13:12:21 +00:00
selections = ask_user_config()
deploy_new_config(config_path, selections)
2024-03-14 19:39:34 +00:00
def start_show_config(args: dict[str, Any]) -> None:
2024-10-03 03:33:52 +00:00
from freqtrade.configuration import sanitize_config
from freqtrade.configuration.config_setup import setup_utils_configuration
2024-03-14 19:39:34 +00:00
config = setup_utils_configuration(args, RunMode.UTIL_EXCHANGE, set_dry=False)
2024-03-19 18:19:26 +00:00
print("Your combined configuration is:")
2024-03-20 06:06:24 +00:00
config_sanitized = sanitize_config(
2024-05-12 14:27:03 +00:00
config["original_config"], show_sensitive=args.get("show_sensitive", False)
2024-03-20 06:06:24 +00:00
)
2024-03-19 18:30:35 +00:00
2024-03-19 18:19:26 +00:00
from rich import print_json
2024-05-12 14:27:03 +00:00
2024-03-19 18:30:35 +00:00
print_json(data=config_sanitized)