Portfolio Optimization, Quantitative Finance, Python Programming, Convex Optimization, Data Science.
(num_simulation, num_funds)) W[W<0] = 0 # long only for i in range(num_simulation): w = W[i] if sum(w): # set the weight vector elementarily sum to 1 w = w * (1 / np.sum(w)) else: w = np.random.uniform(0, 1, (num_funds,)) w = w * (1 / np.sum(w)) ret.append(w @ r_annualized) std.append((w @