pythonlessons / RL-Bitcoin-trading-bot

Trying to create Reinforcement Learning powered Bitcoin trading bot
MIT License
380 stars 208 forks source link

Problem with visualizing img with OpenCV in utils.py #16

Open tom634 opened 2 years ago

tom634 commented 2 years ago

I run default script in the Windows 10 with: test_multiprocessing(CustomEnv, CustomAgent, test_df, test_df_nomalized, num_worker = 16, visualize=True, (...) im main.py.

When it comes to utils.py to line: img = img.reshape(self.fig.canvas.get_width_height()[::-1] + (3,)) I have error:

Traceback (most recent call last):
  File "C:\Users\Tomek\anaconda3\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "c:\Users\Tomek\Documents\binance_bot\RL-Bitcoin-trading-bot-main_my_version\multiprocessing_env.py", line 35, in run
    self.env.render(self.visualize)
  File "c:\Users\Tomek\Documents\binance_bot\RL-Bitcoin-trading-bot-main_my_version\RL-Bitcoin-trading-bot_7.py", line 324, in render
    img = self.visualization.render(self.df.loc[self.current_step], self.net_worth, self.trades)
  File "c:\Users\Tomek\Documents\binance_bot\RL-Bitcoin-trading-bot-main_my_version\utils.py", line 231, in render
    img  = img.reshape(self.fig.canvas.get_width_height()[::-1] + (3,))
ValueError: cannot reshape array of size 15360000 into shape (800,1600,3)

Prints are following:

print("2", img, "len", len(img))
print("3", self.fig.canvas.get_width_height())
print("4", self.fig.canvas.get_width_height()[::-1])
2 [255 255 255 ... 255 255 255] len 15360000
3 (1600, 800)
4 (800, 1600)

What should I do? figsize is:

# figsize attribute allows us to specify the width and height of a figure in unit inches
fig = plt.figure(figsize=(16,8))