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

Method __init__

tf2.0/mlp_trader.py:121–151  ·  view source on GitHub ↗
(self, data, initial_investment=20000)

Source from the content-addressed store, hash-verified

119 - 2 = buy
120 """
121 def __init__(self, data, initial_investment=20000):
122 # data
123 self.stock_price_history = data
124 self.n_step, self.n_stock = self.stock_price_history.shape
125
126 # instance attributes
127 self.initial_investment = initial_investment
128 self.cur_step = None
129 self.stock_owned = None
130 self.stock_price = None
131 self.cash_in_hand = None
132
133 self.action_space = np.arange(3**self.n_stock)
134
135 # action permutations
136 # returns a nested list with elements like:
137 # [0,0,0]
138 # [0,0,1]
139 # [0,0,2]
140 # [0,1,0]
141 # [0,1,1]
142 # etc.
143 # 0 = sell
144 # 1 = hold
145 # 2 = buy
146 self.action_list = list(map(list, itertools.product([0, 1, 2], repeat=self.n_stock)))
147
148 # calculate size of state
149 self.state_dim = self.n_stock * 2 + 1
150
151 self.reset()
152
153
154 def reset(self):

Callers

nothing calls this directly

Calls 1

resetMethod · 0.95

Tested by

no test coverage detected