home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / WEEKCOMP.TAS < prev    next >
Text File  |  1992-02-14  |  2KB  |  85 lines

  1. { WEEKCOMP.TAS 
  2. This script will compress daily data to true
  3. weekly data and create an ASCII output file that PML
  4. can read.
  5.  
  6. The format of the output file is 
  7.    SYMBOL,YYMMDD,HIGH,LOW,CLOSE,VOL 
  8.         or
  9. SYMBOL,YYMMDD,OPEN,HIGH,LOW,CLOSE,VOL,OPEN INT
  10. depending on whether there is OPEN information
  11. in the daily file.
  12. Author : Martin Moore Feb 14, 1992
  13. }
  14. #output_file WEEKLY.PRN N
  15. #max_quotes 250
  16. W_open     : number;
  17. W_oi       : number;
  18. W_high     : number;
  19. W_low     : number;
  20. W_close : number;
  21. W_volume: number;
  22. W_date     : number;
  23. MondayAt = 0;
  24. WeekDay = 0;
  25. PriorDay = DayWk(DATES[1]);
  26. for i = 1; i <= QUOTE_COUNT; i = i+1; 
  27. BEGIN
  28.    WeekDay = DayWk(DATES[i]);
  29.    { is it Monday or later?}
  30.     if WeekDay >= 1  then  
  31.     begin
  32.       if MondayAt = 0 then
  33.       begin
  34.            W_open = OPEN[i];
  35.            W_oi   = OI[i];
  36.            MondayAt = i;
  37.       end;
  38.     end;
  39.     { check if it is the last day of the week}
  40.     if WeekDay < PriorDay  then 
  41.     begin
  42.         GoSub doFriday;
  43.     end;
  44.     PriorDay = WeekDay;
  45. END;
  46. If MondayAt <> 0 And WeekDay <> 5 then
  47.     Gosub DoFriday;
  48. Return;
  49. { *****************************
  50.    **    doFriday:   **********
  51.     Subroutine to print out the 
  52.     summary for the week,
  53.     assumes that the current 
  54.     index "i" is the day following
  55.     the Friday or end of week
  56.   *****************************}
  57. :doFriday
  58. weekRange = i - MondayAt;
  59. k = i-1;
  60. { adjust for HHV etc}
  61. Quote_Range = k;    
  62. if k > weekRange
  63.     weekRange = weekRange+1;
  64. W_high   = HHV(H,weekRange);
  65. W_low    = LLV(L,weekRange);
  66. W_close  = C[k];
  67. W_volume = SUM(V,weekRange);
  68. W_date   = DATES[k];
  69. { reset quote range}
  70. Quote_Range = Quote_Count; 
  71. MondayAt   = 0;
  72. PriorDay = 7;
  73. write(trim(TICKER),',', 
  74.  format(W_date,'%6.0f'),',');
  75. if OPEN[k] <> 0.0 then
  76.     write(W_open,',');
  77. write(W_high,',',
  78.         W_low,',',
  79.         W_close,',',
  80.         Format(W_volume,'%8.0f'));
  81. if OPEN[k] <> 0.0 then
  82.     write(W_oi);
  83. writeln();
  84. Return;
  85.