AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
10.09k stars 2.43k forks source link

Implementing long-short strategy #580

Closed minjunp closed 2 years ago

minjunp commented 2 years ago

Hi guys,

Let's say we are dealing with 10 stocks. Among them, I'm trying to implement an algorithm that forces the model to choose only 2 stocks to long and 2 stocks to short.

How would you be able to achieve this? I assume there should be modifications in the action_space in env_stocktrading.py. Do you have any suggestions?

zhumingpassional commented 2 years ago

Good problem.

Yes. Just like the modeling in operations research , the MDP model should be revised to achieve this.

We should constrain the number of long and short stocks using 0-1 flags. We should also constrain the period for them.

minjunp commented 2 years ago

Thank you for the reply,

Can you elaborate on constraining part? Since action_space is bounded by low and high, I wonder how to achieve forcing the number of buys and sells. Also, how can you constrain the period? For example, I longed and shorted 2 stocks at the same time, hold it for 5 days, dispose all, and repeat the process. Thanks in advance!

zhumingpassional commented 2 years ago

You can read StockTradingEnvCashpenalty in finrl.

In the long-period, keep the actions not change. The reward calculation will also be redefined.

It's an interesting topic, however, I do not have time to work on it. We hope you can produce good works on it.

minjunp commented 2 years ago

I will work on my part.

Thank you!