Toy Portfolio HackerRank代写

4. Toy Portfolio
You are given a Pandas DataFrame with daily returns of 3 stocks and S&P 500 index.
1) For each of the 3 stocks calculate historical market beta (regressed without intercept) as of (and
including) Dec 31, 2015 (stock return time series can start at different times; there could be gaps in data
on holidays), use SPX returns as a proxy for the market return. For each coefficient calculate appropriate
E-statistic to test the hypothesis that B = 0
2) Given a ticker of one of the stocks, compute the holding vector h E Ri
for the unique stock portfolio
that is both dollar and beta neutral and has unit exposure to the specified stock as of Dec 31, 2015. (Do
not include SPX into this portfolio). Place these holdings into “portfolio” column of the results DataFrame
3) Compute daily PL for each position in the above portfolio over the period January 1st, 2016 to
December 31 st, 2016. Assume that each day the portfolio is rebalanced to the initial holdings (no
compounding, profits/losses are taken out of the portfolio at the end of each day)
4) For each position, compute its Maximum PL DrawDown. Where drawdown is defined as the
difference between current cumulative PL and the highest cumulative PL to date (thus by definition,
drawdown is less than or equal to

1) For each of the 3 stocks calculate historical market beta (regressed without intercept) as of (and
including) Dec 31, 2015 (stock return time series can start at different times; there could be gaps in data
on holidays), use SPX returns as a proxy for the market return. For each coefficient calculate appropriate
I statistic to test the hypothesis that B
0
2) Given a ticker of one of the stocks, compute the holding vector h E R
for the unique stock portfolio
that is both dollar and beta neutral and has unit exposure to the specified stock as of Dec 31, 2015. (Do
not include SPX into this portfolio). Place these holdings into “portfolio” column of the results DataFrame.
3) Compute daily PL for each position in the above portfolio over the period January 1st, 2016 to
December 31 st, 2016. Assume that each day the portfolio is rebalanced to the initial holdings (no
compounding, profits/losses are taken out of the portfolio at the end of each day)
4) For each position, compute its Maximum PL DrawDown. Where drawdown is defined as the
difference between current cumulative PL and the highest cumulative PL to date (thus by definition,
drawdown is less than or equal to zero). Maximum drawdown is the drawdown largest in magnitude, i.e.
MDD, = mink<–DDt
The final result should be returned in the following Pandas DataFrame:

Note that the order of tickers in the resulting DataFrame index should be the same as the order of
tickers in the input DataFrame columns (not including SPX). Also, each test case can have data for a
different set of tickers.
Make sure that the results dataframe has the following column types: