problem on state representaion Finrl StockTradingEnv

i’m trying to adjust and apply my own trading strategies on Finrl meta environment and ensmeble agent method. in this process i decide to add some new features which are produced by a neuran network to capture unseen temporal dynamics in the dataset. after applying default feature engineering suggested by finrl itself and my new features my dataset have these columns:

INDICATORS = ['macd','rsi_30','cci_30','dx_30','wr_30','atr_30','chop_30','mfi_30','boll_ub','boll_lb','close_30_sma','close_60_sma']

MYNN = ['NN0','NN1','NN2','NN3','NN4']

df_columns = ['date','open','high','low','close','volume','tic','day','macd','rsi_30','cci_30','dx_30','wr_30','atr_30','chop_30','mfi_30','boll_ub','boll_lb','close_30_sma','close_60_sma','vix','turbulence','NN0','NN1','NN2','NN3','NN4']

stock_dimension = len(df_final.tic.unique())
state_space = 1 + 2*stock_dimension + (len(INDICATORS)+len(MYNN ))*stock_dimension
print(f"Stock Dimension: {stock_dimension}, State Space: {state_space}")
#Stock Dimension: 27, State Space: 514

so my state space is 514. but when i add my features, in the environment the _initialize_state function make states with shape of 442 instead of 514. after this i got the error that said “could not broadcast input array from shape (442,) into shape (514,)”.
here is the _initialize_state function that i adjust but i cant understand why its not working:

def _initiate_state(self):
    if self.initial:
        # For Initial State
        if len(self.df.tic.unique()) > 1:
            # for multiple stock
            state = (
                [self.initial_amount]
                + self.data.close.values.tolist()
                + self.num_stock_shares
                + sum(
                    (self.data[tech].values.tolist() for tech in self.tech_indicator_list),
                    [],
                )
                + sum((self.data[feature].values.tolist() for feature in self.new_features_list), [])
            )
        else:
            # for single stock
            state = (
                [self.initial_amount]
                + [self.data.close]
                + [0] * self.stock_dim
                + sum(([self.data[tech]] for tech in self.tech_indicator_list), [])
                + sum(([self.data[feature]] for feature in self.new_features_list), [])
            )
    else:
        # Using Previous State
        if len(self.df.tic.unique()) > 1:
            # for multiple stock
            state = (
                [self.previous_state[0]]
                + self.data.close.values.tolist()
                + self.previous_state[(self.stock_dim + 1) : (self.stock_dim * 2 + 1)]
                + sum(
                    (self.data[tech].values.tolist() for tech in self.tech_indicator_list),
                    [],
                )
                + sum((self.data[feature].values.tolist() for feature in self.new_features_list), [])
            )
        else:
            # for single stock
            state = (
                [self.previous_state[0]]
                + [self.data.close]
                + self.previous_state[(self.stock_dim + 1) : (self.stock_dim * 2 + 1)]
                + sum(([self.data[tech]] for tech in self.tech_indicator_list), [])
                + sum(([self.data[feature]] for feature in self.new_features_list), [])
            )
    print(f"Initialized state shape: {len(state)} (Expected: {self.state_space})")
    return state

i’ll be grateful if you can guide me on this problem…

in short i want my agents can see new features that i make, so these new features must be involve in state initialization step.

New contributor

alee stvr is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật