mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 18:23:55 +00:00
31 lines
776 B
Python
31 lines
776 B
Python
|
"""
|
||
|
This module contain functions to load the configuration file
|
||
|
"""
|
||
|
import json
|
||
|
import logging
|
||
|
import sys
|
||
|
from typing import Any, Dict
|
||
|
|
||
|
from freqtrade import OperationalException
|
||
|
|
||
|
|
||
|
logger = logging.getLogger(__name__)
|
||
|
|
||
|
|
||
|
def load_config_file(path: str) -> Dict[str, Any]:
|
||
|
"""
|
||
|
Loads a config file from the given path
|
||
|
:param path: path as str
|
||
|
:return: configuration as dictionary
|
||
|
"""
|
||
|
try:
|
||
|
# Read config from stdin if requested in the options
|
||
|
with open(path) if path != '-' else sys.stdin as file:
|
||
|
config = json.load(file)
|
||
|
except FileNotFoundError:
|
||
|
raise OperationalException(
|
||
|
f'Config file "{path}" not found!'
|
||
|
' Please create a config file or check whether it exists.')
|
||
|
|
||
|
return config
|