diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index a77576a27..ac077506a 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -4,11 +4,9 @@ import logging import json import os from typing import Optional, List, Dict +from pandas import DataFrame from freqtrade.exchange import get_ticker_history from freqtrade.optimize.hyperopt_conf import hyperopt_optimize_conf - -from pandas import DataFrame - from freqtrade.analyze import populate_indicators, parse_ticker_dataframe logger = logging.getLogger(__name__) @@ -50,10 +48,8 @@ def load_data(ticker_interval: int = 5, pairs: Optional[List[str]] = None, def preprocess(tickerdata: Dict[str, List]) -> Dict[str, DataFrame]: """Creates a dataframe and populates indicators for given ticker data""" - processed = {} - for pair, pair_data in tickerdata.items(): - processed[pair] = populate_indicators(parse_ticker_dataframe(pair_data)) - return processed + return {pair: populate_indicators(parse_ticker_dataframe(pair_data)) + for pair, pair_data in tickerdata.items()} def testdata_path() -> str: diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 2684d2576..984ca3e72 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -111,14 +111,14 @@ def backtest(stake_amount: float, processed: Dict[str, DataFrame], if min_roi_reached(trade, row2.close, row2.date) or row2.sell == 1: current_profit_percent = trade.calc_profit_percent(rate=row2.close) - current_profit_BTC = trade.calc_profit(rate=row2.close) + current_profit_btc = trade.calc_profit(rate=row2.close) lock_pair_until = row2.Index trades.append( ( pair, current_profit_percent, - current_profit_BTC, + current_profit_btc, row2.Index - row.Index ) ) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index dcdafc946..686f15a17 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -118,8 +118,7 @@ def optimizer(params): backtesting.populate_buy_trend = buy_strategy_generator(params) results = backtest(OPTIMIZE_CONFIG['stake_amount'], PROCESSED) - - result = format_results(results) + result_explanation = format_results(results) total_profit = results.profit_percent.sum() trade_count = len(results.index) @@ -135,20 +134,17 @@ def optimizer(params): loss = trade_loss + profit_loss _CURRENT_TRIES += 1 - result_data = { + log_results({ 'loss': loss, 'current_tries': _CURRENT_TRIES, 'total_tries': TOTAL_TRIES, - 'result': result, - } - log_results(result_data) + 'result': result_explanation, + }) return { 'loss': loss, 'status': STATUS_OK, - 'result': result, - 'total_profit': total_profit, - 'avg_profit': results.profit_percent.mean() * 100.0, + 'result': result_explanation, }