WebCab Portfolio Demo
v4.2
(J2SE Edition)

webcab.lib.finance.portfolio
Class TwoAssetPortfolio

java.lang.Object
  |
  +--webcab.lib.finance.portfolio.TwoAssetPortfolio
All Implemented Interfaces:
Serializable

public class TwoAssetPortfolio
extends Object
implements Serializable

Here we present a number of methods which enables the evaluation of risk/return characteristics of portfolios which consist of two assets. In this special case the optimal portfolio can be constructed without the overhead of computationally intensive optimization techniques.

In fact, in the case of portfolios with only two assets evaluation of the portfolio risk, expected return and optimal weights are all closed formulae. The usefulness of these closed formulae is that the effect of a single purchase (or sale) has to a portfolios risk/reward profile can be studied by viewing the portfolio (or portfolio minus a holding) itself as a single asset. This portfolio which is viewed as a single asset could however have been constructed by use of the Markowitz (see Markowitz class) or CAPM (see CapitalMarket class) Theories.

See Also:
Serialized Form

Constructor Summary
TwoAssetPortfolio()
          Creates a new instance.
 
Method Summary
 double correlationCoef(double covariance, double standardDeviation1, double standardDeviation2)
          Returns the correlation coefficient between two assets.
 double covariance(double[] historicalReturns1, double[] historicalReturns2)
          This method returns the covariance between the returns of the two assets.
 double covariance(double[] probability, double[] rateOfReturn1, double[] rateOfReturn2)
          Evaluates the covariance between the returns of two assets given the probability return distribution of each asset.
 double portfolio2Return(double alpha, double expectedReturn1, double expectedReturn2)
          The expected return for a portfolio with two assets
 double portfolio2Risk(double alpha, double standardDeviation1, double standardDeviation2, double covariance)
          The risk (or standard deviation) for a portfolio with two assets.
 double portfolio2Variance(double alpha, double standardDeviation1, double standardDeviation2, double correlation)
          The variance for a portfolio with two assets.
 double standardDeviation(double[] historicalReturns)
          Evaluates the standard deviation of an asset from its historical returns.
 double standardDeviation(double[] probability, double[] rateOfReturn)
          Evaluates the standard deviation of an asset given its probability distribution of its returns.
 double weight2MinimizeRisk(double standardDeviation1, double standardDeviation2, double covariance)
          Evaluates the weight of the first asset within a two asset portfolio which achieves the optimal diversification (i.e. minimizes the risk) of the portfolio.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TwoAssetPortfolio

public TwoAssetPortfolio()
Creates a new instance.

Method Detail

correlationCoef

public double correlationCoef(double covariance,
                              double standardDeviation1,
                              double standardDeviation2)
                       throws TwoAssetPortfolioDemoException
Returns the correlation coefficient between two assets.

Parameters:
covariance - the covariance between the two assets of the portfolio
standardDeviation1 - standard deviation of the first asset
standardDeviation2 - standard deviation of the second asset
TwoAssetPortfolioDemoException

covariance

public double covariance(double[] probability,
                         double[] rateOfReturn1,
                         double[] rateOfReturn2)
                  throws TwoAssetPortfolioDemoException
Evaluates the covariance between the returns of two assets given the probability return distribution of each asset.

Parameters:
probability - probability[s] is an array of the probability of the state s occurring
rateOfReturn1 - rateOfReturn1[s] is the return (increase in market value) for the first asset in the state s
rateOfReturn2 - rateOfReturn2[s] is the return (increase in market value) for the second asset in the state s
TwoAssetPortfolioDemoException

covariance

public double covariance(double[] historicalReturns1,
                         double[] historicalReturns2)
                  throws TwoAssetPortfolioDemoException
This method returns the covariance between the returns of the two assets. The historical returns for each asset on the `same' historical time periods must be known.

Parameters:
historicalReturns1 - historicalReturns1[t] is the return (increase in market value) of the first asset in the tth period
historicalReturns2 - historicalReturns2[t] is the return (increase in market value) of the second asset in the tth period
TwoAssetPortfolioDemoException

standardDeviation

public double standardDeviation(double[] probability,
                                double[] rateOfReturn)
                         throws TwoAssetPortfolioDemoException
Evaluates the standard deviation of an asset given its probability distribution of its returns.

Parameters:
probability - probability[s] is an array of the probability of the state s occurring
rateOfReturn - rateOfReturn[s] is the return (increase in market value) for the first asset in the state s.
TwoAssetPortfolioDemoException

standardDeviation

public double standardDeviation(double[] historicalReturns)
                         throws TwoAssetPortfolioDemoException
Evaluates the standard deviation of an asset from its historical returns.

Parameters:
historicalReturns - historicalReturns1[t] is the return (increase in market value) of the first asset in the tth period
TwoAssetPortfolioDemoException

portfolio2Variance

public double portfolio2Variance(double alpha,
                                 double standardDeviation1,
                                 double standardDeviation2,
                                 double correlation)
                          throws TwoAssetPortfolioDemoException
The variance for a portfolio with two assets.

Parameters:
alpha - the weight of the first asset. Note, that the weight of an asset lies in the interval [0,1], and the sum of the assets (in this case the two assets) is 1; hence the weight of the second asset is `1-alpha'
standardDeviation1 - the standard deviation of returns for the first asset expressed in decimal format (i.e. 1 percent = 0.01)
standardDeviation2 - the standard deviation of returns for the second asset expressed in decimal format (i.e. 1 percent = 0.01)
correlation - the correlation coefficient between the assets
TwoAssetPortfolioDemoException

portfolio2Risk

public double portfolio2Risk(double alpha,
                             double standardDeviation1,
                             double standardDeviation2,
                             double covariance)
                      throws TwoAssetPortfolioDemoException
The risk (or standard deviation) for a portfolio with two assets.

Parameters:
alpha - the weight for the first asset
standardDeviation1 - the standard deviation of returns for the first asset
standardDeviation2 - the standard deviation of returns for the second asset
covariance - the covariance of returns for the two assets
TwoAssetPortfolioDemoException

portfolio2Return

public double portfolio2Return(double alpha,
                               double expectedReturn1,
                               double expectedReturn2)
                        throws TwoAssetPortfolioDemoException
The expected return for a portfolio with two assets

Parameters:
alpha - the weight for the first asset. Note that, the weights of both assets are positive and sum to one, hence the weight of the second asset is `1-alpha'
expectedReturn1 - the expected return for the first asset
expectedReturn2 - the expected return for the second asset
TwoAssetPortfolioDemoException

weight2MinimizeRisk

public double weight2MinimizeRisk(double standardDeviation1,
                                  double standardDeviation2,
                                  double covariance)
                           throws TwoAssetPortfolioDemoException
Evaluates the weight of the first asset within a two asset portfolio which achieves the optimal diversification (i.e. minimizes the risk) of the portfolio.

Remarks of Effects of Diversification

The ability to gain from the effects of diversification will depend on the covariance between the two assets. In particular, the higher the absolute value of the covariance the greater the influence in proportion of the weight of the asset. If the covariance between the two assets is zero, then there will not be any diversification effects. Moreover, the larger the absolute size of the covariance the greater the effects diversification will be.

Parameters:
standardDeviation1 - the standard deviation of the returns of the first asset
standardDeviation2 - the standard deviation of the return of the second asset
covariance - the covariance between the two assets within the portfolio
TwoAssetPortfolioDemoException

WebCab Portfolio Demo
v4.2
(J2SE Edition)