Choosing optimal pairs from list

Viewed 34

I have a code that calculates random pairs (volatility vs expected returns; for an efficient frontier) and puts them into a list. Is there any way to narrow the list down to only "efficient pairs" (hence, the maximum return for each volatility)? So there would only be a line at the top (like in the picture)?

enter image description here

Also connecting the dots with a line would go a long way!

ff is a pandas Dataframe with daily returns (floats) Code:

    Mean = ff.mean()
    Vol = ff.cov()
    nPort = 10000
    weight = np.zeros((nPort,11))
    eR = np.zeros((nPort,11))
    eV = np.zeros((nPort,11))
    sR = np.zeros((nPort,11))
    for k in range(nPort):
        # generate random weight vector
        w = np.array(np.random.random(11))
        w = w/np.sum(w)
        weight[k,:] = w
        # expected returns
        eR[k] = np.sum(Mean * w)
        # expected Vol
        eV[k] = np.sqrt(np.dot(w.T,np.dot(Vol,w)))
        #sharpe
        sR[k] = eR[k]/eV[k]
    plt.figure(figsize=(12,5))
    plt.scatter(eV,eR, c=sR)
    plt.colorbar(label='sR')

    plt.show()
0 Answers
Related