Home > Sample essays > Optimize Risky Portfolio Weights Using MATLAB: Analyzing Financial Markets w/ Modern Portfolio Theory

Essay: Optimize Risky Portfolio Weights Using MATLAB: Analyzing Financial Markets w/ Modern Portfolio Theory

Essay details and download:

  • Subject area(s): Sample essays
  • Reading time: 8 minutes
  • Price: Free download
  • Published: 1 April 2019*
  • Last Modified: 23 July 2024
  • File format: Text
  • Words: 313 (approx)
  • Number of pages: 2 (approx)

Text preview of this essay:

This page of the essay has 313 words.



Matlab (maxtrix laboratory) over the year have become increasingly important for analysing the financial market. It is a high performance programming language used in carrying out technical and mathematical calculations. Matlab is becoming popular because it integrates, does visualization, computation and programming in an easy to use environment (Anon, 2016)

In this project, I will be using Matlab programmes in solving problems relating to testing the natural logarithm of price series if it follows a random walk, computing the optimal risky portfolio weights and the optimal final portfolio weights, also the forward rate unbiasedness (FRU) and VaR will also be tested. Data used are downloaded from the internet, Yahoo finance and the Bank of England website.

Question 1

The question is about testing whether the natural logarithm of the price series (daily) follows a random walk? The five stocks are Pfizer, coke, General electric, Microsoft and Apple. The tests I will be using are the ADF (augmented dickey fuller) and VR test (variance ratio). If the movement of stocks price cannot be predicted because they change without limit in the long run, then it describes random walk (Tiwari and Kyophilavong, 2014). In a weak form efficient market if the price changes based on realised new information, then the price follows a random walk (Anon, 2016)

The unit root test is used to test for random walk. This is to find if the stock prices are stationary. If the random walk hypothesis is supported it is non-stationary, but if the price are stationary, then we reject the random walk hypothesis (Tiwari and Kyophilavong, 2014). The Dickey-Fuller (ADF test 1979) is a known method used for testing. The Dickey Fuller testis to find out if a unit root is present in the AR model. A simple method is;

 y_(t=Øy_(t-1+ɛ_t ) ) (1)

If Ø=1, the model will be non-stationary meaning there is unit root in the model.

However if the equation 1<1, then it is stationary.

A modified version for testing for the unit root is;

∆y_(t=∅_1^* ) y_(t-1)+ε_t  (2)

Where ∅_1^*= (∅_1-1)

The null hypothesis of the DF test is H_0: Ø=0; so if Ø=1 on the AR model, then  H_0: Ø=0 is the same as H_(0:) Ø=1

The test statistic to be used is;

t_μ=(∅ ̂_1^*)/(〖se(∅〗_(1))^* ) ̂ (3)

I will test the result using the Matlab Programme and compare it with the critical level of 5% (test statistic). The critical value is -2.86 (constant and no trend).

MSFT GE PFIZER APPLE COKE

ADF TEST -3.660 -2.1474 -2.5890 -1.4694 -3.1138

Reject or accept reject accept accept accept reject

Table 1

According to the null hypothesis, if it is accepted it means there is the presence of unit root and it is non-stationary, concluding it follow a random walk. The Table 2 below shows this;

MSFT GE PFIZER APPLE COKE

Follows random walk NO YES YES YES NO

Table 2

One of the limitations of the DF is that against slow mean reversion alternative in small samples, they have a very low power (Chaudhuri and Wu, 2003)

A stock price is permanent and the tendency of the price level returning to a trend path is little (chaudhari and wu, 2003). We can also use VR developed by Lo and Mackinlay for test for random walk. When testing alternatives to the random walk model, VR statistic is off advantage noticeable the hypothesis of mean reversion (Charles and Darné, 2009).

The VR model is

VR (k) =σ ̂^(2 (k))/σ ̂^(2(1)) (4)

Where σ ̂^(2 (k))  is the unbiased estimator of the k-period return variance and σ ̂^(2(1)) is the unbiased estimator of a one period return variance.

 Under the assumption of Homoscedasticity, the test statistic used to test the null hypothesis of the random walk is;

z(q)=((nq)^(1/2   ) VR(q))/(((2(2q-1)(q-1))/3q) 〖1/〗^2 ) (5)

MSFT GE PFIZER APPLE COKE

Z(q)/vhat -1.9542 -2.5422 0.5543 -3.1533 -4.4104

Vr(q) 0.9628 0.9517 1.10105 0.9401 0.9162

Reject or accept accept accept reject accept accept

Table 3

To decide whether to accept or reject the hypothesis (if it follows a random walk), we compare the test statistic with the standard normal distribution

MSFT GE PFIZER APPLE COKE

Follows random walk YES YES NO YES YES

Table 4

We can see that by comparing the two result of the dickey fuller and variance ration test, there some discrepancies, the variance ratio test overcomes the weaknesses of non-stationarity and autocorrelation

Question2

This question is about asset allocation, it is to complete the optimal risky portfolio weights and the optimal final weights. Markowitz says there are two stages in the process of portfolio selection, with the first stage dealing with experience and observation, while the second stage ends with beliefs about the performance of future available resources (portfolio selection, Markowitz, harry 1952).

When investing, there is always a possibility of risk and returns. Markowitz model says for any amount of risk, it teaches on how to select a portfolio with high returns and also how to select a portfolio with the lowest risk (Vaclarik and Jablonsky, 2011- revision of modern portfolio theory optimization model).

Some of the following assumptions of Modern portfolio theory are;

Transaction cost or tax don’t exist

Analysis is on a single period model of investment

The risk-return relationship are viewed over the same time horizon

The risk of the portfolio depends directly on the instability of returns from the given portfolio.

Investors are risk-adverse and they maximize utility which is positive function of expected return

Investors can invest and borrow at a risk-free of interest

Investors will avoid risk when possible and are rational.

One of the limitations is that access to the same information is available to all investors. Also in real life, the assumption that asset returns are normally distributed doesn’t often hold.

 For investors, the preferred combination of risk assets are to maximize expected return E_((rp))with different portfolio variance σ^2p which is minimize portfolio variance (Sollis, 2012)

In choosing between single risk-free assets and risky asset, MPT suggest that optional asset allocation can take two steps;

After the estimation of the expected returns, covariance and variance of returns of risky assets, we use the result to compute different preferred risky portfolio (sollis, 2012). We then maximize the ‘CAL’ slope using the risk-free information that changes the optimal risky portfolio weights (ORP).

CAL slope=E(rp)-rf

  σp (6)

The total portfolio of the risky portfolio and the risk-free asset is complicated using information on the investors’ degree of risk aversion.

The formula for the portfolio mean and variance

E((r_(p)) ) ̅=w.E((r) ̅_A)+(1-w).E(r ̅_B) (7)

Where w= w_A^p is the fraction that is invested in asset A

The variance of the portfolio is

σ^2 p=E[(r_(p-) r_p)]

=w^2 σ_A^2+〖(1-w)〗^(2 ) σ_B^2+2w(1-w)cov((r^A  ) ̅,(r^B  ) ̅) (8)

Sinceρ_(AB=cov() ¯(r^A ),¯(r^(B ) ))/(σ_(A .) σ_B)

   σ_(P )^2=w^2 σ_A^2+〖(1-w)〗^2 σ_B^2+2w (1-w)ρ_AB σ_A σ_B

We can choose the OCP (Optimal complete portfolio) by using the investors risk aversion to choose the OPF to split between the ORP and the risk-free asset (Sollis, 2012).

To derive the fund allocated to ORP, we can get p assuming the Quadratic utility function

U=E_((rp) )-0.005ασ_p^2 (9)

Using the matlab programme, we chose the risk-free rate 0.03% and the risk aversion rate at 4%. The returns for the 5 monthly stocks are shown in the table

MSFT GE PFIZER APPLE COKE

E_((ri)) 0.1760 0.0954 0.0446 0.7456 0.0252

Table 5

The stock with the highest mean return will be more profitable. From the table we can see that stock apple is higher, therefore it is more profitable or will yield more profit.

The covariance matrix can be shown in the table 6 below;

MSFT GE PFIZER APPLE COKE

MSFE 0.2146 0.0058 0.0221 0.1821 -0.0095

GE 0.0528 0.0615 0.0131 0.0466 -0.0054

PFIZER 0.0221 0.0131 0.0625 0.0083 0.0034

APPLE 0.1821 0.0466 0.0083 1.0826 0.0035

COKE -0.0095 -0.0054 0.0034 0.0035 0.0529

Table 6

The optimal risky portfolio weights are shown in table 7

MSFT GE PFIZER APPLE COKE

weights 0 0.4637 0.0232 0.5131 0

Table 7

The estimated return and standard deviation of the OFP are E(rofp)= 0.1533, σofp=0.1756

The estimated return and standard deviation of the ORP are E(rorp)= 0.4278, σorp= 0.5655

It can be seen from the asset weight that Apple has the highest weight and Msft and coke have zero weights. The OFP involves investing 30.9% of funds in the ORP and the remainder in the risk-free asset. The slope of the CAL is maximised when different preferred risk portfolio from the ORP are on the efficient frontier (Sollis, 2012). The expected return and asset weight of apple is the highest. The line draws closer to the y axis which makes it more efficient.

Diversification is created by investors to reduce the risk of their portfolio. It is important for investors not to hold asset that are perfectly correlated. Exposure to asset risk can be minimised by diversification.

Diversification is very important when it comes to investing. An investor should diversify his portfolio so as to reduce the risk associated with investing. There are diversifiable risk and non-diversifiable risk.

Question 3

This question is using the exchange rate data and appropriate regression-based test to test for the forward rate unbiasedness (FRU) hypothesis. The forward rate unbiasedness hypothesis on the part of market agents is an unbiased predictor of the corresponding future spot rate under the condition of risk neutrality and rational expectation. (The forward rate unbiasedness hypothesis re-examined: evidence from a new test). The data used is from 31/01/2001-31/12/2102

The CIP and UIP are to test the efficient market hypothesis for the foreign market.

E (S_(t+1)/δ_t)-S_t=i_t-i_t^* (10)

Where E (S_(t+1)/δ_t) denoted market’s expected value S_(t+1)

The expected exchange rate return must be equal to the difference between the nominal interest rate under the UIP (Sollis, 2012). CIP “is a no-arbitrage condition in foreign exchange markets which depends on the availability of the forward market” (Wikipedia)

f_t^k= natural logarithm of the k period forward rate

f_t^k-s_t=i_t-i_t^* (11)

Under both CIP and UIP, the FRU hypothesis should hold

f_t^k=E(S_(t+k)/δ_t) (12)

Testing whether the FRU hold, the model below is used

∆S_(t+k)=α+β(f_t^k-S_t) +ε_(t+k)  (13)

Where ε_(t+k)~IID (0,σ_ε^2)

Using the OLS, the estimated α and β parameter will be gotten H_0 : α=0, H_0:β=1, using T-test or H_0:α=0, β=1 (joint hypothesis)can be tested using F-TEST (Sollis, 2012). The result is shown in table 8

α -0.000267421134987932

β -1.11377575209063

H_(O:) α=0 t= -0.0654651418437082

H_0: β=0 t= -0.447539517206982

H_0: β=1 F=0.750660606864928

   tbeta= -0.849361442641182

We reject the null hypothesis if the t- statistic is greater than the critical value, otherwise it is accepted when is α=0, β=1. Comparing the t-statistic from the table to the student t-distribution at 5% and 10% level. The critical values are 1.645 and 2.326.

Form the table we see that the t-statistic is not greater than the critical value; therefore we cannot reject the null hypothesis that FRU is an unbiased predictor of future spot exchange rate. The slope parameter is negative.

Question 4

This is about computing the one –day ahead return VaR for equally weighted portfolio of any four stocks on every trading day over 2008. The Daily stock used was Microsoft, General Electric, Pfizer and Apple.

The different ways of computing the one-day return vaR of weighted portfolio, there is the Delta-Norm; approach says that the returns for financial assets are conditionally normally distributed when computing vaR (sillis, 2012).

r_(t+1)=μ_(t+1)+δ_(t+1) σ_(t+1) (14)

Where μ_(t+1) denoted conditional mean return, σ_(t+1) is conditional variance and δ_(t+1) is standard nominal random variable.

There is also the monte-carlo simulation approach which assumes the conditional probability distribution for returns similar to the DN approach (sollis, 2012)

r_(t+1)=σ_(t+1) θ_(t+1) (15)

Where θ_(t+1) is a student random

However, we will use Historical Simulation (HS) approach to compute the one-day return vaR of the weighted portfolio of four stocks on every trading day over 2008. The historical simulation method states that to predict what happens in the future, we use past data to guide us (kondapanemi, 2005)

Value at risk has been popular with banks in managing the degree of market risk. (Sollis 2012). Even though vaR is normally a negative number, it is normally given has a positive amount.  Changes in interest rate, exchange rate or commodity prices may affect the asset portfolio to decline, the risk associated with this can be measured by the value-at-risk models (evaluation if value at risk models using historical data, Hendricks). VaR is also the measuring of the potential loss on a portfolio over a defined time horizon for a given confidence interval. For example, “the one-week vaR for a portfolio is £100 million with a 95% confidence level” should be interpreted as “there is only a 5% chance the portfolio value will decline more than £100 million over the coming week”.

The delta normal approach was introduced by jp morgan. Riskmetrics has its origin from delta normal. This approach is straight forward for large portfolios the computational cost is quite low (Sollis,2012). The Var using this method is computed with the equation below;

〖vaR〗_(t+1)^P=-F^(-1)(p)σ ̂_(p,〖t+1〗^Vt ) (16)

From the graph above, at the start of the year the VaR is 3%, but towards the end of the year, it rose to approximately 11.5% before falling at the end of the year and into the following year. The volatility for the last 3 months of 2008 is widely due to the financial crisis which was at its peak.The vaR (rq) is -0.0760

About this essay:

If you use part of this page in your own work, you need to provide a citation, as follows:

Essay Sauce, Optimize Risky Portfolio Weights Using MATLAB: Analyzing Financial Markets w/ Modern Portfolio Theory. Available from:<https://www.essaysauce.com/sample-essays/2016-5-9-1462807876/> [Accessed 09-04-26].

These Sample essays have been submitted to us by students in order to help you with your studies.

* This essay may have been previously published on EssaySauce.com and/or Essay.uk.com at an earlier date than indicated.