Skip to content

Commit

Permalink
fixed some more line alignments
Browse files Browse the repository at this point in the history
  • Loading branch information
yazeed committed Jan 31, 2020
1 parent 2396f35 commit d038bce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
12 changes: 6 additions & 6 deletions freqtrade/optimize/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,12 @@ def start(self) -> None:
)
# Execute backtest and print results
all_results[self.strategy.get_strategy_name()] = self.backtest(
processed=preprocessed,
stake_amount=self.config['stake_amount'],
start_date=min_date,
end_date=max_date,
max_open_trades=max_open_trades,
position_stacking=position_stacking,
processed=preprocessed,
stake_amount=self.config['stake_amount'],
start_date=min_date,
end_date=max_date,
max_open_trades=max_open_trades,
position_stacking=position_stacking,
)

for strategy, results in all_results.items():
Expand Down
29 changes: 15 additions & 14 deletions freqtrade/optimize/hyperopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Hyperopt:
hyperopt = Hyperopt(config)
hyperopt.start()
"""

def __init__(self, config: Dict[str, Any]) -> None:
self.config = config

Expand Down Expand Up @@ -90,13 +91,13 @@ def __init__(self, config: Dict[str, Any]) -> None:
# Populate functions here (hasattr is slow so should not be run during "regular" operations)
if hasattr(self.custom_hyperopt, 'populate_indicators'):
self.backtesting.strategy.advise_indicators = \
self.custom_hyperopt.populate_indicators # type: ignore
self.custom_hyperopt.populate_indicators # type: ignore
if hasattr(self.custom_hyperopt, 'populate_buy_trend'):
self.backtesting.strategy.advise_buy = \
self.custom_hyperopt.populate_buy_trend # type: ignore
self.custom_hyperopt.populate_buy_trend # type: ignore
if hasattr(self.custom_hyperopt, 'populate_sell_trend'):
self.backtesting.strategy.advise_sell = \
self.custom_hyperopt.populate_sell_trend # type: ignore
self.custom_hyperopt.populate_sell_trend # type: ignore

# Use max_open_trades for hyperopt as well, except --disable-max-market-positions is set
if self.config.get('use_max_market_positions', True):
Expand Down Expand Up @@ -345,15 +346,15 @@ def generate_optimizer(self, raw_params: List[Any], iteration=None) -> Dict:

if self.has_space('roi'):
self.backtesting.strategy.minimal_roi = \
self.custom_hyperopt.generate_roi_table(params_dict)
self.custom_hyperopt.generate_roi_table(params_dict)

if self.has_space('buy'):
self.backtesting.strategy.advise_buy = \
self.custom_hyperopt.buy_strategy_generator(params_dict)
self.custom_hyperopt.buy_strategy_generator(params_dict)

if self.has_space('sell'):
self.backtesting.strategy.advise_sell = \
self.custom_hyperopt.sell_strategy_generator(params_dict)
self.custom_hyperopt.sell_strategy_generator(params_dict)

if self.has_space('stoploss'):
self.backtesting.strategy.stoploss = params_dict['stoploss']
Expand All @@ -372,12 +373,12 @@ def generate_optimizer(self, raw_params: List[Any], iteration=None) -> Dict:
min_date, max_date = get_timerange(processed)

backtesting_results = self.backtesting.backtest(
processed=processed,
stake_amount=self.config['stake_amount'],
start_date=min_date,
end_date=max_date,
max_open_trades=self.max_open_trades,
position_stacking=self.position_stacking,
processed=processed,
stake_amount=self.config['stake_amount'],
start_date=min_date,
end_date=max_date,
max_open_trades=self.max_open_trades,
position_stacking=self.position_stacking,
)
return self._get_results_dict(backtesting_results, min_date, max_date,
params_dict, params_details)
Expand Down Expand Up @@ -469,8 +470,8 @@ def load_previous_results(trials_file) -> List:
trials = Hyperopt._read_trials(trials_file)
if trials[0].get('is_best') is None:
raise OperationalException(
"The file with Hyperopt results is incompatible with this version "
"of Freqtrade and cannot be loaded.")
"The file with Hyperopt results is incompatible with this version "
"of Freqtrade and cannot be loaded.")
logger.info(f"Loaded {len(trials)} previous evaluations from disk.")
return trials

Expand Down

0 comments on commit d038bce

Please sign in to comment.