|
Posted by lluum@yahoo.com on 10/29/23 11:52
I am experimenting a simple stock database. Let's say it only contains
the end-of-day trading data for Intel. The database has the following
columns
date OpenPrice HighPrice LowPrice ClosePrice TradingVolume
For each trading date, I need to compute simple moving average based on
the last fifty days' ClosePrice. I guess I need to add a column named
SMA_50 and perform the computation to fill the column up.
To perform the computation, for each trading date, select the
ClosePrice of previous 50 trading days, add them up and divide the sum
by 50, I have to do this for each trading day.
Here are my specific questions:
1. Should I define the column SMA_50 as a Computed Column and use a
user defined function to perform the computation, or should I use other
approaches (such as triggers stored procedures)?
2. For each trading day, how can I select the ClosePrice of the last
fifty trading days.
Note that trading dates are not consecutive, weekends and holidays are
NOT trading days. It appears to be easy, but as an occasional user of
DB, I do not have an immediate solution.
Thank you very much for your input.
Navigation:
[Reply to this message]
|