TradeMaster-NTU / TradeMaster

TradeMaster is an open-source platform for quantitative trading empowered by reinforcement learning :fire: :zap: :rainbow:
Apache License 2.0
1.35k stars 273 forks source link

How does the project fulfill to close all remaining positions at market price to avoid overnight risk and hold 100% cash again? #191

Closed alanyuwenche closed 9 months ago

alanyuwenche commented 10 months ago

First of all, thanks for the helpful project.

In 3.1 Intraday Trading the paper said, “At the end of the trading day, traders close all remaining positions at market price to avoid overnight risk and hold 100% cash again.”

I’ve studied this project for weeks, but I can’t figure out how the project fulfills the above statement in high frequency trading. I can only find the related code in trademaster/environments/high_frequency_trading/environment.py. At line 210 self.terminal can turn out to be true only when self.day is greater or equal to 25,000. That is, we have to run 25,000 steps before episode termination.

    def step(self, action):
        # 此处的action应为仓位变化
        normlized_action = action / (self.action_dim - 1)
        position = self.max_holding_number * normlized_action
        # 目前没有future embedding day代表最新一天的信息
        self.terminal = self.day >= len(self.df.index.unique()) - 1
        ............

If I miss something, please correct me. Thanks!

qinmoelei commented 9 months ago

Thanks for your feedback and your attention to this project! Sorry for the confusion. The high-frequency trading environment is designed for Binance crypto trading, where the trading goes for 24/7. So, there is no such thing as the overnight risk. So far in this environment, we have not implement such things as closing all the position at the end of the day.

alanyuwenche commented 9 months ago

Thanks for your replies. Hope to see this implement soon.