AminHP / gym-anytrading

The most simple, flexible, and comprehensive OpenAI Gym trading environment (Approved by OpenAI Gym)
MIT License
2.09k stars 459 forks source link

Holding 0 position shall be encouraged when price is falling. #57

Closed GXY2017 closed 2 years ago

GXY2017 commented 2 years ago

Suggest adding this part in Stock.env()_calculate_reward(self, action). Holding 0 position, eg, holding cash, shall be encouraged when price is falling;or be punished when price is rising.

This will change reward, but will not affect profit if stock strategy is long only.

            # encourage 0 holdings when price is falling
            if self._position == Positions.Short:
                step_reward += -price_diff
AminHP commented 2 years ago

Hi @GXY2017, thank you for the suggestion.

This project was supposed to be a simple baseline for beginners when I started it. So, I think it is better to keep it that way. However, you can inherit from the StocksEnv class and add your improvement.

GXY2017 commented 2 years ago

Thank you for the reply. Its a very clean learning example. Close this here.