Extract data-load + dump from hyperopt
(Reduces memory-usage as the dataframes go out of scope)
This commit is contained in:
parent
24a1d5a96f
commit
1055862bc0
@ -345,12 +345,7 @@ class Hyperopt:
|
|||||||
def _set_random_state(self, random_state: Optional[int]) -> int:
|
def _set_random_state(self, random_state: Optional[int]) -> int:
|
||||||
return random_state or random.randint(1, 2**16 - 1)
|
return random_state or random.randint(1, 2**16 - 1)
|
||||||
|
|
||||||
def start(self) -> None:
|
def prepare_hyperopt_data(self) -> None:
|
||||||
self.random_state = self._set_random_state(self.config.get('hyperopt_random_state', None))
|
|
||||||
logger.info(f"Using optimizer random state: {self.random_state}")
|
|
||||||
self.hyperopt_table_header = -1
|
|
||||||
# Initialize spaces ...
|
|
||||||
self.init_spaces()
|
|
||||||
data, timerange = self.backtesting.load_bt_data()
|
data, timerange = self.backtesting.load_bt_data()
|
||||||
logger.info("Dataload complete. Calculating indicators")
|
logger.info("Dataload complete. Calculating indicators")
|
||||||
preprocessed = self.backtesting.strategy.ohlcvdata_to_dataframe(data)
|
preprocessed = self.backtesting.strategy.ohlcvdata_to_dataframe(data)
|
||||||
@ -367,6 +362,15 @@ class Hyperopt:
|
|||||||
|
|
||||||
dump(preprocessed, self.data_pickle_file)
|
dump(preprocessed, self.data_pickle_file)
|
||||||
|
|
||||||
|
def start(self) -> None:
|
||||||
|
self.random_state = self._set_random_state(self.config.get('hyperopt_random_state', None))
|
||||||
|
logger.info(f"Using optimizer random state: {self.random_state}")
|
||||||
|
self.hyperopt_table_header = -1
|
||||||
|
# Initialize spaces ...
|
||||||
|
self.init_spaces()
|
||||||
|
|
||||||
|
self.prepare_hyperopt_data()
|
||||||
|
|
||||||
# We don't need exchange instance anymore while running hyperopt
|
# We don't need exchange instance anymore while running hyperopt
|
||||||
self.backtesting.exchange.close()
|
self.backtesting.exchange.close()
|
||||||
self.backtesting.exchange._api = None # type: ignore
|
self.backtesting.exchange._api = None # type: ignore
|
||||||
|
Loading…
Reference in New Issue
Block a user