remove assertions, log error if user has not assigned freqai in config, fix stratify bug

This commit is contained in:
robcaulk 2022-05-25 11:43:45 +02:00
parent 35bed842cb
commit 7ff3258607
3 changed files with 34 additions and 29 deletions

View File

@ -62,7 +62,6 @@
"corr_pairlist": [
"BTC/USDT",
"ETH/USDT",
"LINK/USDT",
"DOT/USDT"
],
"feature_parameters": {

View File

@ -73,23 +73,26 @@ class FreqaiDataKitchen:
self.data_drawer = data_drawer
def assert_config(self, config: Dict[str, Any], live: bool) -> None:
assert config.get('freqai'), "No Freqai parameters found in config file."
assert config.get('freqai', {}).get('train_period'), ("No Freqai train_period found in"
"config file.")
assert type(config.get('freqai', {})
.get('train_period')) is int, ('Can only train on full day period.'
'No fractional days permitted.')
assert config.get('freqai', {}).get('backtest_period'), ("No Freqai backtest_period found"
"in config file.")
if not live:
assert type(config.get('freqai', {})
.get('backtest_period')) is int, ('Can only backtest on full day'
'backtest_period. Only live/dry mode'
'allows fractions of days')
assert config.get('freqai', {}).get('identifier'), ("No Freqai identifier found in config"
"file.")
assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai feature_parameters"
"found in config file.")
if not config.get('freqai'):
logger.error('No Freqai parameters found in config file.')
# assert config.get('freqai'), "No Freqai parameters found in config file."
# assert config.get('freqai', {}).get('train_period'), ("No Freqai train_period found in"
# "config file.")
# assert type(config.get('freqai', {})
# .get('train_period')) is int, ('Can only train on full day period.'
# 'No fractional days permitted.')
# assert config.get('freqai', {}).get('backtest_period'), ("No Freqai backtest_period found"
# "in config file.")
# if not live:
# assert type(config.get('freqai', {})
# .get('backtest_period')) is int, ('Can only backtest on full day'
# 'backtest_period. Only live/dry mode'
# 'allows fractions of days')
# assert config.get('freqai', {}).get('identifier'), ("No Freqai identifier found in config"
# "file.")
# assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai feature_parameters"
# "found in config file.")
def set_paths(self, metadata: dict, trained_timestamp: int = None,) -> None:
self.full_path = Path(self.config['user_data_dir'] /
@ -234,6 +237,8 @@ class FreqaiDataKitchen:
for i in range(1, len(stratification)):
if i % self.freqai_config.get("feature_parameters", {}).get("stratify", 0) == 0:
stratification[i] = 1
else:
stratification = None
(
train_features,

View File

@ -57,17 +57,18 @@ class IFreqaiModel(ABC):
self.config['exchange']['pair_whitelist'])
def assert_config(self, config: Dict[str, Any]) -> None:
assert config.get('freqai'), "No Freqai parameters found in config file."
assert config.get('freqai', {}).get('data_split_parameters'), ("No Freqai"
"data_split_parameters"
"in config file.")
assert config.get('freqai', {}).get('model_training_parameters'), ("No Freqai"
"modeltrainingparameters"
"found in config file.")
assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai"
"feature_parameters found in"
"config file.")
if not config.get('freqai'):
logger.error('No Freqai parameters found in config file.')
# assert config.get('freqai'), "No Freqai parameters found in config file."
# assert config.get('freqai', {}).get('data_split_parameters'), ("No Freqai"
# "data_split_parameters"
# "in config file.")
# assert config.get('freqai', {}).get('model_training_parameters'), ("No Freqai"
# "modeltrainingparameters"
# "found in config file.")
# assert config.get('freqai', {}).get('feature_parameters'), ("No Freqai"
# "feature_parameters found in"
# "config file.")
def start(self, dataframe: DataFrame, metadata: dict, strategy: IStrategy) -> DataFrame:
"""