From a61274ae18541788d8d39756c433c2e90fb76011 Mon Sep 17 00:00:00 2001 From: robcaulk Date: Mon, 9 Jan 2023 20:04:36 +0100 Subject: [PATCH] ensure cached corr-pairs works with new framework --- docs/freqai-feature-engineering.md | 2 +- freqtrade/freqai/data_kitchen.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/freqai-feature-engineering.md b/docs/freqai-feature-engineering.md index 6b8636e28..6c8c5bb46 100644 --- a/docs/freqai-feature-engineering.md +++ b/docs/freqai-feature-engineering.md @@ -8,7 +8,7 @@ Low level feature engineering is performed in the user strategy within a set of |---------------|-------------| | `feature_engineering__expand_all()` | This optional function will automatically expand the defined features on the config defined `indicator_periods_candles`, `include_timeframes`, `include_shifted_candles`, and `include_corr_pairs`. | `feature_engineering__expand_basic()` | This optional function will automatically expand the defined features on the config defined `include_timeframes`, `include_shifted_candles`, and `include_corr_pairs`. Note: this function does *not* expand across `include_periods_candles`. -| `feature_engineering_standard()` | This optional function will be called once with the dataframe of the base timeframe. This is the final function to be called, which means that the dataframe entering this function will contain all the features and columns created by all other `feature_engineering_expand` functions. This function is a good place to do custom exotic feature extractions (e.g. tsfresh). This function is also a good place for any feature that should not be auto-expanded upon (e.g. day of the week). +| `feature_engineering_standard()` | This optional function will be called once with the dataframe of the base timeframe. This is the final function to be called, which means that the dataframe entering this function will contain all the features and columns from the base asset created by the other `feature_engineering_expand` functions. This function is a good place to do custom exotic feature extractions (e.g. tsfresh). This function is also a good place for any feature that should not be auto-expanded upon (e.g. day of the week). | `set_freqai_targets()` | Required function to set the targets for the model. All targets must be prepended with `&` to be recognized by the FreqAI internals. Meanwhile, high level feature engineering is handled within `"feature_parameters":{}` in the FreqAI config. Within this file, it is possible to decide large scale feature expansions on top of the `base_features` such as "including correlated pairs" or "including informative timeframes" or even "including recent candles." diff --git a/freqtrade/freqai/data_kitchen.py b/freqtrade/freqai/data_kitchen.py index c85ecdca3..3eb0906b1 100644 --- a/freqtrade/freqai/data_kitchen.py +++ b/freqtrade/freqai/data_kitchen.py @@ -1147,9 +1147,9 @@ class FreqaiDataKitchen: for pair in pairs: pair = pair.replace(':', '') # lightgbm doesnt like colons - valid_strs = [f"%-{pair}", f"%{pair}", f"%_{pair}"] - pair_cols = [col for col in dataframe.columns if - any(substr in col for substr in valid_strs)] + pair_cols = [col for col in dataframe.columns if col.startswith("%") + and f"{pair}_" in col] + if pair_cols: pair_cols.insert(0, 'date') corr_dataframes[pair] = dataframe.filter(pair_cols, axis=1) @@ -1327,6 +1327,7 @@ class FreqaiDataKitchen: dataframe = self.populate_features(dataframe.copy(), pair, strategy, corr_dataframes, base_dataframes) + dataframe = strategy.feature_engineering_standard(dataframe.copy()) # ensure corr pairs are always last for corr_pair in corr_pairs: if pair == corr_pair: @@ -1335,7 +1336,6 @@ class FreqaiDataKitchen: dataframe = self.populate_features(dataframe.copy(), corr_pair, strategy, corr_dataframes, base_dataframes, True) - dataframe = strategy.feature_engineering_standard(dataframe.copy()) dataframe = strategy.set_freqai_targets(dataframe.copy()) self.get_unique_classes_from_labels(dataframe)