home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / t / tas501.zip / PERFCHK.TAS < prev    next >
Text File  |  1993-03-07  |  2KB  |  76 lines

  1. #TITLE Calculate Performance for specific securities                  
  2. { PERFCHK.TAS  ( Author Martin Moore)
  3.  Script to print out the performance of specific securities since a 
  4.  particular date. 
  5.  To add a ticker and date to the list of stocks to be tracked, edit
  6.  the file PERFCHK.DTA (the data file for this script) and 
  7.  put a line like this in:
  8.    tickerName,dateSince,numShares
  9.  
  10.  where 'tickerName' is the stock ticker 
  11.        'dateSince' is the year, month and day (format YYMMDD)
  12.        'numShares' is the number of shares to compute change on
  13. }
  14. FTicker : String;
  15. FDate   : Number;
  16. FShares : Integer;
  17. TickerFound : Integer;
  18. ClArray : Array;        { Closing price array}
  19. DtArray : Array;        { Date array }
  20. TotProfit : Number;
  21. Profit : Number;
  22. choice : integer;
  23. Prolog BEGIN
  24.    
  25.    OutputFile('PerfChk.Lst');
  26.    writeln('              Transaction    Current    ',
  27.         'Percent    Points     Profit');
  28.    writeln('Ticker  Shares     Date       Close     ',
  29.         ' Change    Change      /Loss');
  30.     choice = VMenu('Create Performance Report ',
  31.                   'Update Performance Data ');
  32. End;
  33. if choice = 2 then goto UpdateList; { Update perfchk.dta}
  34. { Open the performance data file for reading }
  35. FileNo = AOpen('perfchk.dta','r');
  36.  
  37. { Read Ticker, Date, Shares from file }
  38. While AGet(FileNo,Fticker,Fdate,Fshares)   
  39. Begin
  40.    { Locate the date on or before the date found in 
  41.      the PERFCHK.DTA file for this ticker}
  42.    DtArray = Load(FTicker,'D');
  43.    ClArray = Load(FTicker,'C');
  44.    For I=Quote_Count; I > 0; I = I-1;
  45.       if DtArray[i] <= Fdate then Break;
  46.    If I <> 0 Then 
  47.    Begin
  48.       Write(Expand('%-6s   %5d  %8s  %9.3f   %8.3f%%  %8.3f',
  49.             Fticker,
  50.             Fshares,
  51.             DateStr(DtArray[i]),
  52.             ClArray,
  53.             ROC(ClArray,Quote_Count-I,'%'),
  54.             ROC(ClArray,Quote_Count-I,'$')));
  55.       Profit = (ClArray[0]-ClArray[I]) * Fshares;
  56.       WritelN(Expand('%11.2f ',Profit));
  57.       TotProfit = TotProfit + Profit;
  58.    End;
  59. End;
  60. AClose(FileNo);
  61. WriteLn(Expand('Total Profit %55.2f',TotProfit));
  62. Stop;
  63. :UpdateList
  64. choice = VMenu('Add A Symbol','Quit');
  65. if choice = 1 Then
  66. Begin
  67.     Ask('Symbol',FTicker,
  68.         'Number of Shares',Fshares,
  69.         'Date',FDate);
  70.     FileNo = AOpen('perfchk.dta','a');
  71.     APutLn(FileNo,Expand('%s,%6.0f,%d',FTicker,FDate,FShares));
  72.     Aclose(FileNo);
  73. End;
  74. if choice = 1 then goto UpdateList;
  75. Stop;
  76.