**Single-Period Portfolio Optimization with Mean-Variance Analysis**

#### 1. Introduction

The main feature of this project is to establish and solve a more practical portfolio optimization problem given more real-world constraints basically under the framework of Markowitz’s Modern Portfolio Theory.

**In the simple portfolio optimization problem, we only consider a simple case of Markowitz’s Modern Portfolio Theory**. W**hich requires the distribution of the return of each asset is known. **

And we obtain the covariance matrix for these assets by calculating covariance of each pair of assets. Eventually we make trade-off between maximizing expected return (*𝜇*) and minimizing variance/risk (Σ) and get optimal weights (*𝑥𝑖*) for each asset.

In this project, we apply optimization techniques to customize the investment portfolio with multiple real-world features and constraints, including linear/fixed transaction costs, and then to maximize the expected wealth at the end of current trading period under Markowitz’s Modern Portfolio Theory framework. We consider a more complicated model based on MPT but involving more constraints including variance constraints, shortfall risk constraints, short selling constraints, diversification constraints, as well as the budget constraints, etc. We modeled the transaction cost as the combination of linear transaction cost and fixed transaction cost, both are varied depending on the operation (buying or selling). When we eventually formulated our optimization model, we considered three optimization problems: expected end wealth maximization problem with linear but not fixed transaction cost, expected end wealth maximization problem with linear and fixed transaction cost, and finally a minimization problem with respect to the total transaction cost.

The original data used in our project is the closing prices of 15 stocks whose market capitalization are top 15 on NASDAQ from all transaction days in the year 2020. We access the data directly from Yahoo! Finance, NYSE, and NASDAQ. These closing price data was processed to generate the daily stock return which will be used in this project. We assume that we are currently holding these 15 stocks with equal amount of money, and we hope to adjust the positions of each stock in the portfolio after solving the optimization problems.

#### 2. Mathematical Model

We discuss the optimization model that we used for the portfolio selection problem in this section. We consider an investment portfolio that consists of holdings in part or all a set of different stocks. And this portfolio is to be revised after performing the optimization with respect to maximizing the expected return. We also show how to transfer a set of real-world constraints on the portfolio to mathematical languages. For the sake of convenience, we restricted the investment targets to be listed stocks in U.S. market. So that we can have public access to the historical data. And we suppose there are n stocks in total.

##### 2.1 Modeling Assumptions

- Firstly, we assume that there is no limit to the amount that can be longed or shorted. For all investment objects (stocks), i.e. the supply and demand for every stock is abundant in the market. This is because in this case, the original portfolio is irrelevant, except for its total value. We can make whatever transactions are necessary to arrive at the optimal portfolio.
- Moreover, we assume that each stock can be modeled as a random variable with an expected return
*𝜇𝑖*. And a standard deviation*𝜎𝑖*, here the standard deviation is a measure of uncertainty. - We assume that the returns of each stock, representing by the random vector
*𝑎*a, have a jointly Gaussian distribution. And we assume that we can use 1-year historical data to infer its expected value and standard deviation. - Lastly, we assume that the initial holdings in each asset are $100.

##### 2.2 Decision Variables

Under normal circumstances, the brokerage fees for the two operations of buying (long) and selling (short). Are likely to be different, so here we introduce 2n decision variables, which is twice the quantity of investable targets, to separately indicating the amount transacted in each stock.

##### 2.3 Constraints

*2.3.1 Diversification Constraints*

Diversification of investment targets is one of the most common ways to hedge risks, it is the practice of spreading the investments around so that the exposure to any one type or group of assets is controlled. This practice is designed to help reduce the volatility of the portfolio over time.

*2.3.2 Short selling Constraints*

Short selling is an investment or trading strategy that speculates on the decline in a stock or other asset’s price. In short selling, a position is opened by borrowing shares of a stock or other asset that the investor believes will decrease in value. The investor then sells these borrowed shares to buyers willing to pay the market price. Before the borrowed shares must be returned, the portfolio manager is betting that the price will continue to decline, and they can purchase them at a lower cost. Some investors or portfolio managers may use it as a hedge against the downside risk of a long position in the same stock or a related one.

*2.3.3 Shortfall Risk Constraints*

A shortfall applies to any situation where the level of funds required to meet an obligation is not available. Temporary shortfalls often occur in response to an unexpected event. Controlling the risk of shortfall within a reasonable range is to withdraw the investment amount in time when the market is declining or the black swan event occurs, so as to avoid further unnecessary losses.

*2.3.4 Variance Constraints*

The Modern Portfolio Theory (MPT) assumes that investors are risk-averse; for a given level of expected return, investors will always prefer the less risky portfolio. Under the framework, we prefer a overall portfolio with lower variance as it is a mathematical indicator about the level of overall risk of the portfolio.

*2.3.5 Budget Constraints*

After the adjustment transactions, it is obvious that every transaction on current position (current holding in each listed stock) incurs fees. Which means no matter what kinds of transactions are made. The total amount of the wealth of the portfolio (post-transaction) must be less than the pre-transaction value.

##### 2.4 Objective Function

Generally, the objective of a portfolio optimization problem is to maximize the expected wealth at the end of current period subject to some constraints like what we discussed above. Meanwhile, we may also consider a related problem of minimizing the total transaction costs subject to portfolio constraints. Among all possible transactions that result in portfolios achieving a given expected return and meeting the other portfolio constraints, we would like to perform those transactions that incur the smallest total cost. Before writing down the compact form of the optimization problem, we would like to introduce two slightly different way to model the transaction costs, which are linear and fixed.

*2.4.1 Linear Transaction Costs*

Transaction costs are expenses incurred when buying or selling a stock, in a financial sense, transaction costs include brokers’ commissions and spreads, which are the differences between the price the dealer paid for a stock or security and the price the buyer pays.

Here transaction costs can be used to model many fees for financial trading. Such as brokerage fees, bid-ask spreads, and taxes. In this project, we only consider the commissions fee charged by the brokers.

*2.4.2 Fixed Transaction Costs*

However, sometimes the brokers may require a basis fee in addition to the proportional fee once the transaction incurs, a fixed charge for any nonzero trade is common, we consider a model that includes fixed plus linear costs

##### 2.5 Standard Form

With some obvious assumptions, we would like to solve an expected wealth maximization problem with all the constraints we described above.

Similarly, we may formulate another related optimization problem, which minimize the total transaction costs subject to portfolio constraints, but it also has a desired lower bound on the expected return at the end of current period. We summarize it as follows:

#### 3. Solution

##### 3.1 Data Processing and Basic Visualization

We are currently holding 15 stocks with the highest market capitalization on NASDAQ which are “AAPL”, “MSFT”, “AMZN”, “GOOGL”, “FB”, “TCEHY”, “TSLA”, “BRK-B”, “BABA”, “V”，”JPM”, “TMC”, “JNJ”, “BAC”, “WMT”. In addition, we have 1,500 dollars in total to invest. And each stock is invested equally with 100 dollars now. Furthermore, we want to develop a single-period portfolio management strategy to adjust current positions in each stock. Based on Markowitz’s Modern Portfolio Theory. Each stock can be modeled as a random variable (RV). With an expected daily return *𝜇𝑖* and a standard deviation *𝜎𝑖*. We assume all stock returns have normal distributions.

###### 3.2 Model without Considering the Fixed but Linear Cost and Other Common Constraints

We first consider a most intuitive model with linear cost, whose objective function is to maximize the total wealth of the portfolio at the end of this trading period. For the transaction cost (mainly the brokerage fee). We only consider the fixed case (i.e. the transaction costs is proportional cost to the total traded amount).

**For this model, after multiple trials, we finally decided to discard the shortfall risk constraint.**

Because this constraint significantly decrease our end of current single-period wealth 𝑊 which results in a dramatic loss in our investment portfolio. Shortfall risk constraint is for setting the wealth 𝑊 with a positive lower bound 𝑊𝑙𝑜𝑤 to avoid the market declining or the black swan event. However, this constraint also limits the short selling strategy in our model at the same time. Short selling strategy allows a temporary negative holding when the portfolio manager believe the price will decline (negative rate of return), which contradicts with the shortfall risk constraint. This is also a limitation of this model where we don’t balance shortfall risk constraint and short selling constraint, so we must make some trade off.

All the stock closing price data originates based on the entire year 2020 where the stock market finds itself significantly influenced by COVID-19 pandemic. As we can see from the graph shown below, only 4 out of 15 stocks have positive expected daily return. Therefore, our model will automatically prefer to choose to short sell for these stocks with negative daily return.

**By eliminating the shortfall risk constraint in this model, we would be able to end up with a better end of period wealth value $1502.26 which is higher than the wealth before transaction.**

As we can see from the pie chart shown below, we put over a half weights on “BAC”, the stock of highest expected daily return, which intuitively makes sense.

###### 3.3 Model with Considering the Fixed + Linear Cost, and Other Common Constraints

After the first model, we now consider a slightly modified model with fixed cost, whose objective function is still to maximize the total wealth of the portfolio at the end of this trading period. For the transaction cost (mainly the brokerage fee). We only consider the fixed + linear case (i.e. the transaction costs consists of a certain amount of fixed cost once the transaction finishes. Plus a proportional cost to the total traded amount).

For this model, we introduce binary variable to represent. If the fixed cost incurs so that the fixed brokerage cost constraint can be handled properly. As we discussed in the first model section, we choose not to use the shortfall risk constraint in this model as well for the same reason as before.

By adding the additional fixed brokerage cost constraint. We eventually end up with a end of period wealth value $1489.18, which is lower than the wealth before transaction. This result attributes to the added fixed brokerage cost occurred in each transaction. Moreover, given that only 4 out of 15 stocks have positive expected daily return mainly due to COVID-19 pandemic. As a result, it is extremely difficult for our model to make profit in the trading in this situation.

As we can see from the pie chart shown below, we put highest weight (34.6%) on “BAC”. The stock of highest expected daily return, and put nearly equal weight on the rest stocks except for “TMC”.

###### 3.4 Model with Considering Minimizing the Total Transaction Costs (Objective Function)

For our third model, we consider a related problem. It is intuitive that every transaction will triger some additional transaction costs like brokerage fee and tax. So, some customers may require their managers to maintain a lowest expected return while reducing the overall number of transactions to minimize the lost. So here we introduce a new problem by simply changing the objective function from maximizing total wealth to minimizing the total transaction costs, but we also need to introduce a new constraint to keep a satisfactory level of expected return.

**We try to minimize the total transaction costs as our objective function. **

We also keep the fixed brokerage cost constraint as the second model. As we discussed in the first model section, we choose not to use the shortfall risk constraint in this model as well for the same reason as before. And we add a expected return constraint. Where the end of period wealth value sets to be greater than or equal to $1480. We choose to set a value lower than initial wealth because we consider that 11 out of 15 stocks have negative expected daily return and fixed transaction cost also significantly decrease the end of period wealth. It is good enough for the model to maintain less loss for the wealth in the stock market under this difficult situation.

##### We eventually end up with a end of period wealth value $1488.62, which is higher than the expected value in the expected return constraint.

This end of period wealth value is very close to the one in the second model. Although these two models have different objective function, it turns out that they achieve close end of period wealth value.

As we can see from the pie chart shown below, this time there is no dominant stock in our portfolio. Most stock take a nearly equal weight except for “BRK-B” and “AAPL”.

#### 5. Conclusion

This portfolio optimization project applies optimization techniques. To customize the investment portfolio involving more real-world constraints including linear/fixed transaction cost, shortfall risk constraint, short selling constraint. And diversification constraint, variance constraint and budget constraint, etc. Given different appetites of investors and transaction mechanism. We formulate three optimization problems and display the corresponding holding of each stock and total wealth at the end of trading period. Due to the COVID-19 pandemic influence on stock price. We only make little profit and even lose money for some models by using our portfolio. All the stock prices derive from all transaction days in 2020 so the result is basically applicable in practice.

**We also realize that in the real-world trading, portfolio manager may consider more sophisticated constraints and specific objective function in the optimization model. **

For example, implementing the short selling strategy with proper shortfall risk constraint can be a good idea to consider. Besides, there are many assumptions for this model, for example, in the process of formulating the shortfall risk constraints, we made the assumptions like the end-period wealth is a random variable which follows Gaussian distribution. This may violate the situation in the real trading scene.

In conclusion, this work hopefully could provide some guidance and details facing the rapid changing financial market. While earning profits from the financial market can never be guaranteed. At least one can know they are doing it optimally.

#### Single-Period Portfolio Optimization with Mean-Variance Analysis Written by:

*Jingde Wan (**wan38@wisc.edu**)*

**Back To News**

#### 6. References For Single-Period Portfolio Optimization with Mean-Variance Analysis

Lobo, M. S., Fazel, M., & Boyd, S. (2007). Portfolio Optimization with Linear and Fixed Transaction Costs. *Annals of Operations Research*, 152(1), 341-365.

Skaf, J., & Boyd, S. (2009). Multi-period portfolio optimization with constraints and transaction costs. *Working Manuscript*.