Portfolio Selection with Transactions (qpsole03)
/***************************************************************/
/* */
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: qpsole03 */
/* TITLE: Portfolio Selection with Transactions (qpsole03) */
/* PRODUCT: OR */
/* SYSTEM: ALL */
/* KEYS: OR */
/* PROCS: OPTMODEL */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: Example 3 from the Quadratic Programming Solver */
/* chapter of Mathematical Programming. */
/* */
/***************************************************************/
/* 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 b s;
quit;