Kismuz / btgym

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

BTgymEnv with state_shape parameter, incorrect type #50

Closed gittrainee323 closed 6 years ago

gittrainee323 commented 6 years ago

When using the parameter state_shape to create BTgymEnv, it will throw AttributeError: 'tuple' object has no attribute 'keys'

Running environment:

python 3, macosx

from btgym import BTgymEnv

MyEnvironment = BTgymEnv(filename='../examples/data/DAT_ASCII_EURUSD_M1_2016.csv', episode_duration={'days': 2, 'hours': 23, 'minutes': 55}, drawdown_call=50, state_shape=(4,20), port=5555, verbose=1, )

Files or part of package has been run:

backtrader.py

Actual behaviour:

[2018-04-19 01:04:56.697574] INFO: BTgymAPIshell_0: ...done. Traceback (most recent call last): [2018-04-19 01:04:56.698795] INFO: BTgymAPIshell_0: Base Cerebro class used. Base Strategy class used. File "/btgym/tests/quickstart.py", line 8, in verbose=1, File "/btgym/btgym/envs/backtrader.py", line 353, in init if 'raw_state' in self.params['strategy']['state_shape'].keys(): AttributeError: 'tuple' object has no attribute 'keys'

Kismuz commented 6 years ago

@gittrainee323 , see #44

gittrainee323 commented 6 years ago

Thanks you

Kismuz commented 6 years ago

Readme example fixed.