FinRL icon indicating copy to clipboard operation
FinRL copied to clipboard

Issue with the StockTradingEnv for 1m ticker data

Open lokeshsoni opened this issue 1 year ago • 1 comments

I've been trying to train a model with 1m of tick data for the DOW_30 Index. Everything works perfectly fine for daily data, but when I do the same steps for 1m, I get errors. I've resolved the errors in the feature engineering by making modifications locally, as it looks like there was no support for 1m data.

raw data - https://www.dropbox.com/s/sdhzjl7jv5oaada/raw_dow30_2022-09-11_2022-09-18_1m.csv?dl=0 feature engineered data (without turbulence index) - https://www.dropbox.com/s/ohtdcsh01e88j3y/fe_dow30_2022-09-11_2022-09-18_1m.csv?dl=0

from finrl.config import INDICATORS
from finrl.meta.env_stock_trading.env_stocktrading import StockTradingEnv

stock_dimension = len(train.tic.unique())
state_space = 1 + 2*stock_dimension + len(INDICATORS)*stock_dimension
buy_cost_list = sell_cost_list = [0.001] * stock_dimension
num_stock_shares = [0] * stock_dimension

env_kwargs = {
    "hmax": 100,
    "initial_amount": 1000000,
    "num_stock_shares": num_stock_shares,
    "buy_cost_pct": buy_cost_list,
    "sell_cost_pct": sell_cost_list,
    "state_space": state_space,
    "stock_dim": stock_dimension,
    "tech_indicator_list": INDICATORS,
    "action_space": stock_dimension,
    "reward_scaling": 1e-4
}

e_train_gym = StockTradingEnv(df = train, **env_kwargs)

Error - AttributeError: 'numpy.float64' object has no attribute 'values'

On digging deeper, it looks like the error is coming while initializing the state in the StockTradingEnv class under _initiate_state function. It looks like it's expecting an array self.data.close.values.tolist() but as per the initial declaration self.data = self.df.loc[self.day, :], a scalar value is coming.

Please let me know if I'm doing anything wrong. Also, help me with any existing implementation on 1m data.

Thank you Lokesh Soni

lokeshsoni avatar Sep 25 '22 16:09 lokeshsoni

Hey Lokesh, did you solve it yourself? The code is still the same.

sebnapi avatar Aug 31 '23 14:08 sebnapi