stefan-jansen / machine-learning-for-trading

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

04_q_learning_for_trading -> Error during Observation Space creation #284

Closed hacky1610 closed 1 year ago

hacky1610 commented 1 year ago

Describe the bug The creation of a Box in trading_env.py:242 is failung. The Datatype of the parameters is not correct. It has to be an nd_array.

Steps to reproduce the behavior:

  1. OPen 04_q_learning_for_trading
  2. Execute all

Expected behavior No error occurs

Screenshots image

Environment jupyter/datascience-notebook:latest

Solution: self.observation_space = spaces.Box(self.data_source.min_values.to_numpy(), self.data_source.max_values.to_numpy())

yeonmo317 commented 1 year ago

Describe the bug The creation of a Box in trading_env.py:242 is failung. The Datatype of the parameters is not correct. It has to be an nd_array.

Steps to reproduce the behavior:

1. OPen 04_q_learning_for_trading

2. Execute all

Expected behavior No error occurs

Screenshots image

Environment jupyter/datascience-notebook:latest

Solution: self.observation_space = spaces.Box(self.data_source.min_values.to_numpy(), self.data_source.max_values.to_numpy())

A million thanks! I was getting the same error and this worked :)