rem ************************************************
rem *             STOCK DATABASE PROGRAM	   *
rem ************************************************
rem *						   *
rem *	WRITTEN:   February 25, 1983		   *
rem *	BY:	   Edward A. Valenzuela		   *
rem *	VERSION:   1.35				   *
rem ************************************************
rem *							*	
rem *	Copyright (C) 2/10/83 by Edward A. Valenzuela, 	*
rem * 2001 Wyllys, Midland, Michigan, 48640. The author *
rem * grants permission to FOG to copy this program on  *
rem * a not-for-profit basis. No copies of this program *
rem * may be sold for profit except by the author.      *
rem *							*	
rem ---------- functions used in program -------------------------------

%CHAIN 140, 15000, 40, 1600
COMMON option%,entry%, nstk%,morestock$
%include juldate%
%include scrnin

n%=50
dim nshrs%(n%),namstk$(n%),xchng$(n%),equiv(n%)
dim purdate$(n%),totpurprice(n%),commission(n%)
dim incvalue(n%),pcntinc(n%),anyield(n%),key%(n%)
dim X$(N%),day%(n%),symbol$(n%)
DIM NEWPRICE(N%),OLDPRICE(N%),NEWVALUE(N%)
dim dividend(n%),YIELD(N%)
rem ... stock beta calculation arrays ...
m%=50
dim x(m%),y(m%),x0(m%),xr(m%),yr(m%),x%(m%),kode%(m%)

rem -----print disk initialization instructions-----
 if entry% > 0 then goto 900

print clear$; fn.down$(2); \
      fn.right$(10); "STOCK PORTFOLIO ANALYSIS"

print down$; fn.line$(8); fn.right$(6); \
  "CHANGE disks at this time"
print fn.right$(6); \
  "PROGRAMS disk should be on DRIVE A"
print down$; fn.right$(6); \
  "DATA files disk should be loaded on DRIVE B"
      
  space.remaining = FRE - 4000
print fn.line$(12); fn.right$(2); "Amount of FREE STORAGE area remaining "; \
   space.remaining; " bytes"
print fn.line$(14); fn.right$(6); bell$ ;
PRINT "PRESS ANY KEY TO CONTINUE "
  while not constat%
  wend

INITIALIZE
 disk.capacity% = 92
 space.remaining% = disk.capacity% - size("B:*.*")
print fn.line$(16); fn.right$(2); "Amount of FREE SPACE on DATA disk "; \
   space.remaining%; " Kbytes"
print "PLEASE TAKE NOTE OF DISK SPACE!";bell$
INPUT "enter y to continue "; yes$

900 REM ...PRINT MAIN MENU...

print clear$; fn.down$(2); \
      fn.right$(10); "STOCK PORTFOLIO ANALYSIS"
print down$; fn.right$(15);   "option list" ; down$

print fn.right$(5); "0 = EXIT to CP/M"
print fn.right$(5); "1 = CREATE stock file"
print fn.right$(5); "2 = ADD/DELETE to stock file"
print fn.right$(5); "3 = CHANGE entries in stock file"
print fn.right$(5); "4 = HISTORICAL performance summary"
print fn.right$(5); "5 = UPDATE weekly stock prices"
print fn.right$(5); "6 = TIME-SERIES regressions"
print fn.right$(5); "7 = BUY/SELL FILE entry"
print fn.right$(5); "8 = STOCK SPLIT entry"
print fn.right$(5); "9 = RISK/RETURN file sort"

print down$; fn.line$(18); fn.right$(10); bell$ ;
  input "SELECT OPTION NUMBER: "; option%

if option% <= 0 then goto 999
if option% > 9 then goto 999

on option% goto 910,920,930,940,950,960,970,980,989

rem -----end of screen option menu-----

910 rem ...... file creation menu ......
gosub 700
goto 900

920 rem ...... add to stock entries in file ......
gosub 770
goto 900

930 rem ...... modify entries in existing file ......
gosub 7300
goto 900

940 rem ...... performance summary ......
    rem ...... versus original purchase ......

CHAIN "A:STKPRICE"
goto 900

950 rem ...... update weekly stock prices ......

CHAIN "A:STKPRICE"
goto 900

960 rem ...... time-series regression analysis ......

CHAIN "A:STKGRAPH"
goto 900

970 rem ...... buy/sell data entry ......
GOSUB 3700
goto 900

980 rem ...... stock splits ......
 GOSUB 7800
goto 900

989 rem ...... beta sorting routine ......
 CHAIN "A:STKGRAPH"
goto 900

rem ..... return to original menu .....

rem ************************************************
rem *             SUBROUTINES                      *
rem ************************************************

%include stkchang

%include STKCREAT

%include stkadd

%include stktrans

%include QKSORT$

%include STKUPDTE

rem --------------------- end stkbas --------------

rem ...JUMP VECTORS FOR FILE READ AND PRINT...

310	GOTO 410   : rem ...READ IN SINGLE STOCK 
315	GOTO 415   : rem ...READ IN STOCK FILE
320 	GOTO 420   : rem ...READ IN STOCK PRICE HEADER RECORD
325	GOTO 425   : rem ...READ IN SINGLE STOCK PRICE
330 	GOTO 430   : rem ...READ IN STOCK PRICE FILE
335	GOTO 435   : rem ...PRINT SINGLE STOCK
340	GOTO 440   : rem ...PRINT STOCK FILE
345	GOTO 445   : rem ...PRINT STOCK PRICE HEADER
350	GOTO 450   : rem ...PRINT SINGLE STOCK PRICE
355	GOTO 455   : rem ...PRINT STOCK PRICE FILE

rem -----------------------------------------------

410 rem ... unit number 9
    READ #9; nshrs%(i%), namstk$(i%), symbol$(i%), xchng$(i%), purdate$(i%), \
             commission(i%), totpurprice(i%), key%(i%), dividend(i%)
    RETURN 

415 rem ... read nstk% records
    rem ... use i% for array element
    FOR i% = 1 to nstk%
      GOSUB 310
    NEXT i%
    RETURN

420 rem ... unit number 8
    READ #8; nstk%, newdate$, olddate$
    RETURN

425 rem ... use i% for array element
    READ #8; newprice(i%),oldprice(i%)
    RETURN

430 rem ... read nstk% records
    FOR i% = 1 to nstk%
      GOSUB 325
    NEXT i%
    RETURN

435 rem ... unit number 9
    PRINT #9; nshrs%(i%), namstk$(i%), symbol$(i%), xchng$(i%), purdate$(i%), \
              commission(i%), totpurprice(i%), key%(i%), dividend(i%)
    RETURN

440 rem ... print nstk% records
    rem ... use i% for array element
    FOR i% = 1 to nstk%
      GOSUB 335
    NEXT i%
    RETURN

445 rem ... unit number 8
    PRINT #8; nstk%, newdate$, olddate$
    RETURN

450 rem ... use i% for array element
    PRINT #8; newprice(i%), oldprice(i%)
    RETURN

455 rem ... print nstk% records
    FOR i% = 1 to nstk%
      GOSUB 350
    NEXT i%
    RETURN

999 end

rem ************** MAIN PROGRAM END ****************
