[tech-spec] Re: BBchart

  • From: Tom McCubbin <tmccubbin@xxxxxxxxxxxxxxxx>
  • To: tech-spec@xxxxxxxxxxxxx
  • Date: Tue, 26 Oct 2004 21:09:54 -0400

Dirk Eddelbuettel wrote:

Yes, arithmetic operations are defined for DateTimeClasses, which is what is
used underneath the its object.  It is not always obvious how to milk this,
but note how help("DateTimeClasses") shows a few things, and refers to a few
other help pages. Just to give one idea:

seq(Sys.Date(), by="week", length=3)

[1] "2004-10-26" "2004-11-02" "2004-11-09"

Sys.Date() returns a "Date" object, which is a POSIXt, for which a
seq.POSIXt() exists -- and so you create sequences. Likewise there are
operators for differences etc pp.

the posix time_t and struct tm's are fine for dates/timestamps, but not for 
calendaring ...more below.

There is quite a bit of calendaring code in fBasics, the first of our
modules from www.Rmetrics.org (and also on CRAN). Maybe you could review
that functionality, see what is missing and contribute to it? Just a
suggestions to avoid yet another reinvented wheel ...

i snatched it(fBasics) and reviewed/tested and don't see the needed functionality...and the wheel is already invented in my case, and deployed round the globe at client cites. Just figure'd on sharing it if needed/wanted...

One other question: i notice that the computeXXX functions all take the data represented as business frequency. Is there a good way to handle time-scaling w/ its (or other R pkg) to handle simple meta-data like how time-series are observed, i.e., closes mark the end of a time interval, highs the high for an interval, volume the aggregate for the interval...etc...
E.g., calc the moving average of weekly volume for a stock?

Maybe in two steps: use rangeIts() to extract at weekly intervals, and then use filter() to compute the running moving average?

Like me, you read too damn fast :) The question was not for the weekly moving avg, but the moving average of weekly volume. So, for weekly time-series(ending on fridays) i want to see the moving average of the aggregate weekly volumes. What you indicate above seems to give me the moving average of the values on one day of each week? Am i wrong...

The most simple of examples:

ibm stock measured @ business day freq: (imagine dates attached)

date   open  high  low  close  volume
-------  ------   -----   -----  ------   ----------
mon   5        6       4      5.5     100
tues   5        7       5      6.5     200
wed   6.5     7.5    6      7        200
thur   6.5     6.5    6      6        500
fri      ----<holiday>---

converted to a weekly(friday) time series

date   open  high  low  close  volume
-------  ------   -----   -----  ------   ----------
wk(1)  5        7.5    4      6        1000

now take the moving avg of the volume time-series...
Note: volume is sum'd, close is the last observation w/in the new interval, the high the highest point w/in the new interval, low the lowest, etc...so for a time-series meta-data can be associated that handles the intricacies of time-scaling. understand?

My direct ? is if it is easy to do in R, i'll leave the wheel alone (not my own wheel of course, cause i don't like what i've seen). If not, this kind of functionality exists, and are (imho) the foundations of time-series / time-scaling analysis.

Dirk, maybe we should take it offline as i don't want to get kicked off the list for too much tech-crap. i'd be interested if you would like to install some of my tar-balls to test for yourself? they are standard:

make check
make install

and then i could give you a simple R wrapper to give it a go?


Maybe that would help clarify, and you could tell me i am nuts or that i haven't got a clue :)

Other related posts: