1000 CLS  
1010 PRINT "       SHARPE'S METHOD OF PORTFOLIO SELECTION":PRINT   
1020 PRINT "tHIS PROGRAM STARTS WITH DATA PERTAINING TO A MARKET INDEX  
1030 PRINT "AND SEVERAL POSSIBLE STOCKS TO HOLD. fOR EACH STOCK THE  
1040 PRINT "USER INPUTS THE ALPHA AND BETA PARAMETERS ALONG WITH THE  
1050 PRINT "VARIANCE OF RETURN(OR STANDARD DEVIATION OF RETURN=VOLATILITY).  
1060 PRINT "FOR THE INDEX THE EXPECTED VALUE AND VARIANCE OF RETURN  
1070 PRINT "ARE ENTERED. tHE PROGRAM THEN CALCULATES THE PROPORTION  
1080 PRINT "A RISK FACTOR MAY ALSO BE INCLUDED. THIS FACTOR TAKES ON VALUES  
1090 PRINT "BETWEEN 0 AND 4 OR 5. THE HIGHER THE RISK FACTOR THE MORE  
1100 PRINT "DARING THE INVESTOR SHOULD BE. 0 MEANS VERY CONSERVATIVE.  
1150 PRINT :INPUT "PRESS ENTER TO BEGIN";Z9  
1200 REM DATA INPUT  
1201 CLEAR   
1205 CLS  
1210 INPUT "NUMBER OF STOCKS BEING CONSIDRED FOR PORFOLIO";N  
1215 PRINT   
1220 PRINT "ENTER 1 IF STOCK VARIANCE OF RETURN IS BEING ENTERED.  
1230 INPUT "ENTER 0 IF STOCK STANDARD DEVIATION OF RETURN IS ENTERED";Q  
1240 IF  Q<>0  AND  Q<>1 THEN PRINT "INPUT ERROR!":GOTO  1215  
1250 RA=N+3:CA=N+3:REM # ROWS & COLUMNS ON MATRIX  
1255 DIM  A(N+3,N+3),T(N+3,1),AL(N),BE(N),V(N)  
1257 CLS  
1260 FOR  I=1 TO N  
1265 IF  Q=1 THEN GOTO  1280  
1270 PRINT "ENTER STOCK";I;" ALPHA,BETA,ST.DEV";:INPUT  AL(I),BE(I),V(I)   
1273 V(I)=-2*V(I)[2  
1277 GOTO 1300:REM NEXT I  
1280 PRINT "ENTER STOCK";I;" ALPHA,BETA,VARIANCE";:INPUT  AL(I),BE(I),V(I)  
1285 V(I)=-2*V(I)  
1290 GOTO  1300  
1300 NEXT  I  
1302 PRINT   
1303 INPUT "INDEX RETURN";RI  
1305 INPUT "INDEX VARIANCE OF RETURN";RV  
1310 PRINT   
1320 INPUT "ENTER RISK FACTOR ";RF  
1330 FOR  I=1 TO N:A(I,I)=V(I):NEXT   
1340 FOR  I=1 TO N:A(N+2,I)=1:A(I,N+2)=1:NEXT   
1350 A(N+1,N+1)=-2*RV:A(N+1,N+3)=-1:A(N+3,N+1)=-1  
1360 FOR  I=1  TO  N:A(N+3,I)=BE(I):A(I,N+3)=BE(I):NEXT   
1370 FOR I=1 TO N:T(I,1)=-RF*AL(I):NEXT :T(N+1,1)=-RF*RI:T(N+2,1)=1  
2220 REM NOW INVERTING MATRIX A  
2230 FOR  J=1  TO  CA  
2240 FOR  I=J  TO  RA  
2250 I1=I  
2260 IF  A(I,J)<>0 THEN GOTO  2300   
2270 NEXT  I  
2280 PRINT  "NO UNIQUE SOLUTION. MATRIX A IS SINGULAR."  
2290 END  
2300 FOR  K= 1  TO  RA  
2310 AS = A(J,K):A(J,K)=A(I1,K):A(I1,K)=AS  
2320 NEXT  K  
2330 AS=T(J,1):T(J,1)=T(I1,1):T(I1,1)=AS  
2340 AP = 1/A(J,J)  
2350 FOR  K= 1  TO  RA  
2360 A(J,K)=AP*A(J,K)  
2370 NEXT  K  
2380 T(J,1)=AP*T(J,1)  
2390 FOR  L=1  TO  RA  
2400 IF  L=J THEN GOTO  2460   
2410 AP= -A(L,J)  
2420 FOR  K=1  TO  RA  
2430 A(L,K)=A(L,K)+AP*A(J,K)  
2440 NEXT  K  
2450 T(L,1)=T(L,1)+AP*T(J,1)  
2460 NEXT  L  
2470 NEXT  J  
2475 CLS  
2480 PRINT  "SOLUTION FOLLOWS "  
2490 PRINT   
2500 FOR  I=1 TO N  
2510 PRINT "PROPORTION FOR STOCK ";I;" = ";T(I,1)  
2520 NEXT  I  
2540 PRINT   
2550 INPUT "PRESS ENTER FOR ANOTHER COMPUTATION";Z9  
2555 IF Z9 = -1 THEN END
2560 GOTO  1200  

