Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ra9hur
Copy link
Contributor

@ra9hur ra9hur commented Sep 1, 2024

closes #555

@ra9hur
Copy link
Contributor Author

ra9hur commented Sep 1, 2024

@simoninithomas ,

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.

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.

Copy link
Contributor Author

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.

Copy link

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 = {

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?

Copy link
Contributor Author

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")

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").

Copy link
Contributor Author

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)

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

Copy link
Contributor Author

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

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).

Copy link
Contributor Author

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.

@ra9hur
Copy link
Contributor Author

ra9hur commented Sep 25, 2024

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 !!

@ra9hur
Copy link
Contributor Author

ra9hur commented Oct 8, 2024

Thanks @dantp-ai for your reviews !!

Just wanted to check if this is good to be merged and go live.

@ra9hur
Copy link
Contributor Author

ra9hur commented Oct 26, 2024

@simoninithomas / @dantp-ai ,

Hope you are having a great day !!
I assume, have fixed all review comments and the PR has been dormant for the last 3 weeks.

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.

@dantp-ai
Copy link

LGTM. Nothing from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[UPDATE]FinRL in Unit8 Part3 as one of advance topics
2 participants