-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advance Topics: New section for "RL for Trading" #558
base: main
Are you sure you want to change the base?
Conversation
As suggested, have created this PR to include a section for "RL for Trading" in advance topics. Please review and let me know for any changes. Thanks. |
### Create an environment with custom parameters | ||
|
||
You can change parameters such as dataset, frame_bound, etc while creating the environment. | ||
To try out and explore, you can use two default datasets available in the GitHub repository - [*FOREX*](https://github.com/AminHP/gym-anytrading/blob/master/gym_anytrading/datasets/data/FOREX_EURUSD_1H_ASK.csv) and [*Stocks*](https://github.com/AminHP/gym-anytrading/blob/master/gym_anytrading/datasets/data/STOCKS_GOOGL.csv), but you can use your own as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If using your own dataset requires having some pre-defined columns, it may be helpful to elaborate here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked their documentation and there is no mention of pre-defined columns for custom environments. Assume, the two sample datasets that are provided should be used as references.
Slightly wary of including this to avoid mentioning anything beyond documentation.
Please share your thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think you're right. I looked into the source-code too, and it seems that there are no special columns needed for df
. It's up to the user to extend TradingEnv
and use the columns they want.
|
||
# This is only for illustration. | ||
# Values such as state_space, stock_dimension should be derived in the notebook before using them here. | ||
env_kwargs = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't is simpler to give some mock (or default) values for all variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have made this clearer, hope this works.
Create a new environment using df_test to simulate test scenario. | ||
|
||
```python | ||
trained_ppo = PPO.load("trained_models/agent_ppo.zip") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PPO
is not imported anywhere in the notebook. I guess it can be retrieved e.g. through finrl.stablebaselines3.models.DRLAgent.get_model("ppo")
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is imported through stablebaseline3, have included a import statement.
|
||
df_account_value_ppo, df_actions_ppo = DRLAgent.DRL_prediction( | ||
model=trained_ppo, | ||
environment = e_test) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here e_test
-> env_test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, have updated this now.
Their [tutorial series](https://finrl.readthedocs.io/en/latest/tutorial/Guide.html) is very exhaustive and beginner friendly. One can choose to start at various levels depending on familiarity (introduction, advance, practical, optimization, others). | ||
|
||
|
||
## Additional readings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also this Gymnasium environment gym-trading-env
that might be worth mentioning in this section (cf. https://gym-trading-env.readthedocs.io/, linked also on Gymnasium docs under the Third-party Environments section https://gymnasium.farama.org/environments/third_party_environments/#gym-trading-env-trading-environment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestions, have included a link in additional readings.
Hi @dantp-ai , thanks for the detail reviews. I am slightly held up with another PR, will check your comments, make changes and re-submit by next weekend. Thanks again !! |
Thanks @dantp-ai for your reviews !! Just wanted to check if this is good to be merged and go live. |
Hope you are having a great day !! Was wondering if there is anything pending from my side. If you have been pondering on the topic relevance and whether to include this into the course material, understand. Please let me know either way. |
LGTM. Nothing from my side. |
closes #555