class_docstr: A stock trading environment for OpenAI gym
class_docstr_tok: ["A","stock","trading","environment","for","OpenAI","gym"]
code: 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
                      ),
                      [],
                  )
              )  # append initial stocks_share to initial state, instead of all zero
          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
                      ),
                      [],
                  )
              )
      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
                      ),
                      [],
                  )
              )
          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
                      ),
                      [],
                  )
              )
      return state
  
imports: from __future__ import annotations
  from typing import List
  import gymnasium
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pandas
  from gymnasium import spaces
  from gymnasium.utils import seeding
  from stable_baselines3.common.vec_env import DummyVecEnv
label_desc: Use image node_id 8 for calling the StockTradingEnv obj's underlying member method code with example usage: obj._initiate_state() and returns: state