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

Method __init__

tf2.0/keras_trader.py:140–170  ·  view source on GitHub ↗
(self, data, initial_investment=20000)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

resetMethod · 0.95

Tested by

no test coverage detected