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OSUB 350:DX=DX+OX:? MO;"/";DA;"/";YR;:RETURN 
350 OX=LEN(STR$(IX)):RETURN 
400 GOSUB 490:? CD$:TRAP 498:OPEN #ZZ1,ZZ4,ZZ0,"D:PRTFOLIO":POSITION ZZ4,ZZ12:? "Current portfolio is being loaded"
401 GOSUB 770:? CD$:POSITION ZZ3,ZZ5:? "  This module of STOCK CHARTING":? "allows the user to graph the per-"
402 POSITION ZZ2,ZZ7:? "formance for a stock in the user's":? "portfolio."
403 POSITION ZZ4,17:? "Would you like to see the current portfolio? (Y/N) ";:INPUT ZZ$:TRAP 40000
405 IF ZZ$="YES" OR ZZ$="Y" THEN GOSUB 470
410 POKE RM,RQ:? CD$:POSITION ZZ3,ZZ2:? "Graph stock closing data on file":POSITION ZZ3,ZZ4:? "ÆÏÒÍÁÔ­ STOCK,START DATE,END DATE"
411 POSITION ZZ10,ZZ6:? "* INPUT EXPLANATION *":POSITION ZZ4,ZZ8:? "STOCK- Ticker symbol used by stock"
412 POSITION ZZ11,ZZ9:? "exchange. Must be identical":POSITION 11,10:? "to stock definition symbol."
413 POSITION ZZ4,ZZ12:? "START- OPTIONAL- First date for":POSITION ZZ5,13:? "DATE  which stock closing data is"
414 POSITION ZZ11,14:? "to be graphed. If omitted,":POSITION ZZ11,15:? "first file entry is assumed."
415 POSITION ZZ5,17:? " END- OPTIONAL- Only applicable if":POSITION ZZ5,18:? "DATE  start date is employed. Graph"
416 POSITION ZZ11,19:? "ends at end date or file end.":GOSUB 476
420 ? CD$:POSITION ZZ4,ZZ1:? "Graph stock closing data on file":POSITION ZZ3,ZZ4:? "ÆÏÒÍÁÔ­ STOCK,START DATE,END DATE"
421 POSITION 13,ZZ6:? "** EXAMPLES **":POKE LM,ZZ4:POSITION ZZ4,ZZ8:? "CDA":? "WCI,7/13/79":? "DOW,7/25/79,8/15/79"
424 POKE LM,ZZ3:? :? "ÉÎÐÕÔ óôïãë ôï âå çòáðèåä® Åîä ÉÎÐÕÔ":? "âù ðòåóóéîç ÒÅÔÕÒÎ ïîìù®":? 
425 POKE CS,ZZ0:INPUT ZZ$:POKE CS,ZZ1:ZTL=LEN(ZZ$):IF ZTL=ZZ0 THEN ? CD$:GOTO 445
426 SDATE=ZZ0:EDATE=ZZ0:LFT=ZZ0:CB=ZZ1
427 GOSUB 477:IF M=1 OR M>ZZ5 THEN ? "Stock symbol error ":GOTO 443
428 V$(ZZ3,ZZ6)="    ":V$(ZZ3,ZZ6)=ZZ$(CB,M-1)
429 FOR J=ZZ1 TO SP-ZZ4 STEP ZZ4:IF V$(ZZ3,ZZ6)<>S$(J,J+3) THEN NEXT J:? "Stock not in portfolio ":GOTO 443
430 LSP=INT(J/ZZ4)+ZZ1:SDATE=ZZ0:EDATE=32766:IF M-ZZ1=ZTL THEN 441
431 CB=M+ZZ1:GOSUB 477:IF ZSER=1 THEN 443
432 LX=M-1:GOSUB 460:IF ZSER=1 THEN 505
433 SDATE=TDATE:IF M-1=ZTL THEN 441
435 CB=M+ZZ1:GOSUB 477:IF ZSER=1 THEN 505
436 LX=M-1:GOSUB 460:IF ZSER=1 THEN 505
440 EDATE=TDATE:IF SDATE>EDATE THEN ? "List date error":GOTO 443
441 IF FD(LSP,ZZ0)=ZZ0 THEN ? "No closing data filed in portfolio":GOTO 443
442 GOSUB 600:GOTO 420
443 CRROW=PEEK(84):IF CRROW>21 THEN POSITION ZZ3,15:? "œ":POSITION ZZ3,CRROW-ZZ1:GOTO 443
444 GOTO 425
445 POSITION ZZ3,ZZ12:? "Insert STOCK CHARTING system disk":GOSUB 476
446 TRAP 447:RUN "D:STOCK"
447 TRAP 40000:IF PEEK(195)=170 THEN POKE 195,ZZ0:OPEN #ZZ7,ZZ4,ZZ0,"K:":GOTO 445
448 GOTO 499
450 GET #ZZ7,ZZKK:IF ZZKK=80 THEN TRAP 459:OPEN #ZZ5,ZZ8,ZZ0,"P:PP":GOTO 456
452 IF ZZKK<>155 THEN 450
453 RETURN 
456 DIS=PEEK(106)*256-961:FOR ZZJJ=ZZ1 TO 920:ZZJK=PEEK(DIS+ZZJJ):IF ZZJK>127 THEN ZZJK=ZZJK-128
457 IF ZZJK>95 THEN ZZJK=ZZJK-32
458 ? #ZZ5;CHR$(ZZJK+32);:NEXT ZZJJ:CLOSE #ZZ5
459 TRAP 40000:? ZZBZ$;:GOTO 450
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 GOSUB 490:? CD$:POSITION ZZ11,ZZ1:? "CURRENT PORTFOLIO":POSITION ZZ11,ZZ2:? "------- ---------":POKE LM,ZZ3:? 
471 SE=ZZ0:IF SP=ZZ1 THEN POSITION ZZ10,13:? "Portfolio is empty":GOTO 476
472 SE=ZZ0:FOR I=ZZ1 TO NSP:? S$(ZZ4*I-ZZ3,ZZ4*I);"  ";:SE=SE+ZZ1:IF SE=ZZ6 THEN SE=ZZ0:? 
474 NEXT I
476 POSITION ZZ2,23:POKE 764,255:? R$;:GOSUB 450:RETURN 
477 ZSER=0:GOSUB 500:FOR M=CB TO ZTL:IF ZZ$(M,M)<>" " AND ZZ$(M,M)<>"," THEN NEXT M
478 RETURN 
479 ? "Input date is incorrect":GOTO 425
480 ? "--ERROR--";:ZZ$(N,N)=CHR$(ASC(ZZ$(N,N))+128):? ZZ$:GOTO 425
490 POKE LM,ZZ2:POKE RM,37:RETURN 
493 ? CD$:POSITION ZZ3,ZZ1:? "Input daily stock closing quotes":POSITION ZZ2,ZZ3:? "FORMAT-DATE,STOCK,VOL,HIGH,LOW,CLOSE":RETURN 
498 CLOSE #ZZ1:? CD$:IF PEEK(195)=170 THEN POSITION ZZ4,ZZ11:? "Insert disk containing stock data":GOSUB 476:? CD$:GOTO 400
499 ? "DISK I/O ERROR ";PEEK(195):END 
500 IF CB>ZTL THEN ? "Insufficient data":ZSER=1:POP 
501 RETURN 
505 ? "Date error":GOTO 443
510 ? "Insufficient data":GOTO 443
600 TRAP 650:OPEN #ZZ1,ZZ4,ZZ0,V$:NOTE #ZZ1,SEC,BYT
601 TRAP 660:PNO=FD(LSP,ZZ0):IF SDATE=ZZ0 THEN XHI=FD(LSP,ZZ1):XLO=FD(LSP,ZZ2):GOTO 605
602 XPNO=ZZ0:XLO=32000:XHI=ZZ0:FOR K=ZZ1 TO PNO:GOSUB 658:IF F1>=SDATE AND F1<=EDATE THEN XPNO=XPNO+ZZ1:GOSUB 655
603 NEXT K:PNO=XPNO:IF XPNO=ZZ0 THEN ? "No closing quotes for date(s) exists":POP :CLOSE #ZZ1:GOTO 425
605 XXHI=ZZ10*INT(XHI/ZZ10):IF XHI-XXHI<>ZZ0 THEN XXHI=XXHI+ZZ10
606 XHI=XXHI:XLO=ZZ10*INT(XLO/ZZ10):MXDIF=XHI-XLO+ZZ1:QMXDIF=MXDIF/ZZ4
609 OPEN #ZZ2,ZZ4,ZZ0,"D:PRTFOLIO":INPUT #ZZ2,ZZ$
610 FOR HED=ZZ1 TO LSP:INPUT #ZZ2,ZZ$:INPUT #2,E4,E4,E4,E4,E4,E4,E3,E2,E1,D4,D3,D2,D1:NEXT HED:CLOSE #ZZ2
611 D(ZZ0)=E4:D(ZZ1)=E3:D(ZZ2)=E2:D(ZZ3)=E1:D(ZZ4)=E4+E3+E2+E1
612 D(ZZ5)=D4:D(ZZ6)=D3:D(ZZ7)=D2:D(ZZ8)=D1:D(ZZ9)=D4+D3+D2+D1:GOSUB 680
619 POINT #ZZ1,SEC,BYT:TRAP 40000
620 SCLO=ZZ0:ESCLO=ZZ0:PCT=ZZ1:FOR I=ZZ1 TO PNO:COLOR 2:TRAP 780:GOSUB 713:XCOR=20+PCT:PLOT XCOR,PR*(XHI-F3):DRAWTO XCOR,PR*(XHI-F4)
621 IF DV<>ZZ0 THEN DV=ZZ0:GOSUB 697
622 VOLTOP=PV*F2:IF VOLTOP>78 THEN VOLTOP=78
623 PLOT XCOR,78-VOLTOP:DRAWTO XCOR,78:GOSUB 669
624 IF D(ZZ4)<=ZZ0 THEN ? "NMF";:GOTO 627
625 CPE=INT(F5/D(ZZ4)):TAB=ZZ3-LEN(STR$(CPE)):IF TAB>ZZ0 THEN GOSUB 692
626 ? CPE;
627 TAB=ZZ7:GOSUB 695:CDV=(INT(1000*D(ZZ9)/F5))/ZZ10:TAB=ZZ4-LEN(STR$(CDV)):IF TAB>ZZ0 THEN GOSUB 692
630 ? CDV;:FOR M=ZZ1 TO 14:? "";:NEXT M
635 PCT=PCT+ZZ1:IF PCT<>121 THEN 640
636 PCT=ZZ1:IF I=PNO THEN 649
637 GOSUB 698:GOSUB 680
640 NEXT I
649 GOSUB 698:CLOSE #ZZ1:GRAPHICS ZZ0:RETURN 
650 TRAP 40000:CLOSE #ZZ1:POP :PZ=PEEK(195):POKE 195,0:IF PZ<>170 THEN 654
651 ? "No closing data filed in portfolio"
652 CRROW=PEEK(84):IF CRROW>21 THEN POSITION ZZ3,15:? "œ":POSITION ZZ3,CRROW-ZZ1:GOTO 652
653 GOTO 425
654 GOTO 661
655 IF F3>XHI THEN XHI=F3
656 IF F4<XLO THEN XLO=F4
657 RETURN 
658 IF XPNO=ZZ0 THEN NOTE #ZZ1,SEC,BYT
659 GOSUB 713:RETURN 
660 ZP=PEEK(195):IF ZP=136 THEN 604
661 ? "ERROR ";ZP:END 
669 IF I<ZZ10 THEN 672
670 TDS=F5:FOR M=ZZ1 TO ZZ9:TDS=TDS+OSC(M):NEXT M:TDS=TDS/ZZ10
671 TDS=0.9*TDS+0.1*F5:COLOR ZZ1:PLOT XCOR,PR*(XHI-TDS)
672 IF I<ZZ7 THEN 679
673 IF (QMXDIF-(OSC(ZZ9)-OSC(ZZ4)))<0 OR (QMXDIF-(F5-OSC(ZZ5)))<0 THEN 679
674 COLOR ZZ3:PLOT 19+PCT,QMXDIF-(OSC(ZZ9)-OSC(ZZ4)):DRAWTO XCOR,QMXDIF-(F5-OSC(ZZ5))
679 FOR M=ZZ1 TO ZZ9:OSC(M-ZZ1)=OSC(M):NEXT M:OSC(ZZ9)=F5:RETURN 
680 POKE 82,ZZ1:POKE 83,39:GRAPHICS ZZ7:POKE 752,ZZ1:SETCOLOR ZZ4,12,ZZ8:SETCOLOR ZZ0,ZZ3,ZZ4:SETCOLOR ZZ1,12,ZZ0:SETCOLOR ZZ2,ZZ8,ZZ6:DV=ZZ0
682 PR=65/MXDIF:PV=13/2000:COLOR ZZ3
684 PLOT 20,ZZ0:DRAWTO 20,78:PLOT 141,0:DRAWTO 141,78:FOR TK=XLO TO XHI STEP 10:YCOR=PR*(XHI-TK)
686 PLOT 18,YCOR:DRAWTO 20,YCOR:PLOT 141,YCOR:DRAWTO 143,YCOR:NEXT TK
688 ? V$(ZZ3,ZZ6);" PE=    YIELD=     Low ";XLO;" High ";XHI:? "Earnings ";:GOSUB 696:? "Dividends";:GOSUB 696:RETURN 
692 FOR M=ZZ1 TO TAB:? B$;:NEXT M:RETURN 
693 TAB=ZZ5-LEN(STR$(D(DV))):IF TAB>ZZ0 THEN GOSUB 695
694 ? D(DV);:DV=DV+ZZ1:RETURN 
695 FOR M=ZZ1 TO TAB:? "";:NEXT M:RETURN 
696 FOR VNO=ZZ1 TO ZZ4:GOSUB 693:NEXT VNO:TAB=ZZ4:GOSUB 695:GOSUB 693:? :RETURN 
697 DX=ZZ4:GOSUB 300:FOR M=ZZ1 TO CL-ZZ4:? "";:NEXT M:? "";:RETURN 
698 ? "";:TAB=ZZ7:GOSUB 695:? "Ðòåóó ÒÅÔÕÒÎ";:DX=ZZ3:GOSUB 300
699 POKE 764,255:GET #ZZ7,KBD:IF KBD<>155 THEN 699
700 RETURN 
712 INPUT #ZZ1;ZZ$:RETURN 
713 INPUT #ZZ1,F1,F2,F3,F4,F5:RETURN 
770 INPUT #ZZ1,SP:NSP=INT(SP/ZZ4)
771 FOR I=ZZ1 TO NSP:INPUT #ZZ1,SS$:GOSUB 713:S$(ZZ4*I-ZZ3,ZZ4*I)=SS$:FD(I,ZZ0)=F1:FD(I,ZZ1)=F2:FD(I,ZZ2)=F3
772 NEXT I:CLOSE #ZZ1:FS1=ZZ1:RETURN 
780 CLOSE #ZZ1:TRAP 40000:GOSUB 698:GRAPHICS 0:GOTO 420
