5 REM CDC STOCK CHARTING 7/80
10 DIM S$(200),V$(6),B$(3),F$(21),MN(11),FR(9),SS$(4),ZZ$(128),CD$(1),V(3),R$(35),TUB$(5),ZZBZ$(1)
11 F$="1/81/43/81/25/83/47/8":B$=" ":V$="D:    ":CD$="}":R$="Type Ð to print, ÒÅÔÕÒÎ to continue":ZZBZ$=CHR$(253)
15 POKE 82,3:POKE 83,39:POKE 752,1:? CD$:POKE 195,0
20 FOR I=0 TO 11:READ J:MN(I)=J:NEXT I
25 DATA 1,-2,1,0,1,0,1,1,0,1,0,1
30 FOR I=0 TO 7:READ J:FR(I)=J:NEXT I
35 DATA 0,.12,.25,.37,.5,.62,.75,.87
40 OPEN #7,4,0,"K:KK":GOSUB 200:GOSUB 400
41 POKE 752,0:INPUT ZZ$:POKE 752,1:ZTL=LEN(ZZ$):LX=ZTL:IF ZTL=0 THEN ? CD$:GOTO 65
42 SDATE=0:EDATE=0:LFT=0:CB=1:IF ZZ$(CB,CB)="*" THEN LFT=1:CB=2
45 GOSUB 477:IF ZSER=1 THEN 75
46 IF M=CB OR M>4+CB THEN ? "Stock symbol error":GOTO 75
47 V$(3,6)="    ":V$(3,6)=ZZ$(CB,M-1):FOR J=1 TO SP-4 STEP 4:IF V$(3,6)<>S$(J,J+3) THEN NEXT J:GOTO 60
48 SDATE=0:EDATE=32766:IF M-1=ZTL THEN 80
49 CB=M+1:GOSUB 477:IF ZSER=1 THEN 75
53 LX=M-1:GOSUB 460:IF ZSER=1 THEN 480
54 SDATE=TDATE:IF M-1=ZTL THEN 80
55 CB=M+1:GOSUB 477:IF ZSER=1 THEN 75
56 LX=M-1:GOSUB 460:IF ZSER=1 THEN 480
57 EDATE=TDATE
58 IF SDATE>EDATE THEN ? "Date span error":GOTO 75
59 GOTO 80
60 ? "Stock not in portfolio":GOTO 75
65 ? CD$:POSITION 3,12:? "Insert STOCK CHARTING system disk":GOSUB 476
67 TRAP 70:RUN "D:STOCK"
70 TRAP 40000:IF PEEK(195)=170 THEN POKE 195,0:OPEN #7,4,0,"K:":GOTO 65
71 GOTO 191
75 CRROW=PEEK(84):IF CRROW>21 THEN POSITION 3,18:? "œ":POSITION 3,CRROW-1:GOTO 75
76 GOTO 41
80 TRAP 90:OPEN #1,4,0,V$:POKE 82,0:GOSUB 95:TRAP 40000:RCNO=0:PNO=0:GOTO 110
90 CLOSE #1:TRAP 40000:IF PEEK(195)=170 THEN ? "Stock closing data not on file":GOTO 75
92 TRAP 40000:? "ERROR ";PEEK(195):END 
95 ? CD$:LCT=0:POSITION 12,0:? "Listing of ";V$(3,6)
96 POSITION 3,2:? "DATE    VOL   HIGH     LOW    CLOSE":? :RETURN 
110 TRAP 190:INPUT #1,JDATE,VOL,HI,LOW,CLO:RCNO=RCNO+1
111 TRAP 40000
115 IF JDATE<SDATE THEN 110
116 IF SDATE<>0 AND RCNO=1 AND JDATE>SDATE THEN ? :? " Stock closing data not on file":GOSUB 195:GOTO 75
117 IF JDATE>EDATE THEN ? :? "     List request satisfied":GOSUB 195:GOTO 75
120 P84=PEEK(84):GOSUB 300:DX=4:IX=MO:GOSUB 170:DX=DX+OX:IX=DA:GOSUB 170:DX=DX+OX:POSITION 9-DX,P84
125 ? MO;"/";DA;"/";YR;:IX=VOL:GOSUB 170:POSITION 15-OX,P84:? VOL;
130 PX=19:VL=HI:GOSUB 180
140 PX=27:VL=LOW:GOSUB 180
150 PX=35:VL=CLO:GOSUB 180
160 ? :PNO=PNO+1:LCT=LCT+1:IF LCT<18 THEN 110
165 GOSUB 476:GOSUB 95:GOTO 110
170 OX=LEN(STR$(IX)):RETURN 
180 VX=0:IX=INT(VL):IF LFT<>0 THEN VX=VL-IX
181 GOSUB 170:POSITION PX-OX,P84:IF VX=0 THEN 186
182 FOR I=1 TO 7:IF VX=FR(I) THEN 184
183 NEXT I:VX=0:GOTO 181
184 ? INT(VL);" ";F$(3*I-2,3*I);:RETURN 
186 ? VL;:RETURN 
190 IF PEEK(195)<>136 THEN 194
191 IF PNO=0 THEN ? " Stock closing data not on file":GOTO 193
192 ? " END OF FILE"
193 TRAP 40000:GOSUB 195:GOTO 41
194 ? "DISK I/O ERROR ";PEEK(195):END 
195 CLOSE #1:GOSUB 476:GOSUB 420:RETURN 
200 TRAP 203:OPEN #1,4,0,"D:PRTFOLIO":POSITION 4,12:? "Current portfolio is being loaded":INPUT #1,SP:NSP=INT(SP/4)
201 FOR I=1 TO NSP:INPUT #1,SS$:S$(4*I-3,4*I)=SS$:INPUT #1,ZZ$:NEXT I:CLOSE #1:RETURN 
203 TRAP 40000:CLOSE #1:IF PEEK(195)=170 THEN POSITION 4,11:? "Insert disk containing stock data"
204 GOSUB 476:? CD$:POKE 195,0:GOTO 200
300 I=0:MO=0:YR=50:VL=JDATE
302 IF VL>0 THEN VL=VL-1461:YR=YR+4:GOTO 302
303 VL=VL+1461:YR=YR-4
304 LP=0:LPR=(1900+YR)/4:IF LPR-INT(LPR)=0 THEN LP=1
305 VL=VL-365-LP:YR=YR+1:IF VL>0 THEN 304
306 M0=VL+365+LP:YR=YR-1
315 IF M0<32 THEN 330
318 DEL=MN(I):IF I=1 THEN DEL=DEL+LP
320 MO=(30+DEL)+MO:IF MO<M0 AND I<11 THEN I=I+1:GOTO 318
325 MO=MO-(30+DEL)
330 DA=M0-MO:MO=I+1:RETURN 
360 RETURN 
400 POKE 83,39:? CD$:POSITION 5,5:? "This module of STOCK CHARTING":? "allows the user to list the closing"
401 ? "data for a stock. The stock must":? "have been previously defined in":? "the user's portfolio.":POSITION 5,17
402 ? "Would you like to see the current":? "portfolio? (Y/N) ";:POKE 764,255:INPUT ZZ$
403 IF ZZ$="Y" OR ZZ$="YES" THEN GOSUB 470
404 POKE 83,39:? CD$:POSITION 4,2:? "List stock closing data on file":POSITION 3,4:? "ÆÏÒÍÁÔ­ STOCK,START DATE,END DATE"
405 POSITION 10,6:? "* INPUT EXPLANATION *":POSITION 4,8:? "STOCK- Ticker symbol used by stock"
406 POSITION 11,9:? "exchange. Must be identical":POSITION 11,10:? "to stock definition symbol."
407 POSITION 4,12:? "START- OPTIONAL- First date for":POSITION 5,13:? "DATE  which stock closing data is"
408 POSITION 11,14:? "to be listed. If omitted,":POSITION 11,15:? "first file entry is assumed."
409 POSITION 4,17:? "  END- OPTIONAL- Only applicable if":POSITION 5,18:? "DATE  start date is employed. List"
410 POSITION 11,19:? "ends at end date or file end.":POKE 764,255:GOSUB 476
412 GOSUB 420:POKE 764,255:RETURN 
420 ? CD$:POSITION 4,0:? "List stock closing data on file":POSITION 3,2:? "ÆÏÒÍÁÔ­ STOCK,START DATE,END DATE"
421 POSITION 13,4:? "** EXAMPLES **":POKE 82,4:POSITION 4,6:? "CDA":? "WCI,7/13/79":? "*DOW,7/25/79,8/15/79"
422 ? :? " NOTE--The stock trade prices will":? "be listed in decimal form. To list"
423 ? "prices in fractions-precede the":? "stock symbol with an asterisk(*)."
425 POKE 82,3:? :? "ÉÎÐÕÔ óôïãë ôï âå ìéóôåä® Åîä ÉÎÐÕÔ":? "âù ðòåóóéîç ÒÅÔÕÒÎ ïîìù®":? :RETURN 
460 ZSER=0:CS=0:FOR I=CB TO LX:IF ZZ$(I,I)="/" THEN 463
461 IF ZZ$(I,I)<"0" OR ZZ$(I,I)>"9" THEN ZSER=1:RETURN 
462 NEXT I
463 IF CB>I-1 AND I=CB THEN ZSER=1:RETURN 
464 V(CS)=VAL(ZZ$(CB,I-1)):CB=I+1:IF I<LX THEN CS=CS+1:GOTO 462
465 YR=V(2)+1900:YL=0:YLF=0:IF YR-4*INT(YR/4)=0 THEN YL=1:IF V(0)=2 THEN YLF=1
466 IF CS<>2 OR V(0)<1 OR V(0)>12 OR V(1)<1 OR V(2)<50 OR V(2)>99 THEN ZSER=1:RETURN 
467 IF V(1)>30+YLF+MN(V(0)-1) THEN ZSER=1:RETURN 
468 TDATE=V(1):IF V(0)>1 THEN FOR I=0 TO V(0)-2:TDATE=TDATE+MN(I)+30:NEXT I:IF V(0)>2 THEN TDATE=TDATE+YL
469 YQ=INT((YR-1949)/4):TDATE=TDATE+1461*YQ+365*((YR-1950)-4*YQ):RETURN 
470 POKE 82,3:POKE 83,37:? CD$:POSITION 11,1:? "CURRENT PORTFOLIO":POSITION 11,2:? "------- ---------":? 
471 SE=0:IF SP=1 THEN POSITION 10,13:? "Portfolio is empty":GOSUB 476
474 SE=0:FOR I=1 TO SP-4 STEP 4:? S$(I,I+3);"  ";:SE=SE+1:IF SE=6 THEN SE=0:? 
475 NEXT I
476 POSITION 2,23:? R$;:GOSUB 490:RETURN 
477 ZSER=0:GOSUB 500:FOR M=CB TO ZTL:IF ZZ$(M,M)<>" " AND ZZ$(M,M)<>"," THEN NEXT M:RETURN 
478 RETURN 
480 ? "Input date is incorrect":GOTO 75
490 POKE 764,255:GET #7,ZZKK:IF ZZKK=80 THEN TRAP 499:OPEN #5,8,0,"P:PP":GOTO 496
492 IF ZZKK<>155 THEN 490
493 RETURN 
496 DIS=PEEK(106)*256-961:FOR ZZJJ=1 TO 920:ZZJK=PEEK(DIS+ZZJJ):IF ZZJK>127 THEN ZZJK=ZZJK-128
497 IF ZZJK>95 THEN ZZJK=ZZJK-32
498 ? #5;CHR$(ZZJK+32);:NEXT ZZJJ:CLOSE #5
499 TRAP 40000:? ZZBZ$;:GOTO 490
500 IF CB>ZTL THEN ? "Insufficient data":ZSER=1:TRAP 40000:POP 
501 RETURN 
