AminHP / gym-anytrading

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

Reward computation for stockEnv #38

Closed sabeaussan closed 3 years ago

sabeaussan commented 3 years ago

Hi AminHp,

Really great work, the code is very pleasant to read. I have a question regarding the _calculate_reward function in the StocksEnvs : why is the step_reward only updated when we sell a long position ? As I understand buying after a short position should also generate profit/a loss and thus the agent should be rewarded accordingly but it is not taken into account if i'm correct. Forgive me if this is a noob question, I just got into finance and stock trading yesterday.

Best regards,

AminHP commented 3 years ago

Hi @sabeaussan

Thank you I'm glad it was helpful :)

In some markets only long trades are profitable. But it is possible to use the reward/profit function implemented in the ForexEnv if you want to make short trades profitable.