Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strategy.run(episodes=episodes, render_mode="chart")
 -> IndexError: index -1 is out of bounds for axis 0 with size 0 #115

Closed
tempsvps opened this issue Nov 23, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@tempsvps
Copy link

System information

  • OS Platform and Distribution Windows 10
  • TensorTrade version:
  • TensorFlow version: 1.15.0
  • Python version: 3.6

Describe the current behavior
Testing new chart render. Errror:
"C:\Users\Miner\Documents\GitHub!MyTensorTrader\tensortrade\environments\render\matplotlib_trading_chart.py", line 132, in render
net_worth = round(net_worths[-1], 2)
IndexError: index -1 is out of bounds for axis 0 with size 0

Describe the expected behavior

Code to reproduce the issue
episodes = 1
performance = strategy.run(episodes=episodes, render_mode="chart")


Other info / logs

Traceback (most recent call last):
File "C:/Users/Miner/Documents/GitHub/!MyTensorTrader/main.py", line 83, in
performance = strategy.run(episodes=episodes, render_mode="chart")
File "C:\Users\Miner\Documents\GitHub!MyTensorTrader\tensortrade\strategies\stable_baselines_strategy.py", line 116, in run
self._environment.render(mode=render_mode)
File "C:\ProgramData\Anaconda3\envs\PYTrade\lib\site-packages\stable_baselines\common\vec_env\dummy_vec_env.py", line 64, in render
return self.envs[0].render(*args, **kwargs)
File "C:\Users\Miner\Documents\GitHub!MyTensorTrader\tensortrade\environments\trading_environment.py", line 248, in render
self.exchange.trades)
File "C:\Users\Miner\Documents\GitHub!MyTensorTrader\tensortrade\environments\render\matplotlib_trading_chart.py", line 132, in render
net_worth = round(net_worths[-1], 2)
IndexError: index -1 is out of bounds for axis 0 with size 0

@kuaige99
Copy link

kuaige99 commented Dec 2, 2019

There was a bug: environment will be reset before render.
stable-baselines will reset env in the _environment.step when environments is done.
code
The solution: in render funtion modify code
if self.viewer is not None and self._current_step > 1:

@notadamking notadamking added the bug Something isn't working label Dec 9, 2019
@notadamking
Copy link
Collaborator

Fixed in #125

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants