Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 2

Onecanthenworkwithmaybe orevenonly principalcomponent forboththegermandaxindexandallstocksthatmakeuptheindex toderiveprincipalcomponents machinelearninglibrary importnumpyasnp importpandasaspd importpandas fromsklearn stocksthefollowinglistobjectcontainsthe symbolsforthestockscontainedinthegerman daxindex symbols toretrievestockdatawithpandas time data forsyminsymbols data cputimes

���������plt.grid(True)
���������plt.axhline(0,�color=‘k’,�ls=‘—’,�lw=2.0)���������plt.axvline(0,�color=‘k’,�ls=‘—’,�lw=2.0)���������plt.xlabel(‘expected�volatility’)
���������plt.ylabel(‘expected�return’)
���������plt.colorbar(label=‘Sharpe�ratio’)

Out[76]:�array([�0.684,��0.059,��0.257,�-0.���,��0.���])

Principal�Component�Analysis

The�example�of�this�section�illustrates�the�use�of�PCA�in�such�a�context.�We�retrieve�data for�both�the�German�DAX�index�and�all�stocks�that�make�up�the�index.�We�then�use�PCA to�derive�principal�components,�which�we�use�to�construct�what�we�call�a�pca_index.

First,�some�imports.�In�particular,�we�use�the�KernelPCA�function�of�the�scikit-learn machine�learning�library�(cf.�the�):

We�work�only�with�the�closing�values�of�each�data�set�that�we�retrieve�(for�details�on�how to�retrieve�stock�data�with�pandas,�see�Chapter�6):

In�[3]:�%%time
��������data�=�pd.DataFrame()
��������for�sym�in�symbols:
������������data[sym]�=�web.DataReader(sym,�data_source=‘yahoo’)[‘Close’]��������data�=�data.dropna()

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELI21E13F2
img
Uploaded by :
ZRWAWY8V
Page 1 Preview
onecanthenworkwithmaybe orevenonly principalcompon
Sell Your Old Documents & Earn Wallet Balance