AI4Finance-Foundation / FinRL-Meta

FinRL­-Meta: Dynamic datasets and market environments for FinRL.
https://ai4finance.org
MIT License
1.24k stars 576 forks source link

The model does not sell at all #31

Open leonexu opened 2 years ago

leonexu commented 2 years ago

Hello, I tested the code Demo_MultipleCryptoTrading.ipynb for trading cryptocurrency. It seems that the model only buys without selling at all - the action is always positive (corresponding to buying). The initial balance is 100000. ![6d456a4bbb8869d1e7c79e9b61891bd3](https://user-images.githubusercontent.com/5246067/145134175-c411eeba-00f5-4079-b0f4-f6f16fbee688.jpg) e5bf496bcf2b4a7c1bb8cb0e7bbedcc8_ Is this something buggy and can you please help to fix it?

rayrui312 commented 2 years ago

If in the training period, the cryptocurrency market is mainly one-side rising, the agents may find that buy-and-hold is the best strategy. Using normal technical indicators such as macd, rsi, cci and so on, it is hard for agents to learn how to do trend trading when the market is mainly one-sided. To fix this, you may try the following methods:

  1. Try other technical indicators or add news/Twitter sentiment analysis to features. One of our users used Twitter sentiment analysis and the problem was solved well. He even made some profits in live trading.
  2. Try to train the agents on larger datasets. Since it is a tutorial/notebook, it is not convenient to use large datasets as the training time would be very long.
  3. Add a penalty to the reward function when the agent holds a cryptocurrency for a long time without any trades. It can encourage the agent to trade more and learn trend trading strategies.
leonexu commented 2 years ago

Thanks for your response very much. However, the model can sell during the training. My training dataset is 9/1-9/15, my test dataset is 9/16-9/30. Are the training and inference models the same?

rayrui312 commented 2 years ago

During the training, the agent has exploratory actions. During the testing/trading, it takes the best actions. Your case is probably because the agent tries to sell during the training but finds the return is worse. So it doesn't sell during testing/trading.