Once we have assets with predicted return trends, we can work on trying to figure out how much of each asset we should buy. A financial principle known as diversification states that buying a lot of stocks is less risky than buying just a few. For example, it is generally less likely that 100 stocks will under-perform the market then it is that just one stock will under-perform.

However, this idea still leaves the problem of how much of each stock a person should buy. The amount of each stock in a portfolio is called a weight. In order to standardize numbers, since different investors may invest different amounts of money, weights are typically measured in percentage form, with the entirety of the portfolio, or sum of the weights, being 100%. For example, for if an investor has a \$10,000 portfolio, and \$1,000 is in company X, the weight of company X in the portfolio is 10%.

In order to determine the weights for each stock we must solve a non-linear optimization problem.

##### where  such that  Decision Variable: Weights (w) to put on each asset inside the portfolio : Covariance Matrix of Asset Returns

If more than a few companies are considered, one would typically need to use a computer program to solve this optimization problem. In our project, we use MATLAB’s fmincon() function to solve optimization problems.

### Objective Function: Sharpe Ratio

The objective function, or first equation above, is defined as the Sharpe RatioQualitatively, this ratio measures how much additional return is captured from taking on additional risk. Thus our objective is to determine which set of weights will maximize the risk-return trade off as quantified by the Sharpe Ratio.

### Constraints

There are two constraints above that limit our possible solutions. The first constraint, is that the sum of all the weights is 1 or equivalently 100%. This means that the portfolio we are trying to build is going to consist entirely the considered assets; it will not include bank accounts or stocks that were not inputted into the model.

The second constraint is that the weight placed on a single asset is between 0 and 1, or equivalently 0% and 100%. A more advanced investor could remove the 0% minimum weight constraint, which would mean that short sales are allowed by the model.

### Problem Variations

Many variations of this problem may occur. For example a young and aggressive investor, may be willing to accept additional risk in order to hit a specific return target. Alternatively, an older and more risk-averse investor may be willing to accept lower returns, but will not want to exceed a risk threshold. In cases such as these, we can add in an additional equality constraint, either confining the expected risk or return value to a specified value. We can still keep the rest of the problem the same, although in actuality, when either the return or risk value is fixed, the objective function becomes even simpler since we can remove the constants.

The variation of the problem described here is used later on in our project in order to construct the efficient frontier.