From f33923c7842ad0c440d5d5f9bd028331ea4b9ac3 Mon Sep 17 00:00:00 2001 From: Janne Sinivirta Date: Fri, 26 Jan 2018 11:48:34 +0200 Subject: [PATCH] fix typings for hyperopt code --- freqtrade/optimize/hyperopt.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 4c73dc76f..6f63c159f 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -10,7 +10,7 @@ import sys from functools import reduce from math import exp from operator import itemgetter -from typing import Dict, List +from typing import Dict, Any, Callable import numpy import talib.abstract as ta @@ -35,7 +35,7 @@ logging.getLogger('hyperopt.tpe').setLevel(logging.WARNING) logger = logging.getLogger(__name__) -# set TARGET_TRADES to suit your number concurrent trades so its realistic to 20days of data +# set TARGET_TRADES to suit your number concurrent trades so its realistic to the number of days TARGET_TRADES = 600 TOTAL_TRIES = 0 _CURRENT_TRIES = 0 @@ -225,7 +225,7 @@ def calculate_loss(total_profit: float, trade_count: int, trade_duration: float) return trade_loss + profit_loss + duration_loss -def generate_roi_table(params): +def generate_roi_table(params) -> Dict[str, float]: roi_table = {} roi_table["0"] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] roi_table[str(params['roi_t3'])] = params['roi_p1'] + params['roi_p2'] @@ -235,7 +235,7 @@ def generate_roi_table(params): return roi_table -def roi_space() -> List[Dict]: +def roi_space() -> Dict[str, Any]: return { 'roi_t1': hp.quniform('roi_t1', 10, 220, 10), 'roi_t2': hp.quniform('roi_t2', 10, 120, 10), @@ -246,13 +246,13 @@ def roi_space() -> List[Dict]: } -def stoploss_space() -> Dict: +def stoploss_space() -> Dict[str, Any]: return { 'stoploss': hp.uniform('stoploss', -0.5, -0.02), } -def indicator_space() -> List[Dict]: +def indicator_space() -> Dict[str, Any]: """ Define your Hyperopt space for searching strategy parameters """ @@ -312,11 +312,11 @@ def indicator_space() -> List[Dict]: } -def hyperopt_space() -> List[Dict]: +def hyperopt_space() -> Dict[str, Any]: return {**indicator_space(), **roi_space(), **stoploss_space()} -def buy_strategy_generator(params) -> None: +def buy_strategy_generator(params: Dict[str, Any]) -> Callable: """ Define the buy strategy parameters to be used by hyperopt """