stock_name, model_name = sys.argv[1], sys.argv[2] model = load_model("models/" + model_name) state_size = model.layers[0].input.shape.as_list()[1] broker = Broker(state_size, True, model_name) data = getStockDataVector(stock_name) data_size = len(data) - 1 batch_size = 100 gain = 0 broker.trades_list = [] reward = 0 state = getState(data, 0, state_size + 1) for t in range(data_size): action = broker.act(state) if action == 1 and broker.portfolio >= data[t]: # buy broker.trades_list.append(data[t]) broker.portfolio = broker.portfolio - data[t] print("Bought: " + formatPrice(data[t]) + "| Portfolio Value: " + formatPrice(broker.portfolio)) reward = 0 elif action == 2 and len(broker.trades_list) > 0: # sell buying_price = broker.trades_list.pop(0) gain += data[t] - buying_price if (gain > 0): reward = 1 else: