stefan-jansen / machine-learning-for-trading

Code for Machine Learning for Algorithmic Trading, 2nd edition.
https://ml4trading.io
12.87k stars 4.11k forks source link

Code issue: Chapter 22_deep_reinforcement_learning 04_q_learning_for_trading #263

Closed KoalaChelsea closed 1 year ago

KoalaChelsea commented 1 year ago

I tried to reproduce the Q-Learning for trading, but there is an error when I run this notebook. I prepared data as instructed in data/create_datasets.ipynb. However, I still got the following error when creating the environment from trading_env.py

image

DavidHJong commented 1 year ago

Did you modify the trading_env.py? It seems that the DataSource.min_values and DataSource.max_values are not configured correctly.

Maathouse commented 1 year ago

It helped me to convert the min_values df to the following: self.min_values = self.data.min().to_numpy(). Don't have the complete code running atm by the way.

stefan-jansen commented 1 year ago

Please note that there have been several releases for the OpenAI gym. It's a good idea to run the latest software, but you'll need to adapt the examples to work with more recent versions accordingly.