The Quadratic Programming Solver

Example 10.3 Portfolio Selection with Transactions

Consider a portfolio selection problem with a slight modification. You are now required to take into account the current position and transaction costs associated with buying and selling assets. The objective is to find the minimum variance portfolio. In order to understand the scenario better, consider the following data.

You are given three assets. The current holding of the three assets is denoted by the vector $\mathbf{c}$ = [200, 300, 500], the amount of asset bought and sold is denoted by $b_ i$ and $s_ i$, respectively, and the net investment in each asset is denoted by $x_ i$ and is defined by the following relation:

\[  x_ i - b_ i + s_ i = c_ i, \; \;  i = 1, 2, 3  \]

Suppose that you pay a transaction fee of 0.01 every time you buy or sell. Let the covariance matrix $\mathcal{C}$ be defined as

\[  \begin{array}{rcc} \mathcal{C} &  = &  \left[ \begin{array}{cccc} 0.027489 &  -0.00874 &  -0.00015 \\ -0.00874 &  0.109449 &  -0.00012 \\ -0.00015 &  -0.00012 &  0.000766 \\ \end{array} \right]\\ \end{array}  \]

Assume that you hope to obtain at least 12% growth. Let $\mathbf{r}$ = [1.109048, 1.169048, 1.074286] be the vector of expected return on the three assets, and let $\mathcal{B}$=1000 be the available funds. Mathematically, this problem can be written in the following manner:

\[  \begin{array}{ll} {\min } &  0.027489x_1^2 - 0.01748 x_1 x_2 - 0.0003 x_1 x_3 + 0.109449x_2^2 \\ &  - 0.00024 x_2 x_3 + 0.000766 x_3^2 \\ \end{array}  \]
\[  \begin{array}{rrccl} \mr {subject\  to} & & & & \\ (\mr {return}) &  \sum _{i=1}^3 r_ i x_ i &  \geq &  1.12 \mathcal{B} & \\[0.05in] (\mr {budget}) &  \sum _{i=1}^3 x_ i + \sum _{i=1}^3 0.01 (b_ i + s_ i) &  = &  \mathcal{B} & \\[0.05in] (\mr {balance}) &  x_ i - b_ i + s_ i &  = &  c_ i, &  i = 1, 2, 3 \\[0.05in]&  x_ i,\, b_ i,\, s_ i &  \ge &  0, &  i = 1, 2, 3 \\ \end{array}  \]

The problem can be solved by the following SAS statements:

/* example 3: portfolio selection with transactions */
proc optmodel;
   /* let x1, x2, x3 be the amount invested in each asset */
   var x{1..3} >= 0;
   /* let b1, b2, b3 be the amount of asset bought */
   var b{1..3} >= 0;
   /* let s1, s2, s3 be the amount of asset sold */
   var s{1..3} >= 0;

   /* current holdings */
   num c{1..3}=[ 200 300 500];
   /* covariance matrix */
   num coeff{1..3, 1..3} = [0.027489  -.008740  -.000150
                            -.008740  0.109449  -.000120
                            -.000150  -.000120  0.000766];
   /* returns */
   num r{1..3}=[1.109048 1.169048 1.074286];

   /* minimize the variance of the portfolio's total return */
   minimize f = sum{i in 1..3, j in 1..3}coeff[i,j]*x[i]*x[j];

   /* subject to the following constraints */
   con BUDGET: sum{i in 1..3}(x[i]+.01*b[i]+.01*s[i]) <= 1000;
   con RETURN: sum{i in 1..3}r[i]*x[i] >= 1120;
   con BALANC{i in 1..3}: x[i]-b[i]+s[i]=c[i];

   solve with qp;

   /* print the optimal solution */
   print x;
quit;

The output is displayed in Output 10.3.1.

Output 10.3.1: Portfolio Selection with Transactions

The OPTMODEL Procedure

Problem Summary
Objective Sense Minimization
Objective Function f
Objective Type Quadratic
   
Number of Variables 9
Bounded Above 0
Bounded Below 9
Bounded Below and Above 0
Free 0
Fixed 0
   
Number of Constraints 5
Linear LE (<=) 1
Linear EQ (=) 3
Linear GE (>=) 1
Linear Range 0
   
Constraint Coefficients 21

Performance Information
Execution Mode Single-Machine
Number of Threads 4

Solution Summary
Solver QP
Algorithm Interior Point
Objective Function f
Solution Status Optimal
Objective Value 19560.725753
   
Primal Infeasibility 7.000061E-17
Dual Infeasibility 5.408333E-17
Bound Infeasibility 0
Duality Gap 7.438973E-16
Complementarity 0
   
Iterations 11
Presolve Time 0.00
Solution Time 0.02

[1] x
1 397.58
2 406.12
3 190.17