! Solve an Omega ratio portfolio problem as a nonlinear program
   Maximize  (E(R)-tau)/E(max(0,tau - R)),
 where the random variable R is the portfolio return, and
 tau is a give target, such as the risk free rate of return.
 The Omega ratio is sometimes suggested as an alternative to
 the Sharpe ratio, when the distribution of R is very asymmetric;
 ! Keywords: Investment, LINGO, Omega ratio, Portfolio, Risk, Scenario, Sharpe ratio, Stocks;
SETS:
 STOCK: X;
 OBS: R, DwnSide;
 OxS( OBS, STOCK): GF;
ENDSETS
DATA: Tau = 1.02; ! These data were retrieved from the site https://www.1stock1.com/; STOCK = 3M Chevron CocaCola DupontDow PandG IBM Weyerhauser Ford GE ExxonMobil Deere Boeing Merck; OBS, GF = 1975 1.2033 1.3202 1.5519 1.6659 1.092 1.3348 1.3562 1.3184 1.382 1.3733 1.217 1.5476 1.0433 1976 1.0203 1.3957 0.9605 0.9468 1.052 1.2447 1.2525 1.3977 1.206 1.2085 1.2193 1.8359 0.9838 1977 0.8565 0.9482 0.943 0.6167 0.9172 0.9798 0.5887 0.9299 0.8966 0.8974 0.7826 1.257 0.8147 1978 1.3015 1.2058 1.1779 0.9299 1.0349 1.0914 0.8995 0.9208 0.9449 1.0208 1.399 2.5378 1.2185 1979 0.796 1.2027 0.7863 1.2915 0.8354 0.8626 1.2893 0.7596 1.0743 1.1221 1.13 1.0639 1.0684 1980 1.1741 1.765 0.9674 1 0.9276 1.0544 1.0748 0.625 1.2099 1.4626 1.2268 1.3074 1.173 1981 0.9237 0.8618 1.0412 0.8171 1.167 0.8379 0.8498 0.8375 0.9367 0.7752 0.7396 0.5099 1 1982 1.3761 0.7464 1.4964 0.9857 1.4712 1.6923 1.2414 2.3209 1.6536 0.952 0.831 1.5056 0.9985 1983 1.1 1.082 1.0288 1.2899 0.9619 1.2675 0.9375 1.635 1.2358 1.1218 1.3051 1.2915 1.0679 1984 0.953 0.9025 1.1659 0.824 1.0022 1.0092 0.863 1.0767 0.9659 1.3483 0.7727 1.2943 1.0401 1985 1.1415 1.22 1.3547 1.4909 1.2237 1.2629 1.0558 1.2712 1.2848 1.225 0.9664 1.3841 1.4574 1986 1.2953 1.1902 1.3402 1.4268 1.095 0.7717 1.2276 1.4547 1.1821 1.2721 0.7957 0.9785 1.8084 1987 1.1075 0.8733 1.0099 1.5385 1.1178 0.9625 1.0265 1.34 1.0262 1.0873 1.5191 0.7237 1.2795 1988 0.9631 1.1546 1.1705 0.975 1.019 1.0552 0.9726 1.34 1.0142 1.1541 1.3813 1.6385 1.0931 1989 1.2843 1.4809 1.7311 1.2201 1.6149 0.7723 1.0995 0.8639 1.4413 1.1364 1.2813 1.4691 1.342 1990 1.0769 1.072 1.2039 0.6655 1.2331 1.2005 0.7919 0.6103 0.8895 1.035 0.7622 1.1463 1.1597 1991 1.1108 0.9501 1.7258 1.1316 1.0837 0.7876 1.2571 1.0563 1.3333 1.1763 1.024 1.0523 1.8526 1992 1.0564 1.0072 1.0436 1.0651 1.1425 0.566 1.3409 1.5244 1.1176 1.0041 0.9115 0.8403 0.7815 1993 1.0807 1.2536 1.0675 0.9913 1.0629 1.1216 1.2102 1.5044 1.2266 1.0327 1.6914 1.0779 0.7925 1994 0.9816 1.0244 1.1541 1.185 1.0877 1.3009 0.8403 0.8643 0.9726 0.9723 0.8953 1.0867 1.1091 1995 1.2436 1.1737 1.4417 1.0446 1.3387 1.2432 1.1533 1.0359 1.4118 1.3116 1.5962 1.6676 1.7213 1996 1.2505 1.2411 1.4175 1.1157 1.2967 1.658 1.0954 1.1169 1.3733 1.2174 1.1489 1.3589 1.2133 1997 0.9887 1.1846 1.2672 1.2951 1.4832 1.3812 1.0356 1.5058 1.4842 1.2487 1.4383 0.919 1.3312 1998 0.8667 1.0771 1.0047 0.8959 1.1441 1.7622 1.0357 1.2085 1.3901 1.1951 0.5644 0.6667 1.3915 1999 1.3761 1.0445 0.8694 1.4694 1.1999 1.1702 1.4133 0.9084 1.5172 1.1017 1.3194 1.2701 0.911 2000 1.2312 0.9747 1.0461 0.8223 0.7159 0.7879 0.7067 0.4396 0.9293 1.0791 1.0562 1.5928 1.3935 2001 0.981 1.0613 0.7737 0.9223 1.0088 1.4231 1.0656 0.6707 0.8361 0.9041 0.953 0.5876 0.628 2002 1.0431 0.7419 0.9298 0.8792 1.0861 0.6407 0.9099 0.5916 0.6075 0.8891 1.0502 0.8507 0.9628 2003 1.3792 1.2995 1.1576 1.3997 1.1622 1.1959 1.3005 1.7204 1.2723 1.1734 1.4188 1.2774 0.8161 2004 0.9652 1.2156 0.8205 1.191 1.1029 1.0637 1.0503 0.915 1.1782 1.2502 1.1437 1.2285 0.6957 2005 0.9443 1.0811 0.9681 0.8851 1.0508 0.8338 0.9869 0.5273 0.9603 1.0958 0.9155 1.3568 0.9897 2006 1.0055 1.2952 1.197 0.9105 1.1104 1.1819 1.065 0.9728 1.0616 1.3643 1.3958 1.2648 1.3706 2007 1.082 1.2693 1.2719 0.988 1.1424 1.1127 1.0437 0.8961 0.9962 1.2226 1.959 0.9845 1.3328 2008 0.6824 0.7926 0.7377 0.3828 0.842 0.7785 0.4151 0.3403 0.437 0.8521 0.4115 0.4879 0.5231 2009 1.4367 1.0408 1.2591 1.831 0.9808 1.5554 1.4093 4.3668 0.934 0.8542 1.4115 1.2686 1.202 2010 1.0439 1.1852 1.1539 1.2356 1.061 1.1212 1.0512 1.679 1.2089 1.0723 1.5354 1.2056 0.9863 2011 0.947 1.166 1.0639 0.8424 1.037 1.2529 0.9863 0.6409 0.9792 1.1592 0.9314 1.124 1.0461 2012 1.1361 1.0164 1.0362 1.1241 1.0177 1.0417 1.4901 1.2035 1.172 1.0211 1.1173 1.0274 1.0859 2013 1.5105 1.1551 1.1396 1.3733 1.1991 0.9792 1.1348 1.1915 1.3354 1.1693 1.0568 1.8112 1.2225 2014 1.1716 0.8981 1.022 1.0273 1.1189 0.8554 1.1368 1.0045 0.9015 0.9135 0.9687 0.9523 1.1347 2015 0.9167 0.8019 1.0175 1.1287 0.8718 0.8578 0.8353 0.909 1.2327 0.8432 0.8621 1.1124 0.9301 2016 1.1854 1.3084 0.9651 1.1115 1.0588 1.2061 1.0037 0.8609 1.0144 1.1579 1.351 1.0767 1.1145 2017 1.3181 1.0636 1.1066 1.2447 1.0928 0.9243 1.1718 1.0297 0.5522 0.9267 1.5189 1.8943 0.9558 2018 0.8095 0.869 1.032 0.7509 1.0004 0.7409 0.62 0.6125 0.4338 0.8153 0.9531 1.0936 1.3579 2019 0.9259 1.1077 1.169 2.7766 1.3588 1.1792 1.3815 1.2157 1.5298 1.0233 1.1615 1.0101 1.1903 2020 0.9908 0.7008 0.9908 1.1076 1.114 0.9391 1.1103 0.9452 0.9677 0.5907 1.5529 0.6571 0.8994 2021 1.0162 1.3896 1.0797 1.136 1.1757 1.0906 1.2282 2.3629 0.9015 1.4845 1.2744 0.9405 1.3092 2022 0.6751 1.5295 1.0743 0.8496 0.9265 1.0541 0.7528 0.5589 1.2327 1.8026 1.2504 0.9462 1.4477 2023 0.9116 0.831 0.9264 1.1209 0.9669 1.1608 1.1216 1.0482 1.0144 0.9064 0.9326 1.3684 0.9826 ; ENDDATA SUBMODEL RatioNLP: ! The Omega ratio portfolio problem solved as a nonlinear program; ! The fractions invested must sum to 1; @SUM( STOCK( s): X(s)) = 1; ! For each scenario, compute return from portfolio; @FOR( OBS( i): R( i) = @SUM( STOCK( s): GF( i, s)* X( s)); ! Compute downside below target for scenario i; DwnSide( i) >= Tau - R( i); ); ! Compute numerator of objective ratio; X2 = ( @SUM( OBS( i): R( i))/ @SIZE( OBS)) - Tau; ! Compute denominator of objective ratio; X1 = @SUM( OBS( i): DwnSide( i))/ @SIZE( OBS); MAX = RATIO; RATIO = X2/ X1; ENDSUBMODEL
CALC: @SET( 'OROUTE',1); ! Buffer size for routing output to window; @SET( 'TERSEO',2); ! Output level (0:verb, 1:terse, 2:only errors, 3:none); @SOLVE( RatioNLP); @WRITE( ' Optimal Omega ratio= ', RATIO, @NEWLINE( 1)); @WRITE( ' Stock Fraction', @NEWLINE( 1)); @FOR( STOCK( s) | X( s) #GT# 0: @WRITE( @FORMAT( STOCK( s),'12s'), ' ', @FORMAT( X( s), '8.3f'), @NEWLINE( 1)); ); ENDCALC