wassname / rl-portfolio-management

Attempting to replicate "A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem" https://arxiv.org/abs/1706.10059 (and an openai gym environment)
544 stars 179 forks source link

Gym #17

Closed ucfbrd closed 5 years ago

ucfbrd commented 6 years ago

Hello,

I have an issue running the environment command from GYM. Can you please help me address this issue.

Thank you


TypeError Traceback (most recent call last)

in () 7 window_length = window_length, 8 output_mode='EIIE', ----> 9 random_reset=False) 10 # wrap it in a few wrappers 11 env = ConcatStates(env) ~/Downloads/rl-portfolio-management-master/rl_portfolio_management/environments/portfolio.py in __init__(self, df, steps, trading_cost, time_cost, window_length, augment, output_mode, log_dir, scale, scale_extra_cols, random_reset) 266 nb_assets = len(self.src.asset_names) 267 self.action_space = gym.spaces.Box( --> 268 0.0, 1.0, shape=nb_assets + 1) 269 270 # get the history space from the data min and max ~/gym/gym/spaces/box.py in __init__(self, low, high, shape, dtype) 32 self.low = low.astype(dtype) 33 self.high = high.astype(dtype) ---> 34 gym.Space.__init__(self, shape, dtype) 35 36 def sample(self): ~/gym/gym/core.py in __init__(self, shape, dtype) 200 """ 201 def __init__(self, shape=None, dtype=None): --> 202 self.shape = None if shape is None else tuple(shape) 203 self.dtype = None if dtype is None else np.dtype(dtype) 204 TypeError: 'int' object is not iterable
wassname commented 6 years ago

What versions of everything are you using? The ideal ones are here

ucfbrd commented 6 years ago

Thank you for your quick reply, I have the right requirements except tensorflow-gpu (I have tensorflow 1.8), though I believe the error comes from the library gym, that I didn't figure out the fix :/. Please let me know if you have any ideas.

Thank you

wassname commented 6 years ago

Cheers, so what's the exact gym version so I can try and replicate it (conda list, or pip freeze will tell you)?

Does this change work? At rl_portfolio_management/environments/portfolio.py # 286 change line 286 from 0.0, 1.0, shape=nb_assets + 1) to 0.0, 1.0, shape=(nb_assets + 1,)) That changing the input shape from a int to a tuple, it seems to be what gym is expecting.

ucfbrd commented 6 years ago

absl-py==0.2.0 alabaster==0.7.10 anaconda-client==1.6.14 anaconda-navigator==1.8.3 anaconda-project==0.8.2 appnope==0.1.0 appscript==1.0.1 asn1crypto==0.24.0 astor==0.6.2 astroid==1.6.1 astropy==2.0.3 atari-py==0.1.1 attrs==17.4.0 Babel==2.5.3 backports.shutil-get-terminal-size==1.0.0 beautifulsoup4==4.6.0 bitarray==0.8.1 bkcharts==0.2 blaze==0.11.3 bleach==1.5.0 bokeh==0.12.13 boto==2.48.0 Bottleneck==1.2.1 certifi==2018.1.18 cffi==1.11.4 chardet==3.0.4 click==6.7 cloudpickle==0.5.2 clyent==1.2.2 cmake==3.11.0 colorama==0.3.9 conda==4.5.1 conda-build==3.4.1 conda-verify==2.0.0 contextlib2==0.5.5 cryptography==2.1.4 cvxopt==1.2.0 cycler==0.10.0 Cython==0.27.3 cytoolz==0.9.0 dask==0.17.2 datashape==0.5.4 decorator==4.2.1 distributed==1.21.6 docutils==0.14 entrypoints==0.2.3 et-xmlfile==1.0.1 fastcache==1.0.2 filelock==2.0.13 Flask==0.12.2 Flask-Cors==3.0.3 future==0.16.0 gast==0.2.0 gevent==1.2.2 glob2==0.6 gmpy2==2.0.8 greenlet==0.4.12 grpcio==1.11.0 gym==0.9.3 h5py==2.7.0 heapdict==1.0.0 html5lib==0.9999999 idna==2.6 imageio==2.2.0 imagesize==0.7.1 ipykernel==4.8.0 ipython==6.2.1 ipython-genutils==0.2.0 ipywidgets==7.1.1 isort==4.2.15 itsdangerous==0.24 jdcal==1.3 jedi==0.12.0 Jinja2==2.10 jsonschema==2.6.0 jupyter==1.0.0 jupyter-client==5.2.2 jupyter-console==5.2.0 jupyter-core==4.4.0 jupyterlab==0.31.5 jupyterlab-launcher==0.10.5 Keras==2.1.5 lazy-object-proxy==1.3.1 llvmlite==0.21.0 locket==0.2.0 lxml==4.1.1 Markdown==2.6.11 MarkupSafe==1.0 matplotlib==2.0.2 mccabe==0.6.1 mistune==0.8.3 mpmath==1.0.0 msgpack-python==0.5.1 multipledispatch==0.4.9 navigator-updater==0.1.0 nbconvert==5.3.1 nbformat==4.4.0 networkx==2.1 nltk==3.2.5 nose==1.3.7 notebook==5.4.0 numba==0.36.2 numexpr==2.6.4 numpy==1.14.2 numpydoc==0.7.0 odo==0.5.1 olefile==0.45.1 openpyxl==2.4.10 packaging==16.8 pandas==0.20.3 pandocfilters==1.4.2 parso==0.2.0 partd==0.3.8 path.py==10.5 pathlib2==2.3.0 patsy==0.5.0 pep8==1.7.1 pexpect==4.3.1 pickleshare==0.7.4 Pillow==5.0.0 pkginfo==1.4.1 pluggy==0.6.0 ply==3.10 prompt-toolkit==1.0.15 protobuf==3.5.2.post1 psutil==5.4.3 ptyprocess==0.5.2 py==1.5.2 pycodestyle==2.3.1 pycosat==0.6.3 pycparser==2.18 pycrypto==2.6.1 pycurl==7.43.0.1 pyflakes==1.6.0 pyglet==1.3.2 Pygments==2.2.0 pylint==1.8.2 Pympler==0.5 pyodbc==4.0.22 PyOpenGL==3.1.0 pyOpenSSL==17.5.0 pyparsing==2.2.0 PySocks==1.6.7 pytest==3.3.2 python-dateutil==2.6.1 pytz==2017.3 PyWavelets==0.5.2 PyYAML==3.12 pyzmq==16.0.3 QtAwesome==0.4.4 qtconsole==4.3.1 QtPy==1.3.1 requests==2.18.4 retry==0.9.2 retrying==1.3.3 rope==0.10.7 ruamel-yaml==0.15.35 scikit-image==0.13.1 scikit-learn==0.19.1 scipy==1.0.0 seaborn==0.8 Send2Trash==1.4.2 simplegeneric==0.8.1 singledispatch==3.4.0.3 six==1.11.0 snowballstemmer==1.2.1 sortedcollections==0.5.3 sortedcontainers==1.5.9 Sphinx==1.6.6 sphinxcontrib-websupport==1.0.1 spyder==3.2.6 SQLAlchemy==1.2.1 statsmodels==0.8.0 sympy==1.1.1 tables==3.4.2 tblib==1.3.2 tensorboard==1.6.0 tensorboard-logger==0.1.0 tensorboardX==0.8 tensorflow==1.7.0rc1 tensorforce==0.3.5.1 termcolor==1.1.0 terminado==0.8.1 testpath==0.3.1 tflearn==0.3.2 toolz==0.9.0 torch==0.3.0.post4 torchvision==0.1.8 tornado==4.5.3 tqdm==4.19.2 traitlets==4.3.2 typing==3.6.2 unicodecsv==0.14.1 urllib3==1.22 wcwidth==0.1.7 webencodings==0.5.1 Werkzeug==0.14.1 widgetsnbextension==3.1.0 wrapt==1.10.11 xlrd==1.1.0 XlsxWriter==1.0.2 xlwings==0.11.5 xlwt==1.2.0 zict==0.1.3

Thank you for the fix, it solved the issue :), I am running into other issues (with a bumpy testing method )but will delve into them in details :)

wassname commented 6 years ago

It's weird it work for my with gym==0.9.3. Could you please try and run the code below, to see the location of the gym module your importing (sometimes there are multiple installed).

print(gym.__file__, gym.__version__)
gym.spaces.Box(0.0, 1.0, shape=5)