Skip to content

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

@Chaosqing

Description

@Chaosqing

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions