move record params to utils, use rapidjson

This commit is contained in:
robcaulk
2022-10-23 20:51:32 +02:00
parent bb06745227
commit 4d2b7a74f1
2 changed files with 30 additions and 22 deletions

View File

@@ -1,4 +1,3 @@
import json
import logging
import threading
import time
@@ -21,7 +20,7 @@ from freqtrade.exceptions import OperationalException
from freqtrade.exchange import timeframe_to_seconds
from freqtrade.freqai.data_drawer import FreqaiDataDrawer
from freqtrade.freqai.data_kitchen import FreqaiDataKitchen
from freqtrade.freqai.utils import plot_feature_importance
from freqtrade.freqai.utils import plot_feature_importance, record_params
from freqtrade.strategy.interface import IStrategy
@@ -97,7 +96,7 @@ class IFreqaiModel(ABC):
self._threads: List[threading.Thread] = []
self._stop_event = threading.Event()
self.record_params()
record_params(config, self.full_path)
def __getstate__(self):
"""
@@ -536,24 +535,6 @@ class IFreqaiModel(ABC):
)
self.full_path.mkdir(parents=True, exist_ok=True)
def record_params(self) -> None:
"""
Records run params in the full path for reproducibility
"""
self.params_record_path = self.full_path / "run_params.json"
run_params = {
"freqai": self.config.get('freqai', {}),
"timeframe": self.config.get('timeframe'),
"stake_amount": self.config.get('stake_amount'),
"stake_currency": self.config.get('stake_currency'),
"max_open_trades": self.config.get('max_open_trades'),
"pairs": self.config.get('exchange', {}).get('pair_whitelist')
}
with open(self.params_record_path, "w") as handle:
json.dump(run_params, handle, indent=4)
def extract_data_and_train_model(
self,
new_trained_timerange: TimeRange,