|
|
|
|
@ -9,7 +9,7 @@ from freqtrade.misc import deep_merge_dicts
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_var_typed(val):
|
|
|
|
|
def _get_var_typed(val):
|
|
|
|
|
try:
|
|
|
|
|
return int(val)
|
|
|
|
|
except ValueError:
|
|
|
|
|
@ -24,7 +24,7 @@ def get_var_typed(val):
|
|
|
|
|
return val
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def flat_vars_to_nested_dict(env_dict: Dict[str, Any], prefix: str) -> Dict[str, Any]:
|
|
|
|
|
def _flat_vars_to_nested_dict(env_dict: Dict[str, Any], prefix: str) -> Dict[str, Any]:
|
|
|
|
|
"""
|
|
|
|
|
Environment variables must be prefixed with FREQTRADE.
|
|
|
|
|
FREQTRADE__{section}__{key}
|
|
|
|
|
@ -40,7 +40,7 @@ def flat_vars_to_nested_dict(env_dict: Dict[str, Any], prefix: str) -> Dict[str,
|
|
|
|
|
logger.info(f"Loading variable '{env_var}'")
|
|
|
|
|
key = env_var.replace(prefix, '')
|
|
|
|
|
for k in reversed(key.split('__')):
|
|
|
|
|
val = {k.lower(): get_var_typed(val)
|
|
|
|
|
val = {k.lower(): _get_var_typed(val)
|
|
|
|
|
if not isinstance(val, dict) and k not in no_convert else val}
|
|
|
|
|
relevant_vars = deep_merge_dicts(val, relevant_vars)
|
|
|
|
|
return relevant_vars
|
|
|
|
|
@ -52,4 +52,4 @@ def enironment_vars_to_dict() -> Dict[str, Any]:
|
|
|
|
|
Relevant variables must follow the FREQTRADE__{section}__{key} pattern
|
|
|
|
|
:return: Nested dict based on available and relevant variables.
|
|
|
|
|
"""
|
|
|
|
|
return flat_vars_to_nested_dict(os.environ.copy(), ENV_VAR_PREFIX)
|
|
|
|
|
return _flat_vars_to_nested_dict(os.environ.copy(), ENV_VAR_PREFIX)
|
|
|
|
|
|