1. Download the daily close prices of all current constituents of HSI from 1-Jan-2016 to 31-Dec-2017
into the first column being dates, the first row being tickers (50 tickers)
2. Use Pandas to read the daily prices, and use pandas to create a weekly (every Friday), and monthly
(every monthend) dataframe
3. Use Pandas to calculate the corresponding daily, weekly and monthly returns of the above 3
dataframes
4. For the weekly dataframe, calculate the covariance matrix (50 x 50). OUTPUT the file as
covHSI.csv
5. For the daily returns, use matplotlib to plot histogram for Tencent (700 HK), using bins=100.
Normalize the histogram (using norm=’True’), make the title ‘700 HK’, xticks and yticks with
size=10. Output the histogram and paste it in word, name it Graph.doc
Q6 and Q7 need to be two subplots into one plot, paste it into Graph.doc
6. Perform a “normaltest” using “stats” from “scipy” on EACH of the constituents of HSI using the
weekly returns. Do NOT use for loop. Plot the corresponding 50 P-values of the normal test. Are
the 50 constituents’ return normal? Comments below the subplot
7. Perform a autocorrelation test (“acorr_ljungbox” from “statsmodels.stats.diagnostic”) to check
the IID property on EACH of the constituents of HSI using the weekly returns. Use a max lag of 5.
Do NOT use for loop. Hint: You may use “map” function together with “lambda” function. Plot the
corresponding 50 P-values of the normal test. Are the 50 constituents’ returns exhibiting zero
serial correlation across lags? Comments below the subplot
8. For each stock, for each year and month, calculate the standard deviation of daily returns (within
that month) and put that into a dataframe. Your result will look like: The first column being 201601,
201602…, 201712, the second column will be the 1st stock with each entry being the volatility of
the daily returns of the corresponding month. Hint: You may want to create an empty dict {}, then
for each loop in year and month, create a list [] that appends the result. At the end, convert the
dict{} into dataframe
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。