Home All Groups Group Topic Archive Search About

Days and Years - Data Comparing

Author
9 Mar 2009 7:18 PM
Webbiz
I'm assuming this is a basic question. I'm interested in all your opinions.


Suppose, for example, that your program loads in stock price data into an
array of type STOCKDATA.

Private Type STOCKDATA
    dDate as Date
    fOpen as single  'open price
    fHigh as single   'high price
    fLow as single   'low price
    fClose as single  'close price
End Type

Now, suppose that you have 10 years worth of price data in this array.

You want to do a year-to-year comparison of this price data, where you would
take a date range (ex: 3/2 to 3/9)
and compare that range for all years loaded in.

Or you want to compare that date range of prices of year 7 with year 9 only.

Now I know that I can run LOOPS on the array itself, extract the data from
3/2 to 3/9 of each year and store it somewhere, then compare them.

So my question is this:

If you know you are going to be comparing the price data based on date
ranges (ex: 3/2 to 3/9), comparing all years or specified years, or be able
to add up all the yearly values for a specific day (like add the high price
of each year that falls on 3/2), or other such tasks, what would be the best
way to reference this data?

Should I simply do a bunch of For...Each loops on my existing array of
STOCKDATA, having the loop code look for the first date of my range and then
start extracting into some other storage variable (array, file, ??) to later
do the comparing? Or should I create a multi-dim array where the indexes are
based on what I'll be referencing by, such as arrMyArray(Month, Day, Year)?

I'm thinking that running my whole array through For...Each loops each time
I want to compare 4/5 to 4/9 of year 1 to 3 (or all years) is a bit
inefficient. But then, my experience is not that deep so that is why I put
the questions out here.

Thank you in advance.

Webbiz  ;^)

Author
9 Mar 2009 7:32 PM
dpb
Webbiz wrote:
....
> Suppose, for example, that your program loads in stock price data into an
> array of type STOCKDATA.
....
> Now, suppose that you have 10 years worth of price data in this array.
....
> If you know you are going to be comparing the price data based on date
> ranges (ex: 3/2 to 3/9), comparing all years or specified years, or be able
> to add up all the yearly values for a specific day (like add the high price
> of each year that falls on 3/2), or other such tasks, what would be the best
> way to reference this data?
....
If this is going to be more than just a one-off kind of thing, I'd
suggest a searchable database structure rather than just flat arrays
would be the starting point.

At a bare minimum, assuming there is a consistent set of data
loaded/year, one could at a minimum have keys or compute the array
indices of arbitrary dates to within quite close ranges even if weren't
going to do more sophisticated work over long period to justify a
database solution.

But, if going to try to do stuff on various other correlating values
such as symbol or so on, it would rapidly return the investment unless
again this is just a once or twice kind of thing.

And, of course, if the objective is to develop some sort of predictive
model for future results from past performance, it's been pretty well
shown that is an invalid premise.

--
Author
9 Mar 2009 8:30 PM
Webbiz
Thanks for your input dpb. It would appear that based on the replies so far,
going the Database route is best.

As to the 'predictive' modeling being shown invalid, I'll leave that debate
to a different forum.  :^)

Thanks again.

Webbiz


Show quoteHide quote
"dpb" <n***@non.net> wrote in message news:gp3qvm$38g$1@aioe.org...
> Webbiz wrote:
>
> And, of course, if the objective is to develop some sort of predictive
> model for future results from past performance, it's been pretty well
> shown that is an invalid premise.
>
> --
Author
9 Mar 2009 8:19 PM
David Kerber
In article <PXdtl.68923$cI2.29***@newsfe09.iad>, nospam@formethanks.com
says...

....

> I'm thinking that running my whole array through For...Each loops each time
> I want to compare 4/5 to 4/9 of year 1 to 3 (or all years) is a bit
> inefficient. But then, my experience is not that deep so that is why I put
> the questions out here.
>
> Thank you in advance.

Put it in a database, and use SQL queries to get the date ranges you
want.



--
/~\ The ASCII
\ / Ribbon Campaign
X  Against HTML
/ \ Email!

Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Author
9 Mar 2009 8:30 PM
Webbiz
Thanks David.

Was wondering if that would be the way to go.  :^)

Webbiz


Show quoteHide quote
"David Kerber" <ns_dkerber@ns_wraenviro.com> wrote in message
news:MPG.241f43e8a40fcf829896c2@news.east.cox.net...
> In article <PXdtl.68923$cI2.29***@newsfe09.iad>, nospam@formethanks.com
> says...
>
> ...
>
>> I'm thinking that running my whole array through For...Each loops each
>> time
>> I want to compare 4/5 to 4/9 of year 1 to 3 (or all years) is a bit
>> inefficient. But then, my experience is not that deep so that is why I
>> put
>> the questions out here.
>>
>> Thank you in advance.
>
> Put it in a database, and use SQL queries to get the date ranges you
> want.
>
>
>
> --
> /~\ The ASCII
> \ / Ribbon Campaign
> X  Against HTML
> / \ Email!
>
> Remove the ns_ from if replying by e-mail (but keep posts in the
> newsgroups if possible).
>
Author
10 Mar 2009 12:13 AM
Nobody
You can use DatePart("y", d) to get the day of the year, and/or
Weekday/DateAdd/DateDiff functions to do what you want. You can use these
functions in VB code(loop through the array), or in SQL queries when using
MS Access DB or MS SQL Server.