Issue
I have a problem with python, can u help me to solve it?
all libraries are loaded.
problem in this line: ---> 14 expV[k] = np.sqrt(np.dot(w.T,np.dot(Sigma,w)))
noOfPortfolios = 100
weight = np.zeros((noOfPortfolios,4))
expectedReturn = np.zeros(noOfPortfolios)
expV = np.zeros(noOfPortfolios)
sharpR = np.zeros(noOfPortfolios)
meanLogRet = logReturns.mean()
Sigma = logReturns.cov
for k in range(noOfPortfolios):
w = np.array(np.random.random(4))
w = w / np.sum(w)
weight[k,:] = w
expectedReturn[k]= np.sum(meanLogRet * w)
expV[k] = np.sqrt(np.dot(w.T,np.dot(Sigma,w)))
sharpR[k] = expectedReturn[k]/expV[k]
Solution
Change
Sigma = logReturns.cov
to
Sigma = logReturns.cov()
Answered By – Warren Weckesser
This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0