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

Change reward function #49

Closed CharlyHunsicker closed 3 years ago

CharlyHunsicker commented 3 years ago

Would it be possible to make a function comparable to add_signals for changing the reward function? It would be nice to use custom KPI's as rewards for example risk-adjusted return.

Kind regards.

QuantumCrazy commented 3 years ago

@CharlyHunsicker Any idea how we can change the reward function with model parameters without making a specific function for it like add_signals?

AminHP commented 3 years ago

@CharlyHunsicker

Currently, there is no simple way to add custom KPIs. But, you can implement a new function similar to _calculate_reward or _calculate_profit and call it here. Of course, you need to rewrite the step method. A more simple but dirtier way is calling your custom function inside _calculate_reward or _calculate_profit.

AminHP commented 3 years ago

@QuantumCrazy

You can add some hyperparameters in the env and use them in the reward function. Then, try to tune these hyperparameters by a model and set them outside the reward function.

CharlyHunsicker commented 3 years ago

Thank you for your comment @AminHP.