hackthemarket / gym-trading

Environment for reinforcement-learning algorithmic trading models
MIT License
699 stars 214 forks source link

Environment isn't getting created upon running test_policy_gradients.py #1

Open sankethvedula opened 7 years ago

sankethvedula commented 7 years ago

Hi,

I am kind of new to this OpenAI Gym.

While I was trying to run the test_policy_gradient.py file, I am getting the following error.

[2017-04-16 07:51:37,265] policy_gradient logger started.
[2017-04-16 07:51:37,266] Making new env: trading-v0
Traceback (most recent call last):
  File "test_policy_gradient.py", line 17, in <module>
    env = gym.make('trading-v0')
  File "/home/ubuntu/gym/gym/envs/registration.py", line 161, in make
    return registry.make(id)
  File "/home/ubuntu/gym/gym/envs/registration.py", line 118, in make
    spec = self.spec(id)
  File "/home/ubuntu/gym/gym/envs/registration.py", line 147, in spec
    raise error.UnregisteredEnv('No registered env with id: {}'.format(id))
gym.error.UnregisteredEnv: No registered env with id: trading-v0

trying to debug, I included " import gym_trading" in the beginning of the file.

Now, I am facing the following error unnamed 1

I understand that for some reason, the data frame isn't getting downloaded when I "make" the gym to create an environment, which is why I suspect I am getting this error.

Could you please point out where I am going wrong? Or if there is any fix around this?

Thanks a lot in advance! Sanketh

baolinliu commented 7 years ago

this worked for me, it is in the init.py file in he gym_trading folder

from gym.envs.registration import register

register( id='trading-v1', entry_point='gym_trading.envs:TradingEnv', timestep_limit=1000)

ackdav commented 7 years ago

I'm having the same issue - and both proposed solutions didnt work...

ackdav commented 7 years ago

here is the error:

[2017-06-07 14:21:50,524] policy_gradient logger started.
[2017-06-07 14:21:50,524] Making new env: trading-v0
Traceback (most recent call last):
  File "envs/test_policy_gradient.py", line 16, in <module>
    env = gym.make('trading-v0')
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 161, in make
    return registry.make(id)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 118, in make
    spec = self.spec(id)
  File "/usr/local/lib/python2.7/dist-packages/gym/envs/registration.py", line 147, in spec
    raise error.UnregisteredEnv('No registered env with id: {}'.format(id))
gym.error.UnregisteredEnv: No registered env with id: trading-v0

tried importing gym_pull as suggested, but "no module named gym_trading"

baolinliu commented 7 years ago

id='trading-v1', called the environment v1

ackdav commented 7 years ago

@baolinliu thanks but how does that help? Now it's: gym.error.UnregisteredEnv: No registered env with id: trading-v1

ackdav commented 7 years ago

I tried around for a few days, but in the end it worked with sudo pip install -e . I'm not sure why using the -e flag made it work.

also I had to move the register call into test_policy_gradient.

Additionally with newer gym version you'd need to call env=env.unwrapped

lwhuang commented 7 years ago

can't get it work. what's the install procedure? pip install -e . shows Running setup.py develop for gym-trading Successfully installed gym-trading

but still gym.error.UnregisteredEnv: No registered env with id: trading-v0

crescentluna commented 6 years ago

according to registration.py of gym library, env object is wrapped in a TimeLimit object env = TimeLimit(env, max_episode_steps=env.spec.max_episode_steps,max_episode_seconds=env.spec.max_episode_seconds) so use env.env to run those methods such as run_strats

sophieyl commented 6 years ago

the reason is that the environment did't register into the gym module. change the init.py file in the same directory with env as below: from gym.envs.registration import register

register( id='trading-v0', entry_point='gym_trading.envs.trading_env:TradingEnv', timestep_limit=1000, ) the entry_point should be 'gym_trading.envs.trading_env:TradingEnv'

erdult commented 6 years ago

still not working

melseifi commented 5 years ago

Not working for me either. If I include import gym_trading, it doesn't pass this step. and if I comment it, I get the registration error above.

wongchunghang commented 5 years ago

After some packages update(e.g. the gym module), the notebook in the github will throw errors. So I fixed some of the issues and also made the corresponding changes required so that it can run smoothly in colab. You may find the colab notebook link here: https://colab.research.google.com/drive/14OIx32e_pzqpMIhhRcPV5CMAHUAwVQK1

WilliamGast commented 2 years ago

After running this code:

trading_environment = gym.make('trading-v0', ticker='AAPL', trading_days=trading_days, trading_cost_bps=trading_cost_bps, time_cost_bps=time_cost_bps) trading_environment.seed(42)

I get an assertion error and I don't know how to get past it if anyone can help.

RoyZhangxiquan commented 1 year ago

image