chore: move remove_exchange_credentials to config module

This commit is contained in:
Matthias
2025-06-20 20:19:20 +02:00
parent 5ca69687dc
commit 5e059660d4
7 changed files with 20 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
# flake8: noqa: F401 # flake8: noqa: F401
from freqtrade.configuration.config_secrets import sanitize_config from freqtrade.configuration.config_secrets import remove_exchange_credentials, sanitize_config
from freqtrade.configuration.config_setup import setup_utils_configuration from freqtrade.configuration.config_setup import setup_utils_configuration
from freqtrade.configuration.config_validation import validate_config_consistency from freqtrade.configuration.config_validation import validate_config_consistency
from freqtrade.configuration.configuration import Configuration from freqtrade.configuration.configuration import Configuration

View File

@@ -1,6 +1,6 @@
from copy import deepcopy from copy import deepcopy
from freqtrade.constants import Config from freqtrade.constants import Config, ExchangeConfig
_SENSITIVE_KEYS = [ _SENSITIVE_KEYS = [
@@ -47,3 +47,17 @@ def sanitize_config(config: Config, *, show_sensitive: bool = False) -> Config:
config[key] = "REDACTED" config[key] = "REDACTED"
return config return config
def remove_exchange_credentials(exchange_config: ExchangeConfig, dry_run: bool) -> None:
"""
Removes exchange keys from the configuration and specifies dry-run
Used for backtesting / hyperopt and utils.
Modifies the input dict!
"""
if dry_run:
exchange_config["key"] = ""
exchange_config["apiKey"] = ""
exchange_config["secret"] = ""
exchange_config["password"] = ""
exchange_config["uid"] = ""

View File

@@ -1,6 +1,6 @@
# flake8: noqa: F401 # flake8: noqa: F401
# isort: off # isort: off
from freqtrade.exchange.common import remove_exchange_credentials, MAP_EXCHANGE_CHILDCLASS from freqtrade.exchange.common import MAP_EXCHANGE_CHILDCLASS
from freqtrade.exchange.exchange import Exchange from freqtrade.exchange.exchange import Exchange
# isort: on # isort: on

View File

@@ -5,7 +5,6 @@ from collections.abc import Callable
from functools import wraps from functools import wraps
from typing import Any, TypeVar, cast, overload from typing import Any, TypeVar, cast, overload
from freqtrade.constants import ExchangeConfig
from freqtrade.exceptions import DDosProtection, RetryableOrderError, TemporaryError from freqtrade.exceptions import DDosProtection, RetryableOrderError, TemporaryError
from freqtrade.mixins import LoggingMixin from freqtrade.mixins import LoggingMixin
@@ -104,20 +103,6 @@ EXCHANGE_HAS_OPTIONAL = [
] ]
def remove_exchange_credentials(exchange_config: ExchangeConfig, dry_run: bool) -> None:
"""
Removes exchange keys from the configuration and specifies dry-run
Used for backtesting / hyperopt and utils.
Modifies the input dict!
"""
if dry_run:
exchange_config["key"] = ""
exchange_config["apiKey"] = ""
exchange_config["secret"] = ""
exchange_config["password"] = ""
exchange_config["uid"] = ""
def calculate_backoff(retrycount, max_retries): def calculate_backoff(retrycount, max_retries):
""" """
Calculate backoff Calculate backoff

View File

@@ -21,6 +21,7 @@ from ccxt import TICK_SIZE
from dateutil import parser from dateutil import parser
from pandas import DataFrame, concat from pandas import DataFrame, concat
from freqtrade.configuration import remove_exchange_credentials
from freqtrade.constants import ( from freqtrade.constants import (
DEFAULT_AMOUNT_RESERVE_PERCENT, DEFAULT_AMOUNT_RESERVE_PERCENT,
DEFAULT_TRADES_COLUMNS, DEFAULT_TRADES_COLUMNS,
@@ -64,7 +65,6 @@ from freqtrade.exceptions import (
) )
from freqtrade.exchange.common import ( from freqtrade.exchange.common import (
API_FETCH_ORDER_RETRY_COUNT, API_FETCH_ORDER_RETRY_COUNT,
remove_exchange_credentials,
retrier, retrier,
retrier_async, retrier_async,
) )

View File

@@ -14,7 +14,7 @@ from typing import Any
from schedule import Scheduler from schedule import Scheduler
from freqtrade import constants from freqtrade import constants
from freqtrade.configuration import validate_config_consistency from freqtrade.configuration import remove_exchange_credentials, validate_config_consistency
from freqtrade.constants import BuySell, Config, EntryExecuteMode, ExchangeConfig, LongShort from freqtrade.constants import BuySell, Config, EntryExecuteMode, ExchangeConfig, LongShort
from freqtrade.data.converter import order_book_to_dataframe from freqtrade.data.converter import order_book_to_dataframe
from freqtrade.data.dataprovider import DataProvider from freqtrade.data.dataprovider import DataProvider
@@ -37,7 +37,6 @@ from freqtrade.exceptions import (
from freqtrade.exchange import ( from freqtrade.exchange import (
ROUND_DOWN, ROUND_DOWN,
ROUND_UP, ROUND_UP,
remove_exchange_credentials,
timeframe_to_minutes, timeframe_to_minutes,
timeframe_to_next_date, timeframe_to_next_date,
timeframe_to_seconds, timeframe_to_seconds,

View File

@@ -8,6 +8,7 @@ from typing import Any
from fastapi import APIRouter, BackgroundTasks, Depends from fastapi import APIRouter, BackgroundTasks, Depends
from fastapi.exceptions import HTTPException from fastapi.exceptions import HTTPException
from freqtrade.configuration import remove_exchange_credentials
from freqtrade.configuration.config_validation import validate_config_consistency from freqtrade.configuration.config_validation import validate_config_consistency
from freqtrade.constants import Config from freqtrade.constants import Config
from freqtrade.data.btanalysis import ( from freqtrade.data.btanalysis import (
@@ -20,7 +21,6 @@ from freqtrade.data.btanalysis import (
) )
from freqtrade.enums import BacktestState from freqtrade.enums import BacktestState
from freqtrade.exceptions import ConfigurationError, DependencyException, OperationalException from freqtrade.exceptions import ConfigurationError, DependencyException, OperationalException
from freqtrade.exchange.common import remove_exchange_credentials
from freqtrade.ft_types import get_BacktestResultType_default from freqtrade.ft_types import get_BacktestResultType_default
from freqtrade.misc import deep_merge_dicts, is_file_in_dir from freqtrade.misc import deep_merge_dicts, is_file_in_dir
from freqtrade.rpc.api_server.api_schemas import ( from freqtrade.rpc.api_server.api_schemas import (