You are on page 1of 3

Feature program.

ment management
Buy/ sell decisions with your TRS-80

Model I/III 16K Level or Disk


II

Michael M. T. Henderson, Lawrence, KS

Making money with securities is easy if you follow half the amount newly invested. If you sell shares, it
these basic principles: (1) Buy sound stocks or mutual doesn't change at all. It is the difference between the
fund shares. (2) Buy more shares when the price is low. actual and the control values that triggers the buy/sell
(3) Sell shares when the price is high.. instructions at line 2110, which are in turn blocked if
The first principle is well known and volumes have fewer than 10 shares would change hands. The
been written about picking investments, diversifying, computer applies the formula for you and lets you sleep
etc. I will not try to cover the subject here. This article is at night, confident that a "do nothing" instruction
about using your TRS-80 to manage your chosen meant that the price had not changed enough to make it
investments according to the last two principles. worth buying or selling any shares.
It is notoriously difficult to buy at the bottom and sell
at the top. If I knew how to do that, I wouldn't need to
work for a living. What we want is a tool which allows us Suitable securities for investment
to sell our investments gradually as they rise in value A stock which never moves is not suitable since you
and to acquire more of them (again, gradually) as they will never buy or sell, and it will just sit there losing
fall in value. All we need, really, is a formula plus the ground to inflation. You want about as much volatility
realization that buying or selling all of our holdings in a as you can be comfortable with (look up "Beta" in any
particular security is unwise. We will always miss the investment handbook). You also want a stock whose
best opportunities. individual share prices are relatively low so that when
The program shown below provides such a formula your TRS-80 tells you to buy or sell a certain number of
fora portfolio of up to 20 different securities. Using this shares, that number will be closer to the magic 100 so
formula, you can ignore the Dow-Jones Industrial beloved (and charged lower commissions for) by
averages, stop worrying about the prime rate, buy a stockbrokers than to a weird number which will sock
newspaper with a list of stock prices every three months you with an "odd lot differential" charge. Many mutual
and let your TRS-80 do the worrying. funds fit the bill, offering the advantages of liquidity,
Lines 100-200 display the menu, check to see whether low individual share prices and small (or no)
or not you have a diskette and store this information for commissions on sales or redemptions. The new fund
use in the later I/O routines. When you create a new groups which allow you to switch your assets between
data file, the amount of cash you have invested is stored growth and income or money market funds in the same
as C(I). The value, V(I), and the control value, C V(I), are group (by phone) offer an almost ideal vehicle for this
set equal to C(I). The latter two change as you update investment tool.
stock prices using the routines at 2000. If the price goes It would be wise, before rushing out and investing
up from the original purchase value, the value your money on my say-so, to try out the formula on a
increases, but the cash invested stays the same. stock with a known history. Pick a date in the past,
Likewise, if the price goes down, value decreases while initialize a data file with the stock's price as of that date,
investment remains the same. pretend you bought 1000 shares or so and then update
The control value is the interesting variable. It the file with the new price every three months after the
changes only as you buy more shares and then only by "initial purchase" date. Keep track of the money you put

22 80-U.S. Journal
5 *

Feature program

in and took out. See if by today's date you would be


190 XX=VAL(XX$)
richer than if you had bought and held. In nine out often
cases, you will be richer than had you been calling the
200 ON XX GOTO 220,390,550,730,850,1010
exact turns in the Dow Jones Industrial Average. (If you ,1110,1290
could do that, you should be publishing a market letter 210 GOTO 120
and making bigger bucks than possible from investing). 220 'CREATE A NEW DATA FILE
The best feature of this investment tool is that you 230 I=1:GOSUB250
don't have to hope that stock prices will rise forever 240 G0T0120
after you buy shares. If they rise, you take some profits; 250 CLS:IF 1=20 THEN 380
and if they fall, you get the chance to buy more. The only
stocks this won't work with are those which fall straight
260 PRINTa782,"E NTER RECORD
N 0. ";I
down from the moment you buy them. No investment
270 PRINTa704,STRING$(64,"-")
strategy will work with those.
280 PRINTa74,"";:INPUT"NAME OF STOCK :
For a more detailed explanation of this investment
";N$(I>
strategy, I recommend the book on which the formula is
loosley based: How to Make $1,000,000 in the Stock 290 PRINTal38,"";:INPUT"N0. SHARES
Market Automatically!, by Robert Lichello, $2.75,
: ";N(D
Signet Books New American Library, 1633 Broadway, 300 PRINTa202,"";:INPUT"CASH INVESTED
a of
New York, NY 10019. It is cited in the REMs at the p>

beginning of the program. 310 C(I)=C:V(I)=C:PC(I)=C


320 PRINTa330,"";:G0SUBl210
330 G0SUB1230
340 PRINTa768,"T0 CORRECT THIS RECORD,
10 REM INVESTMENT MANAGEMENT PROGRAM B HIT 'CLEAR .":PRINT"T0 SAVE IT AND GO
8

Y MICHAEL M. T. HENDERSON ON TO AJOTHER RECORD, HIT ENTER."; CH


20 REM DEPARTMENT OF LINGUISTICS, UNIVE R$(30)
RSITY OF KANSAS 350 PRINT"T0 CLOSE THE FINKEYSLE, TYPE
30 REM LAWRENCE, KANSAS 66045 S
C .";CHR$(30)
8

40 REM 7/1/81 360 GOSUB1190:IFASC(XX$X>31ANDASC(XX$)


50 REM THIS PROGRAM SCIENTIFICALLY DETE <>13AND XX$<>"C" THEN 340
RMINES HOW MANY STOCKS 370 IF ASC(XX$)=31 THEN 250ELSE IF XX$=
60 REM TO BUY/SELL AS STOCK PRICES FALL "C" THEN 380 ELSEIFASC(XX$)=13THENI=I
/RISE. IT CAN BE RUN +1:G0T0250
70 REM MONTHLY OR QUARTERLY., THE F0RMUL 380 IM=I:CLS:PRINT"FILE CLOSED. ";:G0SU
AS ARE LOOSELY DERIVED B1210:RETURN
80 REM FROM ROBERT LICHELLO S "HOW TO M 8
390 'COMPUTATION SUBROUTINE
AKE $1,000,000 IN THE 400 CLSsINPUT"DATE OF RECORD FOR THIS S
90 REM STOCK MARKET AUTOMATICALLY! " (S ESSION: ";D$
IGNET 1977). 410 G0SUB1150
100 CLEAR 1Q00:DEFINT IsDIM N$(20),N(20 420 CLS:PRINT"TYPE THE PRICE OF ";N$(D
),C(20),V(2Q),PC(20):D$=" " ;" AS OF ";D$;": ";
110 IFPEEK(16396)=201THENDD=0:DD$="TAPE 430 INPUTP
"ELSEDD=1:DD$="DISK" 440 V(I)=P*N(I)
120 CLS:PRINTalO,"INVESTMENT MANAGEMENT 450 PRINT
PROGRAM - UP TO 20 STOCKS" 460 IF PC(I)>V(I)THEN M=PC(I)-V(I)-(V(I
130 PRINT SPRINT,, "MENU": PRINT; P=1 )/10):Z=M/P:G0T0 490
140 PRINTTAB(P)"1 - CREATE NEW DATA FIL 470 IF PC(IXV(I)THEN M=V(I)-PC(I)-(V(I
E":PRINTTAB(P)"2 - COMPUTE PURCHASE/S )/10):Z=M/P:G0T0 500
ALE 480 G0T0510
150 PRINTTAB(P)"3 - RECORD PURCHASES/SA 490 IF Z=>10PRINT"BUY"INT(Z/10+.5)*10"
LES":PRINTTAB(P)"4 - RECORD DATA ON " SHARES.":G0T0520ELSE 510
DD$ 500 IF Z=>10PRINT"SELL"INT(Z/10+.5)*10"
160 PRINTTAB(P)"5 - READ DATA FROM "DD$ SHARES. ":G0T0520ELSE 510
:PRINTTAB(P)"6 - DISPLAY FILE CONTENT 510 PRINT"D0 NOTHING."
S 520 PRINT"T0 SEE ANOTHER RECORD TYPE '

170 PRINTTAB(P)"7 - ADD A RECORD": PRINT '. TO SEE THE MENU


TAB(P)"8 - END" 530 PRINT"HIT ENTER":G0SUB1 190:IFASC(XX
180 GOSUB 1190:IF XX<1 OR XX>8 THEN 120 $)<>13 AND ASC(XX$X>91THEN 520
April, 1982 23
Feature program.

540 IF ASC(XX$)=91 THEN 410 ELSE GOTO 1 900 FOR 1=1 TO IM


10 910 GOSUB 1000
550 'UPDATE SUBROUTINE 920 IF DD=1INPUT#1,N$U),N(I),C(I),V(I)
560 CLS:G0SUB1150 ,PC(I):GOTO 940
570 GOSUB 1230 930 INPUT #-1,N$(I),N(I),C(I),V(I),PC(I
580 INPUT"N0. SHARES BOUGHT/SOLD ";S )
590 INPUT"DOLLAR AMOUNT OF TRANSACTION 940 NEXT I:IF DD=1 CLOSE
";D 950 PRINT:PRINT"READING FINISHED. ";IM;"
600 PRINT:PRINT"IF TRANSACTION WAS A RECORDS WERE READ ."s GOSUB 1210:G0T0 1
TYPE" 20
610 PRINV BUY , M ,

V
B :PRINV'SELLV S M
, ,

960 'I/O DISPLAY SUB


620 GOSUB1190:IFXX$0 B"ANDXX$0 S"THEN
,, ,,
970 PRINTsPRINTa322,IM;"REC0RDS ARE BEI
600 NG PROCESSED. RECORD DATE IS ";D$
630 IFXX$="S" THEN 660 980 RETURN
640 C(I)=C(I)+D:V(I)=V(I)+D:N(I)=N(I)+S 990 'COUNTER
1000 PRINT5)399^ N0W ON RECORD NO.";IsRE
,B

650 PC(I)=PC(I)+(D/2):G0T0 670 TURN


660 C(I)=C(I)-D:V(I)=V(I)-D:N(I)=N(I)-S 1010 'DISPLAY SUB
670 CLS 1020 CLSsF$="$$###^###.## $$###^###.#
680 GOSUB 1230 tt"
690 IF N(I)=OTHENPRINT"NO SHARES LEFT. 1030 PRINT" NAME"|TAB(21)' N0. SHARES";
e

DELETING RECORD #";I:FOR 1=1+1 TO IM: TABC39) "VALUE";TAB(50) "CASH INVESTED


N$(I-1)=N$(I):N(I-1)=N(I):C(I-1)=C(I) 1040 M=OsT=0
:V(I-1)=V(I):PCU-1)=PC(I):NEXT I:IM= 1050 FOR 1=1 TO IM
IM-1 1060 PRINT I;N$(I);TAB(24)N(I);TAB(33)U
700 PRINT"TO UPDATE ANOTHER RECORD TYPE SINGF$;V(I);C(I)
*'.";CHR$(13);"T0 SEE THE MENU,, HIT 1070 M=M+C(I):T=T+V(I)
ENTER." 1080 NEXT I
710 GOSUB 1190:IF ASC(XX$)<>13 AND ASC( 1090 PRINT" TOTALS AS OF "D$;TAB(33)US
XX$)<>91 THEN 700 INGF$;T;M
720 IF ASC(XX$)=91 THEN 560 ELSE 120 1100 GOSUB 1210sG0T0 120
730 'RECORD ON TAPE/DISK 1110 'ADD SUB
740 IFD$=" "THENINPUT"WHAT IS TODAY'S D 1120 I=IM+1
ATE";D$ 1130 GOSUB 250
750 CLS : I FDD=1 THEN0PEN"Q"1 /'DATA" : PRIN 1140 GOTO 110
T#1,IM;CHR$(34);D$;CHR$(34);:GOT0790 1150 CLSs 'DISPLAY STOCK NAMES
760 PRINT"LOAD DATA TAPE. PRESS RECORD 1160 FOR 1=1 TO IM
& PLAY KEYS.":GOSUB 1210 1170 PRINT I;" ";N$(D,
770 PRINT"RECORDING... 1180 NEXTI:INPUT"NUMBER OF THE STOCK WA
780 PRINT #-1,IM,D$:G0SUB 960 NTED "; I : I FI>IMTHENG0T01 1 50ELSERETU
790 FOR 1=1 TO IM RN
800 GOSUB 1000 1190 XX$=INKEY$:IF XX$="" THEN 1190;'IN
810 IFDD=1THENPRINT#1,CHR$(34);N$(I);CH KEYS ROUTINE
R$(34);N(I);C(I);V(I);PC(I):GOT0830 1200 XX=VAL(XX$)s RETURN
820 PRINT#-1,N$(I),N(I),C(I),V<I),PC(I) 1210 'DELAY SUB
1220 PRINT"<ENTER> TO CONTINUE"; GOSUB 1
830 NEXT I: IF DD=1 CLOSE 190: RETURN
840 PRINT: PRINT"RECORDING FINISHED. ";IM 1230 'RECORD DISPLAY
;"RECORDS WERE WRITTEN. ":GOSUB 1210:G 1240 CLS:PRINT"THE RECORD FOR "N$(D;"
OTO 110 IS:"
850 'READ FROM TAPE/DISK 1250 F$="$$###^### B ##"
860 CLS:IF DD=1THEN0PEN"I",1,"DATA":INP 1260 PRINT" NO. SHARES VALUE"
UT#1,IM,D$:G0T0900 1270 PRINTTAB(4)N(I);TAB(15)USINGF$;C(I
870 PRINT"LOAD DATA TAPE. PRESS PLAY KE )
Y.":GOSUB 1210 1280 RETURN
880 PRINT"READING... 1290 'END OF PROGRAM
890 INPUT #-1,IM/D$:G0SUB 960 1300 END m
24 80-U.S. Journal

You might also like