(self, max_weight=1.)
return w.value
Compute minimum variance portfolio.
Compute minimum variance portfolio.
Compute minimum variance portfolio .
def minvar(self, max_weight=1.):
        """Compute minimum variance portfolio."""
        w = cp.Variable(self.n_assets)
        risk = cp.quad_form(w, self.covmat)
        prob = cp.Problem(cp.Minimize(risk),
                          [cp.sum(w) == 1,
                           w <= max_weight,
                           w >= 0])

        prob.solve()

        return w.value
def minvar ( self , max_weight = 1. ) : w = cp . Variable ( self . n_assets ) risk = cp . quad_form ( w , self . covmat ) prob = cp . Problem ( cp . Minimize ( risk ) , [ cp . sum ( w ) == 1 , w <= max_weight , w >= 0 ] ) prob . solve ( ) return w . value