MODEL:
! Generic Markowitz portfolio model that takes into account
  bid/ask spread and taxes.  (PORTAX)
  Keywords: Downside Risk / Financial / Markowitz / Portfolio / Stocks / Taxes / Transaction Costs;
SETS:
  ASSET: RET, START, BUY, SEL, APRICE, BUYAT, SELAT, DVPS, STD, X;
 ENDSETS
DATA: ! Data based on original Markowitz example; ASSET = ATT GMC USX; ! The expected returns as growth factors; RET = 1.089083 1.21367 1.23458; ! S. D. in return for each asset; STD = .103959 .241644 .306964; ! Starting composition of the portfolio in shares; START = 100 70 100; ! Price per share at acquisition; APRICE = 80 89 21; ! Current price per share; BUYAT = 87 86 27; SELAT = 86 85 26; ! Dividends per share(estimated); DVPS = 0 0 0; ! Tax rate; TAXR = .32; ! The desired growth factor; TARGET = 1.15; ENDDATA SETS: TMAT( ASSET, ASSET) | &1 #GE# &2: CORR; ENDSETS
DATA: ! Correlation matrix; CORR= 1.000000 0.4938961 1.000000 0.4097276 0.7472293 1.000000 ; ENDDATA !---------------------------------------------------------------; ! Min the var in portfolio return; [OBJ] MIN = @SUM( ASSET( I): ( X( I)*SELAT( I)* STD( I))^2) + 2 * @SUM( TMAT( I, J) | I #NE# J: CORR( I, J) * X( I)* SELAT( I) * STD( I) * X( J)* SELAT( J) * STD( J)) ; ! Budget constraint, sales must cover purchases + taxes; [BUDC] @SUM( ASSET( I): SELAT( I) * SEL( I) - BUYAT( I) * BUY( I)) >= TAXES; [TAXC] TAXES >= TAXR * @SUM( ASSET( I): DVPS( I) + SEL( I) * ( SELAT( I) - APRICE( I))); ! After tax return requirement. This assumes we do not pay tax on appreciation until we sell; [RETC] @SUM( ASSET( I): RET( I)* X(I)* SELAT( I)) - TAXES >= TARGET * @SUM( ASSET(I): START( I) * SELAT( I)); ! Inventory balance for each asset; @FOR( ASSET( I): [BAL] X( I) = START( I) + BUY( I) - SEL( I); ); END