Kismuz / btgym

Scalable, event-driven, deep-learning-friendly backtesting library
https://kismuz.github.io/btgym/
GNU Lesser General Public License v3.0
984 stars 260 forks source link

Problem to run the code #34

Closed Nicolas99-9 closed 6 years ago

Nicolas99-9 commented 6 years ago

I have a problem to run the code, after the first epoch, I call the function env.reset() to start a new one but I have the following error :

WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype. WARN: gym.spaces.Box autodetected dtype as <class 'numpy.float32'>. Please provide explicit dtype. WARN: Environment '<class 'btgym.envs.backtrader.BTgymEnv'>' has deprecated methods. Compatibility code invoked. learning-rules.py:320: RuntimeWarning: overflow encountered in multiply self.states = self.states+ learning_rateestimated_valuetraces learning-rules.py:320: RuntimeWarning: invalid value encountered in multiply self.states = self.states+ learning_rateestimated_valuetraces learning-rules.py:320: RuntimeWarning: invalid value encountered in add self.states = self.states+ learning_rateestimated_valuetraces Episode 1 finished /home/nicolas/.local/lib/python3.5/site-packages/matplotlib/lines.py:44: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1. if is_string_like(style) and is_hashable(style): /home/nicolas/.local/lib/python3.5/site-packages/matplotlib/style/core.py:92: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1. if cbook.is_string_like(style) or hasattr(style, 'keys'): /home/nicolas/.local/lib/python3.5/site-packages/matplotlib/style/core.py:99: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1. if not cbook.is_string_like(style): /home/nicolas/.local/lib/python3.5/site-packages/matplotlib/font_manager.py:971: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1. if is_string_like(family): /home/nicolas/.local/lib/python3.5/site-packages/matplotlib/font_manager.py:697: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1. if is_string_like(family): /home/nicolas/.local/lib/python3.5/site-packages/matplotlib/text.py:218: MatplotlibDeprecationWarning: The is_string_like function was deprecated in version 2.1. elif is_string_like(fontproperties): Process BTgymServer-2: Traceback (most recent call last): File "/usr/lib/python3.5/multiprocessing/process.py", line 249, in _bootstrap self.run() File "/home/nicolas/Documents/trading/btgym/btgym/server.py", line 453, in run episode = cerebro.run(stdstats=True, preload=False, oldbuysell=True)[0] File "/usr/local/lib/python3.5/dist-packages/backtrader/cerebro.py", line 1127, in run runstrat = self.runstrategies(iterstrat) File "/usr/local/lib/python3.5/dist-packages/backtrader/cerebro.py", line 1295, in runstrategies self._runnext(runstrats) File "/usr/local/lib/python3.5/dist-packages/backtrader/cerebro.py", line 1626, in _runnext strat._next() File "/usr/local/lib/python3.5/dist-packages/backtrader/strategy.py", line 328, in _next self._next_analyzers(minperstatus) File "/usr/local/lib/python3.5/dist-packages/backtrader/strategy.py", line 362, in _next_analyzers analyzer._next() File "/usr/local/lib/python3.5/dist-packages/backtrader/analyzer.py", line 188, in _next self.next() File "/home/nicolas/Documents/trading/btgym/btgym/server.py", line 158, in next self.early_stop() File "/home/nicolas/Documents/trading/btgym/btgym/server.py", line 80, in early_stop self.render.render(self.render_at_stop, step_to_render=self.step_to_render, send_img=False) File "/home/nicolas/Documents/trading/btgym/btgym/rendering/renderer.py", line 284, in render xlabel=self.render_xlabel, File "/home/nicolas/Documents/trading/btgym/btgym/rendering/renderer.py", line 312, in draw_plot self.plt.title(title) File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/pyplot.py", line 1465, in title return gca().set_title(s, *args, kwargs) File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/pyplot.py", line 950, in gca return gcf().gca(kwargs) File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/figure.py", line 1369, in gca return self.add_subplot(1, 1, 1, *kwargs) File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/figure.py", line 1021, in add_subplot a = subplot_class_factory(projection_class)(self, args, kwargs) File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/axes/_subplots.py", line 73, in init self._axes_class.init(self, fig, self.figbox, kwargs) File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 529, in init self._init_axis() File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/axes/_base.py", line 622, in _init_axis self.xaxis = maxis.XAxis(self) File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/axis.py", line 676, in init self.cla() File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/axis.py", line 760, in cla self.reset_ticks() File "/home/nicolas/.local/lib/python3.5/site-packages/matplotlib/axis.py", line 771, in reset_ticks cbook.popall(self.majorTicks) AttributeError: module 'matplotlib.cbook' has no attribute 'popall' Traceback (most recent call last): File "learning-rules.py", line 335, in q.learning(env) File "learning-rules.py", line 304, in learning current_state = env.reset() File "/home/nicolas/Documents/trading/btgym/btgym/envs/backtrader.py", line 595, in _reset if self._force_control_mode(): File "/home/nicolas/Documents/trading/btgym/btgym/envs/backtrader.py", line 509, in _force_control_mode self.server_response = self.socket.recv_pyobj() File "/home/nicolas/.local/lib/python3.5/site-packages/zmq/sugar/socket.py", line 491, in recv_pyobj msg = self.recv(flags) File "zmq/backend/cython/socket.pyx", line 693, in zmq.backend.cython.socket.Socket.recv File "zmq/backend/cython/socket.pyx", line 727, in zmq.backend.cython.socket.Socket.recv File "zmq/backend/cython/socket.pyx", line 150, in zmq.backend.cython.socket._recv_copy File "zmq/backend/cython/socket.pyx", line 145, in zmq.backend.cython.socket._recv_copy File "zmq/backend/cython/checkrc.pxd", line 19, in zmq.backend.cython.checkrc._check_rc zmq.error.Again: Resource temporarily unavailable

Kismuz commented 6 years ago

@Nicolas99-9,

  1. Seems you have matplotlib 2.1 installed, see: https://github.com/Kismuz/btgym#-current-issues-and-limitations and #19
  2. Deprecation warnings (not critical) )are due to gym changes made 25.01.18; will sort it out soon.
Kismuz commented 6 years ago

changes been made to remove deprecation warnings, update.