[tech-spec] Re: BBchart

  • From: Dirk Eddelbuettel <edd@xxxxxxxxxx>
  • To: tech-spec@xxxxxxxxxxxxx
  • Date: Tue, 26 Oct 2004 16:47:33 -0500

On Tue, Oct 26, 2004 at 11:36:18AM -0400, Tom McCubbin wrote:
> The output looks damn beautiful.  But the source code begs some 


> now obviously, you make some sweeping assumptions about a finite trading 
> days / year, which of course is variable, and for the last 10 years (cal 
> 1992-2003) numbered 2519 for nyse stuff, or ~251.9/ year.  I am however 
> a spoiled brat, and just can't accept approximation ( here it doesn't 
> matter i know, because it just spots a rough point in time to snatch 
> yahoo data ), so how can this be done better in R?

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.

> Now, I'm looking for some nice way to contribute to this group, so could 
> someone tell me how to handle calendaring, or would it be a good 
> contribution to package calendaring functionality for R for the group?

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 ...
> 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?


If your hair is standing up, then you are in extreme danger.
      -- http://www.usafa.af.mil/dfp/cockpit-phys/fp1ex3.htm

Other related posts: