[tech-spec] Re: BBchart
- From: Tom McCubbin <tmccubbin@xxxxxxxxxxxxxxxx>
- To: tech-spec@xxxxxxxxxxxxx
- Date: Tue, 26 Oct 2004 11:36:18 -0400
The output looks damn beautiful. But the source code begs some
questions i have regarding R, its, and calendaring:
From your code:
# to calc the start date for data collection adjust trading days, 251,
# for calendar days, 366, add a runup period
# equal to the longest calculation length + 50
# and subtract the total from today's date
if(compress=="d") startDate <-
if(compress=="w") startDate <-
if(compress=="m") startDate <-
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?
In my world i have calendars for both regular and irregular frequencies,
represented of course as intervals, so for example:
if(compress=="d") startDate <- business_calendar( Sys.Date() ) -
if(compress=="w") startDate <- weekly_calendar( Sys.Date() ) -
if(compress=="m") startDate <- monthly_calendar( Sys.Date() ) -
would give each an interval that represented the exact date at the given
frequency. The issue is dealing w/ irregular frequency intervals should
be done just like that. as intervals, not as dates, but should be
easily converted back and forth.
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?
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
E.g., calc the moving average of weekly volume for a stock?
curious and helpless in R,
ps - i'll look at the code and try and give some more meaningful input
than my selfish wants and desires to help/prove myself...
I'd appreciate feedback from anyone who had a look at BBchart.
Other related posts: