Skip to content

Error while rendering environment? #8

@fightthepower

Description

@fightthepower

Thank you for this I was looking for something like this. when I am trying out this I am getting a assertion error like this

self.ax.lines.remove(self.price_plot[0])
AttributeError: 'trading_env' object has no attribute 'ax'

data frame sample

>>> df.head()
   serial_number        Date   Open   High    Low  Close      Volume
0              0  1998-01-02  13.63  16.25  13.50  16.25   6411700.0
1              1  1998-01-05  16.50  16.56  15.19  15.88   5820300.0
2              2  1998-01-06  15.94  20.00  14.75  18.94  16182800.0
3              3  1998-01-07  18.81  19.00  17.31  17.50   9300200.0
4              4  1998-01-08  17.44  18.62  16.94  18.19   6910900.0

I want to use Volume column alone as the my observation state. This is the whole code

import random
import numpy as np
import pandas as pd
import trading_env

df = pd.read_csv('./dataset/AAPL.csv')

df.rename(columns={'Unnamed: 0':'serial_number'},inplace=True)

env = trading_env.make(env_id='training_v1', obs_data_len=50, step_len=14,
                       df=df, fee=0.1, max_position=5, deal_col_name='Close', 
                       feature_names=['Volume'])


env.reset()
env.render()

state, reward, done, info = env.step(random.randrange(3))

### randow choice action and show the transaction detail
for i in range(500):
    print(i)
    state, reward, done, info = env.step(random.randrange(3))
    print(state, reward)
    env.render()
    if done:
        break

env.transaction_details

IMPORTANT: Can you please tell me what is the action space index for buy, sell and hold. I can see action space consists of three integers but can't find where its mapped to.

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