December 2018
Beginner to intermediate
684 pages
21h 9m
English
We can calculate an efficient frontier using scipy.optimize.minimize and the historical estimates for asset returns, standard deviations, and the covariance matrix. The code can be found in the efficient_frontier subfolder of the repo for this chapter and implements the following sequence of steps:
def simulate_portfolios(mean_ret, cov, rf_rate=rf_rate, short=True): alpha = np.full(shape=n_assets, fill_value=.01) weights = dirichlet(alpha=alpha, size=NUM_PF) weights *= choice([-1, 1], size=weights.shape) returns = weights @ ...