def evaluate_portefolio(wei, returns_vec):
""" Given a repartition, compute expected return and risk from a portefolio
:param wei: Weights for each currency
:type wei: ndarray of float
:return: expected return and risk
:rtype: (float, float)
"""
p = np.asmatrix(np.mean(returns_vec, axis=1))
w = np.asmatrix(wei)
c = np.asmatrix(np.cov(returns_vec))
mu = w * p.T
sigma = np.sqrt(w * c * w.T)
return mu, sigma
评论列表
文章目录