def efficient_frontier(self, points):
        """Get the efficient frontier"""
        mu, sigma, weights = [], [], []
        # remove the 1, to avoid duplications
        a = np.linspace(0, 1, points / len(self.w))[:-1]
        b = list(range(len(self.w) - 1))
        for i in b:
            w0, w1 = self.w[i], self.w[i + 1]
            if i == b[-1]:
                # include the 1 in the last iteration
                a = np.linspace(0, 1, points / len(self.w))
            for j in a:
                w = w1 * j + (1 - j) * w0
                weights.append(np.copy(w))
                mu.append(np.dot(w.T, self.mean)[0, 0])
                sigma.append(np.dot(np.dot(w.T, self.cov_matrix), w)[0, 0] ** 0.5)
        return mu, sigma, weights
def efficient_frontier ( self , points ) : mu , sigma , weights = [ ] , [ ] , [ ] a = np . linspace ( 0 , 1 , points / len ( self . w ) ) [ : - 1 ] b = list ( range ( len ( self . w ) - 1 ) ) for i in b : w0 , w1 = self . w [ i ] , self . w [ i + 1 ] if i == b [ - 1 ] : a = np . linspace ( 0 , 1 , points / len ( self . w ) ) for j in a : w = w1 * j + ( 1 - j ) * w0 weights . append ( np . copy ( w ) ) mu . append ( np . dot ( w . T , self . mean ) [ 0 , 0 ] ) sigma . append ( np . dot ( np . dot ( w . T , self . cov_matrix ) , w ) [ 0 , 0 ] ** 0.5 ) return mu , sigma , weights
Get the efficient frontier