Hi there,
  I'm about to start a project I have been thinking about for a long
while.  I basically wish to analyse stock market data.  I already have the
data in a table and I'm now in the process of writing my own indicators and
oscillators.  I hope to learn while re-inventing this wheel and perhaps
explore different things unavailable in most stocks analysis software I
found.

  I would love to do an sql query that would look like the following ones.
I wonder if they are possible and valid applications for SQL and what would
be the proper implementation for these.  I know I can calculate all this
using C, but it would be most useful (to my later projects) to do it in SQL
directly (my last example gives you an idea where I'm going).

select max(opening_price, closing_price, high_price) - min(opening_price,
closing_price, low_price) as day_range...
select closing_price, moving_average(20,closing_price),
exp_mov_avg(20,closing_price)...
select closing_price, moving_average( funky_oscillator( closing_price ) )...

I think creating a module and using virtual tables may be an idea...  but
doing the above selects would involve some serious twists I think.  What
I'd need are virtual functions or something like that...

A DBMS is a good way to keep your raw data. But I highly doubt that a majority of your analysis algorithms are going to be expressible in SQL without going way beyond the intended purpose of the language. You will either find yourself limiting the analyses to what is convenient to express in SQL, or you will spend much more time writing queries than you would spend describing your data processing in a form more suited to functions. SQL is primarily a language for extracting sets from other sets, according to defined criteria (which include set relationships). Your analyses, unless they are like nothing I've ever seen or imagined, are going to be derived from functions on time series rather than sets, per se. I expect you would find a signal processing library, such as can be found in Matlab, Octave, or Scilab, to be a much better start than what you might write in SQL in reasonable time.

That said, it is not hard to imagine that selection of datasets might be done with SQL, and perhaps some query criteria might include measures derived from your own custom functions on time series.

Can you guys confirm with me whether I'm asking too much and I should
concentrate on a C or C++ implementation of my functions, or is there a way
to make it happen in sqlite?

There is no real either/or choice posed here. You can create your own custom functions to be incorporated into SQLite queries, including aggregate functions. The aggregate functions might produce some output other than what is returned to SQLite. What I think will be unreasonable or unduly limiting is making it happen in bare SQLite. You will need more.

Thanks,
  Simon
Have fun!
--
Larry Brasfield
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to