MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / __init__

Method __init__

tf2.0/rl_trader.py:133–163  ·  view source on GitHub ↗
(self, data, initial_investment=20000)

Source from the content-addressed store, hash-verified

131 - 2 = buy
132 """
133 def __init__(self, data, initial_investment=20000):
134 # data
135 self.stock_price_history = data
136 self.n_step, self.n_stock = self.stock_price_history.shape
137
138 # instance attributes
139 self.initial_investment = initial_investment
140 self.cur_step = None
141 self.stock_owned = None
142 self.stock_price = None
143 self.cash_in_hand = None
144
145 self.action_space = np.arange(3**self.n_stock)
146
147 # action permutations
148 # returns a nested list with elements like:
149 # [0,0,0]
150 # [0,0,1]
151 # [0,0,2]
152 # [0,1,0]
153 # [0,1,1]
154 # etc.
155 # 0 = sell
156 # 1 = hold
157 # 2 = buy
158 self.action_list = list(map(list, itertools.product([0, 1, 2], repeat=self.n_stock)))
159
160 # calculate size of state
161 self.state_dim = self.n_stock * 2 + 1
162
163 self.reset()
164
165
166 def reset(self):

Callers

nothing calls this directly

Calls 1

resetMethod · 0.95

Tested by

no test coverage detected