Data Used: ALARABANK BATBC BATASHOE Beximco Bxpharma DELTASPINN UCBLNormalizing by dividing prices for each stock by the first price value for that stock


Doing basic statistics with data and plotting results
****** Basic Statistical Measures ******
Given the returns above. Calculate and store the following values:
- the expected daily return per asset, store in expReturn (1x7)
- the expected daily standard deviation, store in expStd (1x7)
- the number of assets, store in variable nAssets
mean(returns) = expected daily returns
std(returns) =expected standard deviation
length(expReturn) =number of assets

Convert average daily rate of return to annual by assuming number of business days per year is 253
thus expected annual return = expected daily returns*253
Plot individual stock returns vs. risk

A
dummy portfolio -- Plot the dummy portfolio

Generating Random Portfolios: Use the PORTRAND function to generate 1000 random portfolios. Store the associated risk, return and asset weights in variables. Plot the risk vs. annual percent return for each portfolio using a star: *.

The
profit maximization can be set up as a linear programming.
We have:
Weight associated with each asset (scalar)
Expected return for each asset (scalar)
maximizing this sum is equivalent to minimizing the negative of the sum. The weights in w to calculate the return and risk associated with the current portfolio.

The
risk minimization can be set up as a quadratic programming
We have:
Weight associated with each asset (scalar)
Expected return for each asset (scalar)
Plotting results: The
efficient frontier curve must have the portfolio with minimum risk at one end and the one with maximum return at the other end and thus will be contained in a box drawn below:

Generating the efficient frontier using QUADPROG in a loop: The portfolio which minimized risk regardless of the return. Here, we intend to use QUADPROG to minimize the risk associated with a fix return; for example we can ask what is the portfolio with minimum risk for an annual return of 25%?
You can see that we can repeatedly fix a return and calculate the weights for the associated minimum risk portfolio. Create a 1x30 vector retArray of returns. Use QUADPROG in a loop to calculate the weights; For each return value stored in retArray. Within the loop, we calculate and store the risk and return for each portfolio in variables.
Generating the efficient frontier using PORTOPT:
Adding
Protfolio Constraints on how assets are allocated. The minimum and maximum allocation per asset are set bellow:
'ALARABANK' 'BATBC' 'BATASHOE' 'Beximco' 'Bxpharma' 'DELTASPINN' 'UCBL'
assetMax = [0.7 0.6 0.8 0.81 0.95 0.85 0.9];
The minimum and maximum allocation per group are set bellow:
'ALARABANK' 'BATBC' 'BATASHOE' 'Beximco' 'Bxpharma' 'DELTASPINN' 'UCBL'
groupTech = [ 0 1 0 1 0 1 0];
groupBank = [ 1 0 0 0 0 0 1];
groupOther = [ 0 0 1 0 1 0 0];
groups = [groupTech;groupBank;groupOther];
tech Bank Other
groupMax = [0.9 0.8 0.6];
groupMin = [0 0 0];
Generate the efficient frontier
Calculating the Sharpe ratio:Assuming a risk free rate of return: Rf of 4% per annum
Sharpe ratio for a portfolio is: (E(returns)-Rf)/std(returns)
Rf = 0.04;
Calculating the sharpe ratio for portfolios on the efficient frontier - try projecting the line to X-Y, X-Z, Y-Z planes. Which projection results in the efficient frontier?
Backtesting of portfolios: We would like to truncate our period of observation and see how the
calculated portfolio weights (optimized for all observations) will do. We'll generate a return series with the new return and covariance matrix, calculated from the truncated observations.
Post-optimization statistical analysis: MAX, SKEWNESS, KURTOSIS, NORMPLOT
If the acheived returns were normally distributed the optimum strategy for minimizing the risk for a given return would be to minmize. Testing for normality of portfolio with highest Sharpe Ratio. The normplot and histogram of achivedRet give us a sense for the % distribution of returns for the portfolio with highest Sharpe ratio. Are the returns for this portfolio normally distributed?
Statistics for portfolio with highest Sharpe Ratio
skewAchievedReturns = skewness(achievedRet);
kurtAchievedReturns = kurtosis(achievedRet);
mu = mean(achievedRet); Expected daily return
sigma = std(achievedRet); Expected risk

Maximum drawdown as measure of risk: Drawdown is the percentage drop in total returns from the start to the end of a period. If the total equity time series is increasing over an entire period, drawdown is 0. Otherwise, it is a negative number. Maximum drawdown is a proxy for downside risk that computes the largest drawdown over all intervals of time that can be formed within a specified interval of time. Mean-Variance Efficient Frontier vs. Max Drawdown: