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

Issue while running code #29

Closed
Nicolas99-9 opened this issue Jan 5, 2018 · 1 comment
Closed

Issue while running code #29

Nicolas99-9 opened this issue Jan 5, 2018 · 1 comment

Comments

@Nicolas99-9
Copy link

Nicolas99-9 commented Jan 5, 2018

I have two issues while running the code, first one is when I try to run a basic environment. After performing the first action, I receive the following error :
ValueError: too many values to unpack (expected 4)
and when I print the output of env.step(action) :
"No key received:Server Control mode: received <{'action': 'hold'}>"

from btgym import BTgymEnv from policy_gradient import PolicyGradient import numpy as np env = BTgymEnv(filename='../examples/data/DAT_ASCII_EURUSD_M1_2016.csv',) done = False while not done: action = env.action_space.sample() obs, reward, done, info = env.step(action) print(reward)

Second issue is related to the rewards, the are equal to 0 whatever the actions I choose.

@Kismuz
Copy link
Owner

Kismuz commented Jan 5, 2018

@Nicolas99-9 ,

Due to Gym API convention it is essential to call env.reset() before taking steps. Try this way:

from btgym import BTgymEnv

env = BTgymEnv(filename='../examples/data/DAT_ASCII_EURUSD_M1_2016.csv',) 

done = False 

init_obs = env.reset()

while not done: 
    action = env.action_space.sample() 
    obs, reward, done, info = env.step(action) 
    print('action: {}\nreward: {}\ninfo: {}'.format(action, reward, info))
    
env.close()

Anyway error message you receive trying to run uninitialised environment should be more informative. Need to sort it out.

As for zero-reward, see related question: #27 .
Pay attention to broker message part of info output when running script above - you'll see 'ORDER FAILED with status: Margin', cause no sufficient cash has been set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants