Skip to content

Commit 45fa313

Browse files
author
Jesse Osiecki
authored
Update Efficient Frontier with Sharpe Ratio.py
Map Symbol+Weight portfolio keys to the correct array of stock weights. `selected` does not have the same order as that used in the pandas dataframe https://medium.com/@troy.engelhardt/hey-just-letting-you-know-that-your-final-data-frame-labelled-df-is-in-fact-mislabelled-6861298efcda#--responses
1 parent ef83f39 commit 45fa313

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Tutorials/Efficient Frontier with Sharpe Ratio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
'Sharpe Ratio': sharpe_ratio}
5656

5757
# extend original dictionary to accomodate each ticker and weight in the portfolio
58-
for counter,symbol in enumerate(selected):
58+
for counter,symbol in enumerate(cov_annual.columns):
5959
portfolio[symbol+' Weight'] = [Weight[counter] for Weight in stock_weights]
6060

6161
# make a nice dataframe of the extended dictionary
@@ -74,4 +74,4 @@
7474
plt.xlabel('Volatility (Std. Deviation)')
7575
plt.ylabel('Expected Returns')
7676
plt.title('Efficient Frontier')
77-
plt.show()
77+
plt.show()

0 commit comments

Comments
 (0)