Continuing on to function #3.....

Stock data normally consists of 6 pieces of data: date, open, high,
low, close, volume.  Occasionally, early data for some stocks has no
data for the opening price of the day.  One technique that some data
vendors use (in order to guarantee non-zero prices, which screw up
charting software) is to replace the zero open price with the price of
the close on the previous day.  That is the purpose of function #3.
Starting with row 1 (NOT row 0!), if the open (column 1) is zero,
replace it with the close (column 4) of the *previous* day; otherwise,
go on to the next row.  You must use *explicit* code (NOT tacit code).
If you have another approach, that's fine, too, as long as it's
explicit code.  I presume this function is relatively easy (but it
would save me time, which is valuable in my hyper-busy life these days
preparing for a lengthy, little-by-little residential move).

As an example, the opening 0.00 price on 1990-03-02 below would be
replaced with the 0.29 closing price on 1990-03-01.

DATA SET C:

1990-03-01,0.00,0.31,0.29,0.29,428800
1990-03-02,0.00,0.29,0.29,0.29,313600
1990-03-05,0.00,0.31,0.29,0.29,1395200
1990-03-06,0.00,0.31,0.29,0.29,1152000
1990-03-07,0.00,0.31,0.29,0.31,854400
1990-03-08,0.00,0.31,0.29,0.29,227200
1990-03-09,0.00,0.31,0.29,0.31,547200
1990-03-12,0.00,0.31,0.29,0.29,1196800
1990-03-13,0.00,0.29,0.29,0.29,3372800
1990-03-14,0.00,0.29,0.29,0.29,134400
1990-03-15,0.00,0.31,0.29,0.29,3017600
1990-03-16,0.00,0.29,0.29,0.29,195200
1990-03-19,0.00,0.29,0.29,0.29,409600
1990-03-20,0.00,0.29,0.28,0.28,2982400
1990-03-21,0.00,0.28,0.23,0.26,11424000
1990-03-22,0.00,0.26,0.23,0.25,3043200
1990-03-23,0.00,0.28,0.25,0.27,3340800
1990-03-26,0.27,0.28,0.27,0.27,2348800
1990-03-27,0.27,0.27,0.26,0.26,1667200
1990-03-28,0.26,0.27,0.26,0.27,1104000
1990-03-29,0.27,0.27,0.26,0.26,275200
1990-03-30,0.26,0.26,0.25,0.25,787200

If this were like high school math class, "extra credit" would be to
incorporate code to replace a zero value in column 1 (open) of row 0
with the value in column 4 (close) of the same row.  (I'm sure I can
do that, but if you want to throw it in to fill out the function, feel
free!)

A variation "super extra credit"(!) is the fact that, with really old
data, sometimes only one piece of data exists for a given date (this
is always assumed to be the close).  "Your mission, should you wish to
accept it", is to write code that will expand a data set in a
"date,close" format to a "date,open,high,low,close" format by
duplicating the close data.  (Some charting software wants data to be
in the latter format.)  The latter format is also useful for merging
old data with newer data already in that format.

Yet again, thanks in advance for any and all help with this!

Harvey
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to