models = [ RidgeCV(alphas=[0.2, 0.3, 0.6], cv=6, fit_intercept=True) for i in range(30) ] for i in range(30): models[i].fit(get_ith_col_x(x, i), get_ith_col_y(y, i)) # model = Lstm(time_steps=p, input_size=30, output_size=30) # model.load_data(x, y, units=50, epochs=20, batch_size=50) market.buy(P.items()) trades = [] y_preds = [] cash_y = [] cash_x = [] for prices in market.iterate(tick_names=False): y_pred = [ m.predict(get_ith_col_x(np.array(prices).reshape((-1, p, 30)), i)) for i, m in enumerate(models) ] y_pred = np.array(y_pred).flatten() y_preds.append(y_pred) returns = np.divide( np.subtract(np.array(y_pred), np.array(prices[-1])), np.array(prices[-1])) returns = returns.flatten() max_return = max(returns) max_index = list(returns).index(max_return) cash = market.liquidate_stocks(market.ticks) cash_y.append(cash) # print(f'cash: {cash}, sec: {market.get_tick_from_index(max_index)}')