ensure normalization acceleration methods are employed in RL
This commit is contained in:
parent
6746868ea7
commit
9c6b97c678
@ -38,8 +38,6 @@ where `ReinforcementLearner` will use the templated `ReinforcementLearner` from
|
|||||||
self, pair, df, tf, informative=None, set_generalized_indicators=False
|
self, pair, df, tf, informative=None, set_generalized_indicators=False
|
||||||
):
|
):
|
||||||
|
|
||||||
coin = pair.split('/')[0]
|
|
||||||
|
|
||||||
if informative is None:
|
if informative is None:
|
||||||
informative = self.dp.get_pair_dataframe(pair, tf)
|
informative = self.dp.get_pair_dataframe(pair, tf)
|
||||||
|
|
||||||
@ -47,15 +45,15 @@ where `ReinforcementLearner` will use the templated `ReinforcementLearner` from
|
|||||||
for t in self.freqai_info["feature_parameters"]["indicator_periods_candles"]:
|
for t in self.freqai_info["feature_parameters"]["indicator_periods_candles"]:
|
||||||
|
|
||||||
t = int(t)
|
t = int(t)
|
||||||
informative[f"%-{coin}rsi-period_{t}"] = ta.RSI(informative, timeperiod=t)
|
informative[f"%-{pair}rsi-period_{t}"] = ta.RSI(informative, timeperiod=t)
|
||||||
informative[f"%-{coin}mfi-period_{t}"] = ta.MFI(informative, timeperiod=t)
|
informative[f"%-{pair}mfi-period_{t}"] = ta.MFI(informative, timeperiod=t)
|
||||||
informative[f"%-{coin}adx-period_{t}"] = ta.ADX(informative, window=t)
|
informative[f"%-{pair}adx-period_{t}"] = ta.ADX(informative, window=t)
|
||||||
|
|
||||||
# The following features are necessary for RL models
|
# The following features are necessary for RL models
|
||||||
informative[f"%-{coin}raw_close"] = informative["close"]
|
informative[f"%-{pair}raw_close"] = informative["close"]
|
||||||
informative[f"%-{coin}raw_open"] = informative["open"]
|
informative[f"%-{pair}raw_open"] = informative["open"]
|
||||||
informative[f"%-{coin}raw_high"] = informative["high"]
|
informative[f"%-{pair}raw_high"] = informative["high"]
|
||||||
informative[f"%-{coin}raw_low"] = informative["low"]
|
informative[f"%-{pair}raw_low"] = informative["low"]
|
||||||
|
|
||||||
indicators = [col for col in informative if col.startswith("%")]
|
indicators = [col for col in informative if col.startswith("%")]
|
||||||
# This loop duplicates and shifts all indicators to add a sense of recency to data
|
# This loop duplicates and shifts all indicators to add a sense of recency to data
|
||||||
@ -88,10 +86,10 @@ Most of the function remains the same as for typical Regressors, however, the fu
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# The following features are necessary for RL models
|
# The following features are necessary for RL models
|
||||||
informative[f"%-{coin}raw_close"] = informative["close"]
|
informative[f"%-{pair}raw_close"] = informative["close"]
|
||||||
informative[f"%-{coin}raw_open"] = informative["open"]
|
informative[f"%-{pair}raw_open"] = informative["open"]
|
||||||
informative[f"%-{coin}raw_high"] = informative["high"]
|
informative[f"%-{pair}raw_high"] = informative["high"]
|
||||||
informative[f"%-{coin}raw_low"] = informative["low"]
|
informative[f"%-{pair}raw_low"] = informative["low"]
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, there is no explicit "label" to make - instead the you need to assign the `&-action` column which will contain the agent's actions when accessed in `populate_entry/exit_trends()`. In the present example, the user set the neutral action to 0. This value should align with the environment used. FreqAI provides two environments, both use 0 as the neutral action.
|
Finally, there is no explicit "label" to make - instead the you need to assign the `&-action` column which will contain the agent's actions when accessed in `populate_entry/exit_trends()`. In the present example, the user set the neutral action to 0. This value should align with the environment used. FreqAI provides two environments, both use 0 as the neutral action.
|
||||||
|
@ -253,18 +253,26 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
|||||||
Builds the train prices and test prices for the environment.
|
Builds the train prices and test prices for the environment.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
coin = pair.split('/')[0]
|
pair = pair.replace(':', '')
|
||||||
train_df = data_dictionary["train_features"]
|
train_df = data_dictionary["train_features"]
|
||||||
test_df = data_dictionary["test_features"]
|
test_df = data_dictionary["test_features"]
|
||||||
|
|
||||||
# price data for model training and evaluation
|
# price data for model training and evaluation
|
||||||
tf = self.config['timeframe']
|
tf = self.config['timeframe']
|
||||||
ohlc_list = [f'%-{coin}raw_open_{tf}', f'%-{coin}raw_low_{tf}',
|
ohlc_list = [f'%-{pair}raw_open_{tf}', f'%-{pair}raw_low_{tf}',
|
||||||
f'%-{coin}raw_high_{tf}', f'%-{coin}raw_close_{tf}']
|
f'%-{pair}raw_high_{tf}', f'%-{pair}raw_close_{tf}']
|
||||||
rename_dict = {f'%-{coin}raw_open_{tf}': 'open', f'%-{coin}raw_low_{tf}': 'low',
|
rename_dict = {f'%-{pair}raw_open_{tf}': 'open', f'%-{pair}raw_low_{tf}': 'low',
|
||||||
f'%-{coin}raw_high_{tf}': ' high', f'%-{coin}raw_close_{tf}': 'close'}
|
f'%-{pair}raw_high_{tf}': ' high', f'%-{pair}raw_close_{tf}': 'close'}
|
||||||
|
|
||||||
prices_train = train_df.filter(ohlc_list, axis=1)
|
prices_train = train_df.filter(ohlc_list, axis=1)
|
||||||
|
if prices_train.empty:
|
||||||
|
raise OperationalException('Reinforcement learning module didnt find the raw prices '
|
||||||
|
'assigned in populate_any_indicators. Please assign them '
|
||||||
|
'with:\n'
|
||||||
|
'informative[f"%-{pair}raw_close"] = informative["close"]\n'
|
||||||
|
'informative[f"%-{pair}raw_open"] = informative["open"]\n'
|
||||||
|
'informative[f"%-{pair}raw_high"] = informative["high"]\n'
|
||||||
|
'informative[f"%-{pair}raw_low"] = informative["low"]\n')
|
||||||
prices_train.rename(columns=rename_dict, inplace=True)
|
prices_train.rename(columns=rename_dict, inplace=True)
|
||||||
prices_train.reset_index(drop=True)
|
prices_train.reset_index(drop=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user