0 REM Modified by Jim Woolley, FOG Disk Librarian, 8/82
1 RANDOMIZE TIMER
2 FOR A=1 TO 5:READ NA$(A):NEXT
3 DATA IBM,RCA,LBJ,ABC,CBS
5 CLS:WIDTH 80
10 PRINT TAB(30);"STOCK MARKET":PRINT
20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
30 PRINT: PRINT: PRINT
100 REM STOCK MARKET SIMULATION     -STOCK-
101 REM REVISED 8/18/70 (D. PESSEL, L. BRAUN, C. LOSIK)  
102 REM IMP VRBLS: A-MRKT TRND SLP; B5-BRKRGE FEE; C-TTL CSH ASSTS;    
103 REM C5-TTL CSH ASSTS (TEMP); C(I)-CHNG IN STK VAL; D-TTL ASSTS;
104 REM E1,E2-LRG CHNG MISC; I-STCK #; I1,I2-STCKS W LRG CHNG; 
105 REM N1,N2-LRG CHNG DAY CNTS; P5-TTL DAYS PRCHSS; P(I)-PRTFL CNTNTS;
106 REM Q9-NEW CYCL?; S4-SGN OF A; S5-TTL DYS SLS; S(I)-VALUE/SHR; 
107 REM T-TTL STCK ASSTS; T5-TTL VAL OF TRNSCTNS;
108 REM W3-LRG CHNG; X1-SMLL CHNG(<$1); Z4,Z5,Z6-NYSE AVE.; Z(I)-TRNSCT
110 DIM S(5),P(5),Z(5),C(5) 
112 REM SLOPE OF MARKET TREND:A  (SAME FOR ALL STOCKS) 
113 X=1
114 A=INT((RND(X)/10)*100+.5)/100 
115 T5=0
116 X9=0
117 N1=0
118 N2=0
119 E1=0
120 E2=0
121 REM INTRODUCTION 
122 PRINT "DO YOU WANT THE INSTRUCTIONS"; 
123 INPUT Z9$
124 PRINT 
125 PRINT 
126 IF LEFT$(Z9$,1)="N" THEN 200
129 CLS
130 PRINT "THIS PROGRAM PLAYS THE STOCK MARKET.  YOU WILL BE GIVEN" 
132 PRINT "$10,000 AND MAY BUY OR SELL STOCKS.  THE STOCK PRICES WILL"
134 PRINT "BE GENERATED RANDOMLY AND THEREFORE THIS MODEL DOES NOT" 
135 PRINT "REPRESENT EXACTLY WHAT HAPPENS ON THE EXCHANGE.  A TABLE"
136 PRINT "OF AVAILABLE STOCKS, THEIR PRICES, AND THE NUMBER OF SHARES
137 PRINT "IN YOUR PORTFOLIO WILL BE PRINTED.  FOLLOWING THIS, THE" 
138 PRINT "INITIALS OF EACH STOCK WILL BE PRINTED WITH A QUESTION"
139 PRINT "MARK.  HERE YOU INDICATE A TRANSACTION.  TO BUY A STOCK" 
140 PRINT "TYPE +NNN, TO SELL A STOCK TYPE -NNN, WHERE NNN IS THE"  
141 PRINT "NUMBER OF SHARES.  A BROKERAGE FEE OF 1% WILL BE CHARGED"
142 PRINT "ON ALL TRANSACTIONS.  NOTE THAT IF A STOCK'S VALUE DROPS"
143 PRINT "TO ZERO IT MAY REBOUND TO A POSITIVE VALUE AGAIN.  YOU"
144 PRINT "HAVE $10,000 TO INVEST.  USE INTEGERS FOR ALL YOUR INPUTS."
145 PRINT "(NOTE:  TO GET A 'FEEL' FOR THE MARKET RUN FOR AT LEAST" 
146 PRINT "10 DAYS)":PRINT
147 PRINT "-----GOOD LUCK!-----"  :PRINT
150 LINE INPUT "HIT 'RETURN' TO START THE GAME.";XX$:PRINT:PRINT
200 REM GENERATION OF STOCK TABLE; INPUT REQUESTS  
210 REM INITIAL STOCK VALUES 
220 S(1)=100
230 S(2)=85 
240 S(3)=150
250 S(4)=140
260 S(5)=110
265 REM INITIAL T8 - # DAYS FOR FIRST TREND SLOPE (A)
266 T8=INT(4.99*RND(X)+1) 
267 REM RANDOMIZE SIGN OF FIRST TREND SLOPE (A)
268 IF RND(X)>.5 THEN 270 
269 A=-A
270 REM RANDOMIZE INITIAL VALUES 
280 GOSUB 830 
285 REM INITIAL PORTFOLIO CONTENTS 
290 FOR I=1 TO 5
300 P(I)=0
305 Z(I)=0
310 NEXT I
320 PRINT 
330 PRINT 
333 REM INITIALIZE CASH ASSETS:C 
335 C=10000 
338 REM PRINT INITIAL PORTFOLIO
339 F1$="  $$##.##":F2$="$$,###,###.##"
340 CLS:PRINT "STOCK"," ","INITIALS","PRICE/SHARE"
345 PRINT "-----"," ","--------","-----------"
350 PRINT "INT. BALLISTIC MISSILES","  IBM",:PRINT USING F1$;S(1)
352 PRINT "RED CROSS OF AMERICA","  RCA",:PRINT USING F1$;S(2) 
354 PRINT "LICHTENSTEIN, BUMRAP & JOKE","  LBJ",:PRINT USING F1$;S(3)
356 PRINT "AMERICAN BANKRUPT CO.","  ABC",:PRINT USING F1$;S(4)
358 PRINT "CENSURED BOOKS STORE","  CBS",:PRINT USING F1$;S(5) 
360 PRINT 
361 REM NYSE AVERAGE:Z5; TEMP. VALUE:Z4; NET CHANGE:Z6 
363 Z4=Z5 
364 Z5=0
365 T=0 
370 FOR I=1 TO 5
375 Z5=Z5+S(I)
380 T=T+S(I)*P(I) 
390 NEXT I
391 Z5=INT(100*(Z5/5)+.5)/100 
392 Z6=INT((Z5-Z4)*100+.5)/100
393 REM TOTAL ASSETS:D 
394 D=T+C 
395 IF X9>0 THEN 398
396 PRINT "NEW YORK STOCK EXCHANGE AVERAGE: "Z5 
397 GOTO 399 
398 PRINT "NEW YORK STOCK EXCHANGE AVERAGE: ";:PRINT USING "####.##";Z5;:PRINT USING "   +###.##";Z6  
399 PRINT 
400 T=INT(100*T+.5)/100 
401 PRINT "TOTAL STOCK ASSETS ARE   ";:PRINT USING F2$;T
403 C=INT(100*C+.5)/100 
405 PRINT "TOTAL CASH ASSETS ARE    ";:PRINT USING F2$;C
407 D=INT(100*D+.5)/100 
408 PRINT "TOTAL ASSETS ARE         ";:PRINT USING F2$;D
410 PRINT 
411 IF X9=0 THEN 416
412 LINE INPUT "DO YOU WISH TO CONTINUE?";Q9$:PRINT
413 IF LEFT$(Q9$,1)="N" THEN 998
416 REM INPUT TRANSACTIONS 
420 PRINT "WHAT IS YOUR TRANSACTION IN" 
430 PRINT "IBM";
440 INPUT Z(1)
450 PRINT "RCA";
460 INPUT Z(2)
470 PRINT "LBJ";
480 INPUT Z(3)
490 PRINT "ABC";
500 INPUT Z(4)
510 PRINT "CBS";
520 INPUT Z(5)
525 PRINT 
530 REM TOTAL DAY'S PURCHASES IN $:P5
540 P5=0
550 REM TOTAL DAY'S SALES IN $:S5
560 S5=0
570 FOR I=1 TO 5
575 Z(I)=INT(Z(I)+.5) 
580 IF Z(I)<=0 THEN 610 
590 P5=P5+Z(I)*S(I) 
600 GOTO 620 
610 S5=S5-Z(I)*S(I) 
612 IF -Z(I)<=P(I) THEN 620 
614 PRINT "YOU HAVE OVERSOLD A STOCK; TRY AGAIN." 
616 GOTO 420 
620 NEXT I
622 REM TOTAL VALUE OF TRANSACTIONS:T5 
625 T5=P5+S5
630 REM BROKERAGE FEE:B5 
640 B5=INT(.01*T5*100+.5)/100 
650 REM CASH ASSETS=OLD CASH ASSETS-TOTAL PURCHASES
652 REM -BROKERAGE FEES+TOTAL SALES:C5 
654 C5=C-P5-B5+S5 
656 IF C5>=0 THEN 674 
658 PRINT "YOU HAVE USED ";:PRINT USING "$$##,###.##";-C5;:PRINT " MORE THAN YOU HAVE." 
660 GOTO 420
674 C=C5
675 REM CALCULATE NEW PORTFOLIO  
680 FOR I=1 TO 5
690 P(I)=P(I)+Z(I)
700 NEXT I
710 REM CALCULATE NEW STOCK VALUES 
720 GOSUB 830 
750 REM PRINT PORTFOLIO
751 REM BELL RINGING-DIFFERENT ON MANY COMPUTERS 
755 PRINT 
756 PRINT "**********     END OF DAY'S TRADING     **********"
757 PRINT 
758 PRINT 
759 IF X9<1 THEN 769
769 PRINT      "STOCK  PRICE/SHARE  CHANGE  HOLDINGS     VALUE"
770 PRINT      "-----  -----------  ------  --------  -----------"
776 FOR XX=1 TO 5
777 PRINT USING" \ \     $$##.##    +##.##   ####   $$,###,###.##";NA$(XX),S(XX),C(XX),P(XX),S(XX)*P(XX)
778 NEXT XX
779 X9=1
780 PRINT 
790 PRINT 
810 GOTO 360 
829 REM NEW STOCK VALUES - SUBROUTINE
830 REM RANDOMLY PRODUCE NEW STOCK VALUES BASED ON PREVIOUS
831 REM DAY'S VALUES 
832 REM N1,N2 ARE RANDOM NUMBERS OF DAYS WHICH RESPECTIVELY
833 REM DETERMINE WHEN STOCK I1 WILL INCREASE 10 PTS. AND STOCK
834 REM I2 WILL DECREASE 10 PTS. 
840 REM IF N1 DAYS HAVE PASSED, PICK AN I1, SET E1, DETERMINE NEW N1 
841 IF N1>0 THEN 850
845 I1=INT(4.99*RND(X)+1) 
846 N1=INT(4.99*RND(X)+1) 
847 E1=1
850 REM IF N2 DAYS HAVE PASSED, PICK AN I2, SET E2, DETERMINE NEW N2 
851 IF N2>0 THEN 860
855 I2=INT(4.99*RND(X)+1) 
856 N2=INT(4.99*RND(X)+1) 
857 E2=1
860 REM DEDUCT ONE DAY FROM N1 AND N2
861 N1=N1-1 
862 N2=N2-1 
890 REM LOOP THROUGH ALL STOCKS
900 FOR I=1 TO 5
910 X1=RND(X) 
915 IF X1>.25 THEN 920
916 X1=.25
917 GOTO 935 
920 IF X1>.5 THEN 925
921 X1=.5
922 GOTO 935 
925 IF X1>.75 THEN 930
926 X1=.75  
927 GOTO 935 
930 X1=0!
931 REM BIG CHANGE CONSTANT:W3  (SET TO ZERO INITIALLY)
935 W3=0
936 IF E1<1 THEN 945
937 IF INT(I1+.5)<>INT(I+.5) THEN 945 
938 REM ADD 10 PTS. TO THIS STOCK;  RESET E1 
939 W3=10 
943 E1=0
945 IF E2<1 THEN 955
947 IF INT(I2+.5)<>INT(I+.5) THEN 955 
948 REM SUBTRACT 10 PTS. FROM THIS STOCK;  RESET E2
949 W3=W3-10
953 E2=0
954 REM C(I) IS CHANGE IN STOCK VALUE
955 C(I)=INT(A*S(I))+X1+INT(3-6*RND(X)+.5)+W3 
956 C(I)=INT(100*C(I)+.5)/100 
957 S(I)=S(I)+C(I)
960 IF S(I)>0 THEN 967
964 C(I)=0
965 S(I)=0
966 GOTO 970 
967 S(I)=INT(100*S(I)+.5)/100 
970 NEXT I
972 REM AFTER T8 DAYS RANDOMLY CHANGE TREND SIGN AND SLOPE 
973 T8=T8-1 
974 IF T8<1 THEN 985
980 RETURN
985 REM RANDOMLY CHANGE TREND SIGN AND SLOPE (A), AND DURATION 
986 REM OF TREND (T8)
990 T8=INT(4.99*RND(X)+1) 
992 A=INT((RND(X)/10)*100+.5)/100 
993 S4=RND(X) 
994 IF S4<=.5 THEN 997
995 A=-A
997 RETURN
998 IF D=10000 THEN PRINT "YOU BROKE EVEN." ELSE IF D>10000 THEN PRINT "YOU MADE A PROFIT OF";:PRINT USING F2$;D-10000 ELSE IF D<10000 THEN PRINT "YOU LOST";:PRINT USING F2$;10000-D
999 end
