use Config typing in more places
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
This module loads custom exchanges
|
||||
"""
|
||||
import logging
|
||||
from freqtrade.constants import Config
|
||||
|
||||
import freqtrade.exchange as exchanges
|
||||
from freqtrade.exchange import MAP_EXCHANGE_CHILDCLASS, Exchange
|
||||
@@ -18,7 +19,7 @@ class ExchangeResolver(IResolver):
|
||||
object_type = Exchange
|
||||
|
||||
@staticmethod
|
||||
def load_exchange(exchange_name: str, config: dict, validate: bool = True,
|
||||
def load_exchange(exchange_name: str, config: Config, validate: bool = True,
|
||||
load_leverage_tiers: bool = False) -> Exchange:
|
||||
"""
|
||||
Load the custom class from config parameter
|
||||
|
@@ -5,9 +5,8 @@ This module load a custom model for freqai
|
||||
"""
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.constants import USERPATH_FREQAIMODELS
|
||||
from freqtrade.constants import USERPATH_FREQAIMODELS, Config
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.freqai.freqai_interface import IFreqaiModel
|
||||
from freqtrade.resolvers import IResolver
|
||||
@@ -29,7 +28,7 @@ class FreqaiModelResolver(IResolver):
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def load_freqaimodel(config: Dict) -> IFreqaiModel:
|
||||
def load_freqaimodel(config: Config) -> IFreqaiModel:
|
||||
"""
|
||||
Load the custom class from config parameter
|
||||
:param config: configuration dictionary
|
||||
|
@@ -5,9 +5,8 @@ This module load custom hyperopt
|
||||
"""
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.constants import HYPEROPT_LOSS_BUILTIN, USERPATH_HYPEROPTS
|
||||
from freqtrade.constants import HYPEROPT_LOSS_BUILTIN, USERPATH_HYPEROPTS, Config
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss
|
||||
from freqtrade.resolvers import IResolver
|
||||
@@ -26,7 +25,7 @@ class HyperOptLossResolver(IResolver):
|
||||
initial_search_path = Path(__file__).parent.parent.joinpath('optimize/hyperopt_loss').resolve()
|
||||
|
||||
@staticmethod
|
||||
def load_hyperoptloss(config: Dict) -> IHyperOptLoss:
|
||||
def load_hyperoptloss(config: Config) -> IHyperOptLoss:
|
||||
"""
|
||||
Load the custom class from config parameter
|
||||
:param config: configuration dictionary
|
||||
|
@@ -10,6 +10,7 @@ import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Type, Union
|
||||
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.exceptions import OperationalException
|
||||
|
||||
|
||||
@@ -43,7 +44,7 @@ class IResolver:
|
||||
initial_search_path: Optional[Path]
|
||||
|
||||
@classmethod
|
||||
def build_search_paths(cls, config: Dict[str, Any], user_subdir: Optional[str] = None,
|
||||
def build_search_paths(cls, config: Config, user_subdir: Optional[str] = None,
|
||||
extra_dirs: List[str] = []) -> List[Path]:
|
||||
|
||||
abs_paths: List[Path] = []
|
||||
@@ -153,7 +154,7 @@ class IResolver:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def load_object(cls, object_name: str, config: dict, *, kwargs: dict,
|
||||
def load_object(cls, object_name: str, config: Config, *, kwargs: dict,
|
||||
extra_dir: Optional[str] = None) -> Any:
|
||||
"""
|
||||
Search and loads the specified object as configured in hte child class.
|
||||
|
@@ -6,6 +6,7 @@ This module load custom pairlists
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.plugins.pairlist.IPairList import IPairList
|
||||
from freqtrade.resolvers import IResolver
|
||||
|
||||
@@ -24,7 +25,7 @@ class PairListResolver(IResolver):
|
||||
|
||||
@staticmethod
|
||||
def load_pairlist(pairlist_name: str, exchange, pairlistmanager,
|
||||
config: dict, pairlistconfig: dict, pairlist_pos: int) -> IPairList:
|
||||
config: Config, pairlistconfig: dict, pairlist_pos: int) -> IPairList:
|
||||
"""
|
||||
Load the pairlist with pairlist_name
|
||||
:param pairlist_name: Classname of the pairlist
|
||||
|
@@ -5,6 +5,7 @@ import logging
|
||||
from pathlib import Path
|
||||
from typing import Dict
|
||||
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.plugins.protections import IProtection
|
||||
from freqtrade.resolvers import IResolver
|
||||
|
||||
@@ -22,7 +23,8 @@ class ProtectionResolver(IResolver):
|
||||
initial_search_path = Path(__file__).parent.parent.joinpath('plugins/protections').resolve()
|
||||
|
||||
@staticmethod
|
||||
def load_protection(protection_name: str, config: Dict, protection_config: Dict) -> IProtection:
|
||||
def load_protection(protection_name: str, config: Config,
|
||||
protection_config: Dict) -> IProtection:
|
||||
"""
|
||||
Load the protection with protection_name
|
||||
:param protection_name: Classname of the pairlist
|
||||
|
@@ -9,10 +9,10 @@ from base64 import urlsafe_b64decode
|
||||
from inspect import getfullargspec
|
||||
from os import walk
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from freqtrade.configuration.config_validation import validate_migrated_strategy_settings
|
||||
from freqtrade.constants import REQUIRED_ORDERTIF, REQUIRED_ORDERTYPES, USERPATH_STRATEGIES
|
||||
from freqtrade.constants import REQUIRED_ORDERTIF, REQUIRED_ORDERTYPES, USERPATH_STRATEGIES, Config
|
||||
from freqtrade.enums import TradingMode
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.resolvers import IResolver
|
||||
@@ -32,7 +32,7 @@ class StrategyResolver(IResolver):
|
||||
initial_search_path = None
|
||||
|
||||
@staticmethod
|
||||
def load_strategy(config: Dict[str, Any] = None) -> IStrategy:
|
||||
def load_strategy(config: Config = None) -> IStrategy:
|
||||
"""
|
||||
Load the custom class from config parameter
|
||||
:param config: configuration dictionary or None
|
||||
@@ -91,8 +91,7 @@ class StrategyResolver(IResolver):
|
||||
return strategy
|
||||
|
||||
@staticmethod
|
||||
def _override_attribute_helper(strategy, config: Dict[str, Any],
|
||||
attribute: str, default: Any):
|
||||
def _override_attribute_helper(strategy, config: Config, attribute: str, default: Any):
|
||||
"""
|
||||
Override attributes in the strategy.
|
||||
Prevalence:
|
||||
@@ -215,7 +214,7 @@ class StrategyResolver(IResolver):
|
||||
|
||||
@staticmethod
|
||||
def _load_strategy(strategy_name: str,
|
||||
config: dict, extra_dir: Optional[str] = None) -> IStrategy:
|
||||
config: Config, extra_dir: Optional[str] = None) -> IStrategy:
|
||||
"""
|
||||
Search and loads the specified strategy.
|
||||
:param strategy_name: name of the module to import
|
||||
|
Reference in New Issue
Block a user