AI4Finance-Foundation / FinRL-Meta

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

关于China_A_share_market_tushare的一个疑惑 #203

Open tdg2088 opened 2 years ago

tdg2088 commented 2 years ago

China的股票采用T+1的交易制度。我在跑China_A_share_market_tushare的例子的时候,val_start_date='20220619', val_stop_date='20220701';在account的输出中包含20220701的账户余额,但是在actions的输出中未包含20220701的账户操作,使用的是stablebaselines3的SAC Agent。但是我现在的需求是在盘尾根据OHLCV预测Action。我看了一下DRL_prediction的实现方式: for i in range(len(environment.df.index.unique())): action, _states = model.predict(test_obs, deterministic=deterministic)

account_memory = test_env.env_method(method_name="save_asset_memory")

        # actions_memory = test_env.env_method(method_name="save_action_memory")
        test_obs, rewards, dones, info = test_env.step(action)
        if i == (len(environment.df.index.unique()) - 2):(在循环到df的倒数第二行就形成结果了)
            account_memory = test_env.env_method(method_name="save_asset_memory")
            actions_memory = test_env.env_method(method_name="save_action_memory")
        #                 state_memory=test_env.env_method(method_name="save_state_memory") # add current state to state memory
        if dones[0]:
            print("hit end!")
            break
    return account_memory[0], actions_memory[0]

这种设计的用意何在?如果我需要实现盘尾根据OHLCV预测Action,该如何修改?