Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while rendering environment? #8

Open
fightthepower opened this issue May 12, 2019 · 1 comment
Open

Error while rendering environment? #8

fightthepower opened this issue May 12, 2019 · 1 comment

Comments

@fightthepower
Copy link

fightthepower commented May 12, 2019

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.

@omar94khan
Copy link

0 is for hold.
1 is for long / buy.
2 is for short / sell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants