Enable dataprovier for hyperopt

This commit is contained in:
Matthias 2020-08-08 17:04:32 +02:00
parent e2643103b6
commit dd430455e4
2 changed files with 11 additions and 9 deletions

View File

@ -65,9 +65,8 @@ class Backtesting:
self.strategylist: List[IStrategy] = [] self.strategylist: List[IStrategy] = []
self.exchange = ExchangeResolver.load_exchange(self.config['exchange']['name'], self.config) self.exchange = ExchangeResolver.load_exchange(self.config['exchange']['name'], self.config)
if self.config.get('runmode') != RunMode.HYPEROPT: dataprovider = DataProvider(self.config, self.exchange)
self.dataprovider = DataProvider(self.config, self.exchange) IStrategy.dp = dataprovider
IStrategy.dp = self.dataprovider
if self.config.get('strategy_list', None): if self.config.get('strategy_list', None):
for strat in list(self.config['strategy_list']): for strat in list(self.config['strategy_list']):

View File

@ -4,26 +4,26 @@
This module contains the hyperopt logic This module contains the hyperopt logic
""" """
import io
import locale import locale
import logging import logging
import random import random
import warnings import warnings
from math import ceil
from collections import OrderedDict from collections import OrderedDict
from math import ceil
from operator import itemgetter from operator import itemgetter
from os import path
from pathlib import Path from pathlib import Path
from pprint import pformat from pprint import pformat
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
import progressbar
import rapidjson import rapidjson
import tabulate
from colorama import Fore, Style from colorama import Fore, Style
from joblib import (Parallel, cpu_count, delayed, dump, load, from joblib import (Parallel, cpu_count, delayed, dump, load,
wrap_non_picklable_objects) wrap_non_picklable_objects)
from pandas import DataFrame, json_normalize, isna from pandas import DataFrame, isna, json_normalize
import progressbar
import tabulate
from os import path
import io
from freqtrade.data.converter import trim_dataframe from freqtrade.data.converter import trim_dataframe
from freqtrade.data.history import get_timerange from freqtrade.data.history import get_timerange
@ -35,6 +35,7 @@ from freqtrade.optimize.hyperopt_interface import IHyperOpt # noqa: F401
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F401 from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F401
from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver, from freqtrade.resolvers.hyperopt_resolver import (HyperOptLossResolver,
HyperOptResolver) HyperOptResolver)
from freqtrade.strategy import IStrategy
# Suppress scikit-learn FutureWarnings from skopt # Suppress scikit-learn FutureWarnings from skopt
with warnings.catch_warnings(): with warnings.catch_warnings():
@ -634,6 +635,8 @@ class Hyperopt:
# We don't need exchange instance anymore while running hyperopt # We don't need exchange instance anymore while running hyperopt
self.backtesting.exchange = None # type: ignore self.backtesting.exchange = None # type: ignore
self.backtesting.pairlists = None # type: ignore self.backtesting.pairlists = None # type: ignore
self.backtesting.strategy.dp = None # type: ignore
IStrategy.dp = None # type: ignore
self.epochs = self.load_previous_results(self.results_file) self.epochs = self.load_previous_results(self.results_file)