AminHP / gym-mtsim

A general-purpose, flexible, and easy-to-use simulator alongside an OpenAI Gym trading environment for MetaTrader 5 trading platform (Approved by OpenAI Gym)
MIT License
428 stars 107 forks source link

A Complete Example using stable-baselines #26

Closed Error4046716 closed 1 year ago

Error4046716 commented 2 years ago
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[<ipython-input-6-4ca9ec63cf36>](https://localhost:8080/#) in <module>()
     11 # env = gym.make('crypto-hedge-v0')
     12 
---> 13 model = A2C('MultiInputPolicy', env, verbose=0)
     14 model.learn(total_timesteps=1000)
     15 

2 frames
[/usr/local/lib/python3.7/dist-packages/stable_baselines3/common/base_class.py](https://localhost:8080/#) in __init__(self, policy, env, learning_rate, policy_kwargs, tensorboard_log, verbose, device, support_multi_env, create_eval_env, monitor_wrapper, seed, use_sde, sde_sample_freq, supported_action_spaces)
    189                 assert np.all(
    190                     np.isfinite(np.array([self.action_space.low, self.action_space.high]))
--> 191                 ), "Continuous action space must have a finite lower and upper bound"
    192 
    193     @staticmethod

AssertionError: Continuous action space must have a finite lower and upper bound

Where can set the lower and upper bound? Thank you

AminHP commented 2 years ago

Hi @Error4046716,

I added some commits to make the repo compatible with the newer versions of gym. However, stable_baselines is not compatible yet. You can try using stable-baselines3==1.5.0 with gym==0.21.0 for now. Also, you can change the lower and upper bound here.

TomCS91 commented 2 years ago

This bug seems to still be active with the below versions.

Running torch 1.12.0 instead of 1.12.1 I thought fixed it as that worked on one machine but it didn't on another.

pip show stable-baselines3 Name: stable-baselines3 Version: 1.5.0

pip show gym Name: gym Version: 0.21.0

pip show torch Name: torch Version: 1.12.0

salah2025 commented 2 years ago

How can I add technical indicators ?

Emmanuel1524 commented 1 year ago

Just add some comment here: the Mtsim isnt working so well with StableBaseline3...

Even when I correct the Box adjustment bug, the algorithin doesn't fit so well with the RL algos

AminHP commented 1 year ago

Please install the latest version (v1.3.0).