merged order book

This commit is contained in:
Gert Wohlgemuth
2018-06-12 09:46:23 -07:00
65 changed files with 1366 additions and 961 deletions

View File

@@ -2,7 +2,7 @@
IStrategy interface
This module defines the interface to apply for strategies
"""
from typing import Dict
from abc import ABC, abstractmethod
from pandas import DataFrame
@@ -16,9 +16,13 @@ class IStrategy(ABC):
Attributes you can use:
minimal_roi -> Dict: Minimal ROI designed for the strategy
stoploss -> float: optimal stoploss designed for the strategy
ticker_interval -> int: value of the ticker interval to use for the strategy
ticker_interval -> str: value of the ticker interval to use for the strategy
"""
minimal_roi: Dict
stoploss: float
ticker_interval: str
@abstractmethod
def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
"""

View File

@@ -36,7 +36,8 @@ class StrategyResolver(object):
# Verify the strategy is in the configuration, otherwise fallback to the default strategy
strategy_name = config.get('strategy') or constants.DEFAULT_STRATEGY
self.strategy = self._load_strategy(strategy_name, extra_dir=config.get('strategy_path'))
self.strategy: IStrategy = self._load_strategy(strategy_name,
extra_dir=config.get('strategy_path'))
# Set attributes
# Check if we need to override configuration
@@ -64,7 +65,7 @@ class StrategyResolver(object):
self.strategy.stoploss = float(self.strategy.stoploss)
def _load_strategy(
self, strategy_name: str, extra_dir: Optional[str] = None) -> Optional[IStrategy]:
self, strategy_name: str, extra_dir: Optional[str] = None) -> IStrategy:
"""
Search and loads the specified strategy.
:param strategy_name: name of the module to import
@@ -123,7 +124,7 @@ class StrategyResolver(object):
# Generate spec based on absolute path
spec = importlib.util.spec_from_file_location('user_data.strategies', module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
spec.loader.exec_module(module) # type: ignore # importlib does not use typehints
valid_strategies_gen = (
obj for name, obj in inspect.getmembers(module, inspect.isclass)