[R-SIG-Finance] Create a Monday-Friday time series?

Murali.Menon at avivainvestors.com Murali.Menon at avivainvestors.com
Thu Jan 6 18:29:15 CET 2011


For US holidays, the timeDate package in Rmetrics has a function holidayNYSE() to which you pass a numeric range for years, e.g. holidayNYSE(1980:1990).


-----Original Message-----
From: r-sig-finance-bounces at r-project.org [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of Mark Knecht
Sent: 06 January 2011 17:19
To: R-Finance
Subject: [R-SIG-Finance] Create a Monday-Friday time series?

   I think I'm going to have a couple of questions but I figured I'd
start with (I hope) a very simple one. I've not worked with time
series objects before so I'm trying to learn them. I've been looking
at things like ?xts, ?zoo as well as Phil Proctor's book but so far no

   Starting from this little code stub I'd like to create a Monday
through Friday time series into which I can eventually place trading
system results.

   Here's the stub:

TStoDate = function (TSDate) {
	X = strptime(TSDate + 19e6L, "%Y%m%d")

# TradeStation date format
FirstDate = 1100401
LastDate = 1100601

StartDate = TStoDate(FirstDate)
EndDate = TStoDate(LastDate)


   How can I do this, and (if possible and easy) is there a way to
exclude U.S. holidays?

   I did discover

R1 <- as.zoo(StartDate:EndDate )

does create an object, but the values are numbers which I don't
understand but suspect are some internal R code for a date, and it
appears to have enough entries to include weekends.

   Anyway, hopefully this is clear enough to describe what I'm trying
to do and where I'm stuck.


R-SIG-Finance at r-project.org mailing list
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.

More information about the R-SIG-Finance mailing list