Yvictor / TradingGym

Trading and Backtesting environment for training reinforcement learning agent or simple rule base algo.
MIT License
1.57k stars 350 forks source link

AttributeError: 'trading_env' object has no attribute 'backtest' #19

Open Chaosqing opened 5 months ago

Chaosqing commented 5 months ago

Backtesting loading env just like training env = trading_env.make(env_id='backtest_v1', obs_data_len=1024, step_len=512, df=df, fee=0.1, max_position=5, deal_col_name='Price', feature_names=['Price', 'Volume', 'Ask_price','Bid_price', 'Ask_deal_vol','Bid_deal_vol', 'Bid/Ask_deal', 'Updown'])

start to backtest agent = YourAgent()

transactions = [] while not env.backtest_done: state = env.backtest()
done = False while not done: state, reward, done, info = env.step(agent.choice_action(state))

print(state, reward)

    #env.render()
    if done:
        transactions.append(info)
        break

transaction = pd.concate(transactions) transaction

Making new env: backtest_v1 Traceback (most recent call last): File "\TradingGym-master\BackTest.py", line 32, in state = env.backtest() AttributeError: 'trading_env' object has no attribute 'backtest'

how could I fix this.

LIZESHENG13 commented 3 months ago

I also encounter this problem,how do you fix this problem?