Flake8 compliance and documentation for hyperopt in strategy file

This commit is contained in:
Stephen Dade
2018-03-01 19:58:37 +11:00
parent 41b9165495
commit e4d29e473b
4 changed files with 44 additions and 40 deletions

View File

@@ -4,7 +4,7 @@ import talib.abstract as ta
from pandas import DataFrame
from typing import Dict, Any, Callable
import freqtrade.vendor.qtpylib.indicators as qtpylib
from hyperopt import STATUS_FAIL, STATUS_OK, Trials, fmin, hp, space_eval, tpe
from hyperopt import hp
from functools import reduce
from freqtrade.strategy.interface import IStrategy
from freqtrade.indicator_helpers import fishers_inverse
@@ -301,7 +301,7 @@ class DefaultStrategy(IStrategy):
{'type': 'di_cross'},
]),
}
def buy_strategy_generator(self, params: Dict[str, Any]) -> Callable:
"""
Define the buy strategy parameters to be used by hyperopt
@@ -374,7 +374,7 @@ class DefaultStrategy(IStrategy):
return dataframe
return populate_buy_trend
def roi_space(self) -> Dict[str, Any]:
return {
'roi_t1': hp.quniform('roi_t1', 10, 120, 20),
@@ -385,8 +385,7 @@ class DefaultStrategy(IStrategy):
'roi_p3': hp.quniform('roi_p3', 0.01, 0.20, 0.01),
}
def stoploss_space(self) -> Dict[str, Any]:
return {
'stoploss': hp.quniform('stoploss', -0.5, -0.02, 0.02),
}
}

View File

@@ -185,16 +185,15 @@ class Strategy(object):
Define your Hyperopt space for searching strategy parameters
"""
return self.custom_strategy.indicator_space()
def buy_strategy_generator(self, params: Dict[str, Any]) -> Callable:
"""
Define the buy strategy parameters to be used by hyperopt
"""
return self.custom_strategy.buy_strategy_generator(params)
def roi_space(self) -> Dict[str, Any]:
return self.custom_strategy.roi_space()
def stoploss_space(self) -> Dict[str, Any]:
return self.custom_strategy.stoploss_space()