The program that will optimise everything is listed below;
df_returns = df_stocks.set_index('Date').diff()
mean_stock = df_returns.mean().values
cov_stock = df_returns.cov().values
x = cp.Variable(len(mean_stock))
stock_return = mean_stock * x
stock_risk = cp.quad_form(x, cov_stock)
p = 1
objective = cp.Maximize(stock_return - p * stock_risk)
prob = cp.Problem(objective=objective)
prob.solve(), x.value
Can you spot the issue at the end of the video though?