R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("fCalendar-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('fCalendar') Loading required package: fBasics Rmetrics, (C) 1999-2005, Diethelm Wuertz, GPL fBasics: Markets, Basic Statistics, Date and Time Rmetrics, (C) 1999-2005, Diethelm Wuertz, GPL fCalendar: Markets, Basic Statistics, Date and Time > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "A1-TimeDateClass" > > ### * A1-TimeDateClass > > flush(stderr()); flush(stdout()) > > ### Name: TimeDateClass > ### Title: timeDate Class > ### Aliases: TimeDateClass rulesFinCenter listFinCenter timeDate > ### timeDate-class timeCalendar timeSequence Sys.timeDate > ### timeLastDayInMonth timeNdayOnOrAfter timeNdayOnOrBefore > ### timeNthNdayInMonth timeLastNdayInMonth is.timeDate print.timeDate > ### summary.timeDate format.timeDate isWeekday isWeekend isBizday weekDay > ### Keywords: chron > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fBasics.E1-TimeDateClass") > ## SOURCE("fBasics.Z1-BasicsTools") > > ## c - > xmpBasics("\nStart: Create Character Vectors > ") > dts = c("1989-09-28", "2001-01-15", "2004-08-30", "1990-02-09") > tms = c( "23:12:55", "10:34:02", "08:30:00", "11:18:23") > dts; tms [1] "1989-09-28" "2001-01-15" "2004-08-30" "1990-02-09" [1] "23:12:55" "10:34:02" "08:30:00" "11:18:23" > > ## timeDate - > xmpBasics("\nNext: Construct timeDate Object from Character Vector > ") > timeDate(dts, format = "%Y-%m-%d", FinCenter = "GMT" ) Warning in timeDate(dts, format = "%Y-%m-%d", FinCenter = "GMT") : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-28] [2001-01-15] [2004-08-30] [1990-02-09] > timeDate(dts, format = "%Y-%m-%d", FinCenter = "Europe/Zurich") Warning in timeDate(dts, format = "%Y-%m-%d", FinCenter = "Europe/Zurich") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28 01:00:00] [2001-01-15 01:00:00] [2004-08-30 02:00:00] [4] [1990-02-09 01:00:00] > timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S", + zone = "GMT", FinCenter = "GMT") Warning in timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S", zone = "GMT", : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-28 23:12:55] [2001-01-15 10:34:02] [2004-08-30 08:30:00] [4] [1990-02-09 11:18:23] > timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S", + zone = "Europe/Zurich", FinCenter = "Europe/Zurich") Warning in timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S", zone = "Europe/Zurich", : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28 23:12:55] [2001-01-15 10:34:02] [2004-08-30 08:30:00] [4] [1990-02-09 11:18:23] > timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S", + zone = "GMT", FinCenter = "Europe/Zurich") Warning in timeDate(paste(dts, tms), format = "%Y-%m-%d %H:%M:%S", zone = "GMT", : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-29 00:12:55] [2001-01-15 11:34:02] [2004-08-30 10:30:00] [4] [1990-02-09 12:18:23] > > ## timeCalendar - > xmpBasics("\nNext: Create a timeDate Object From Calendar Atoms > ") > timeCalendar( m = c(9, 1, 8, 2), d = c(28, 15, 30, 9), + y = c(1989, 2001, 2004, 1990), FinCenter = "GMT") Warning in timeCalendar(m = c(9, 1, 8, 2), d = c(28, 15, 30, 9), y = c(1989, : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = "%Y%m%d%H%M%S", zone = FinCenter, : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-28] [2001-01-15] [2004-08-30] [1990-02-09] > timeCalendar(m = c(9, 1, 8, 2), d = c(28, 15, 30, 9), + y = c(1989, 2001, 2004, 1990), FinCenter = "Europe/Zurich") Warning in timeCalendar(m = c(9, 1, 8, 2), d = c(28, 15, 30, 9), y = c(1989, : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = "%Y%m%d%H%M%S", zone = FinCenter, : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28] [2001-01-15] [2004-08-30] [1990-02-09] > timeCalendar(h = c(9, 14), min = c(15, 23)) Warning in timeCalendar(h = c(9, 14), min = c(15, 23)) : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = "%Y%m%d%H%M%S", zone = FinCenter, : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Zurich" [1] [2005-01-01 09:15:00] [2005-02-01 14:23:00] [2005-03-01 09:15:00] [4] [2005-04-01 14:23:00] [2005-05-01 09:15:00] [2005-06-01 14:23:00] [7] [2005-07-01 09:15:00] [2005-08-01 14:23:00] [2005-09-01 09:15:00] [10] [2005-10-01 14:23:00] [2005-11-01 09:15:00] [2005-12-01 14:23:00] > > ## timeSequence - > xmpBasics("\nNext: Create a Regularly Spaced timeDate Objects > ") > timeSequence(from = "2004-03-12", to = "2004-04-11", + format = "%Y-%m-%d", FinCenter = "GMT") Warning in timeSequence(from = "2004-03-12", to = "2004-04-11", format = "%Y-%m-%d", : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = NULL, zone = FinCenter, : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [2004-03-12 00:00:00] [2004-03-13 00:00:00] [2004-03-14 00:00:00] [4] [2004-03-15 00:00:00] [2004-03-16 00:00:00] [2004-03-17 00:00:00] [7] [2004-03-18 00:00:00] [2004-03-19 00:00:00] [2004-03-20 00:00:00] [10] [2004-03-21 00:00:00] [2004-03-22 00:00:00] [2004-03-23 00:00:00] [13] [2004-03-24 00:00:00] [2004-03-25 00:00:00] [2004-03-26 00:00:00] [16] [2004-03-27 00:00:00] [2004-03-28 00:00:00] [2004-03-29 01:00:00] [19] [2004-03-30 01:00:00] [2004-03-31 01:00:00] [2004-04-01 01:00:00] [22] [2004-04-02 01:00:00] [2004-04-03 01:00:00] [2004-04-04 01:00:00] [25] [2004-04-05 01:00:00] [2004-04-06 01:00:00] [2004-04-07 01:00:00] [28] [2004-04-08 01:00:00] [2004-04-09 01:00:00] [2004-04-10 01:00:00] > timeSequence(from = "2004-03-12", to = "2004-04-11", + format = "%Y-%m-%d", FinCenter = "Europe/Zurich") Warning in timeSequence(from = "2004-03-12", to = "2004-04-11", format = "%Y-%m-%d", : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = NULL, zone = FinCenter, : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [2004-03-12 00:00:00] [2004-03-13 00:00:00] [2004-03-14 00:00:00] [4] [2004-03-15 00:00:00] [2004-03-16 00:00:00] [2004-03-17 00:00:00] [7] [2004-03-18 00:00:00] [2004-03-19 00:00:00] [2004-03-20 00:00:00] [10] [2004-03-21 00:00:00] [2004-03-22 00:00:00] [2004-03-23 00:00:00] [13] [2004-03-24 00:00:00] [2004-03-25 00:00:00] [2004-03-26 00:00:00] [16] [2004-03-27 00:00:00] [2004-03-28 00:00:00] [2004-03-29 01:00:00] [19] [2004-03-30 01:00:00] [2004-03-31 01:00:00] [2004-04-01 01:00:00] [22] [2004-04-02 01:00:00] [2004-04-03 01:00:00] [2004-04-04 01:00:00] [25] [2004-04-05 01:00:00] [2004-04-06 01:00:00] [2004-04-07 01:00:00] [28] [2004-04-08 01:00:00] [2004-04-09 01:00:00] [2004-04-10 01:00:00] > > ## timeDate - > xmpBasics("\nNext: Note, ISO and American Formats are Auto-Detected > ") > timeDate("2004-12-11", FinCenter = "GMT") Warning in timeDate("2004-12-11", FinCenter = "GMT") : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [2004-12-11] > timeDate("12/11/2004", FinCenter = "GMT") Warning in timeDate("12/11/2004", FinCenter = "GMT") : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [2004-12-11] > > > > cleanEx(); ..nameEx <- "A2-TimeDateMethods" > > ### * A2-TimeDateMethods > > flush(stderr()); flush(stdout()) > > ### Name: TimeDateMethods > ### Title: timeDate Methods > ### Aliases: TimeDateMethods timeDateMethods [.timeDate +.timeDate > ### -.timeDate Ops.timeDate diff.timeDate difftimeDate c.timeDate > ### rep.timeDate start.timeDate end.timeDate modify.timeDate rev.timeDate > ### as.character.timeDate as.data.frame.timeDate as.POSIXct.timeDate > ### julian.POSIXt julian.timeDate atoms.timeDate months.timeDate > ### Keywords: chron > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fBasics.E1-TimeDateClass") > ## SOURCE("fBasics.E2-TimeDatemethods") > ## SOURCE("fBasics.Z1-BasicsTools") > > ## c - > xmpBasics("\nStart: Create Character Vectors > ") > dts = c("1989-09-28", "2001-01-15", "2004-08-30", "1990-02-09") > tms = c( "23:12:55", "10:34:02", "08:30:00", "11:18:23") > dts; tms [1] "1989-09-28" "2001-01-15" "2004-08-30" "1990-02-09" [1] "23:12:55" "10:34:02" "08:30:00" "11:18:23" > > ## "+/-" - > xmpBasics("\nStart: Add One Day to a Given timeDate Object > ") > GMT = timeDate(dts, FinCenter = "GMT") Warning in timeDate(dts, FinCenter = "GMT") : Set timezone to GMT! > ZUR = timeDate(dts, FinCenter = "Europe/Zurich") Warning in timeDate(dts, FinCenter = "Europe/Zurich") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! > GMT + 24*3600 Warning in "+.timeDate"(GMT, 24 * 3600) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e1GMT + e2, zone = "GMT", FinCenter = e1@FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-29] [2001-01-16] [2004-08-31] [1990-02-10] > ZUR[2] - ZUR[1] Warning in "[.timeDate"(ZUR, 2) : Set timezone to GMT! Warning in "[.timeDate"(ZUR, 1) : Set timezone to GMT! Warning in "-.timeDate"(ZUR[2], ZUR[1]) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Time difference of 4127 days > > ## "[" - > xmpBasics("\nNext: Subsets from and Lops for timeDate Objects > ") > GMT[GMT < GMT[2]] Warning in "[.timeDate"(GMT, GMT < GMT[2]) : Set timezone to GMT! Warning in "[.timeDate"(GMT, 2) : Set timezone to GMT! Warning in Ops.timeDate(GMT, GMT[2]) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-28] [1990-02-09] > ZUR[ZUR < ZUR[3]] == ZUR[1:3] Warning in "[.timeDate"(ZUR, ZUR < ZUR[3]) : Set timezone to GMT! Warning in "[.timeDate"(ZUR, 3) : Set timezone to GMT! Warning in Ops.timeDate(ZUR, ZUR[3]) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in "[.timeDate"(ZUR, 1:3) : Set timezone to GMT! Warning in Ops.timeDate(ZUR[ZUR < ZUR[3]], ZUR[1:3]) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! [1] TRUE TRUE FALSE > > ## diff - > xmpBasics("\nNext: Suitably Lagged and Iterated Differences > ") > diff(GMT) Warning in diff.timeDate(GMT) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Time differences of 4127.000, 1322.958, -5315.958 days > diff(GMT, lag = 2) Warning in diff.timeDate(GMT, lag = 2) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Time differences of 5449.958, -3993.000 days > diff(GMT, lag = 1, diff = 2) Warning in diff.timeDate(GMT, lag = 1, diff = 2) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Time differences of -2804.042, -6638.917 days > difftimeDate(GMT[1:2], GMT[-(1:2)]) Warning in difftimeDate(GMT[1:2], GMT[-(1:2)]) : Set timezone to GMT! Warning in timeDate(time1, zone = time1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in "[.timeDate"(GMT, 1:2) : Set timezone to GMT! Warning in timeDate(time2, zone = time2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in "[.timeDate"(GMT, -(1:2)) : Set timezone to GMT! Time differences of -5450, 3993 days > > ## c | rep - > xmpBasics("\nNext: Concatenate and Replicate timeDate Objects > ") > c(GMT[1:2], ZUR[1:2]) Warning in "[.timeDate"(GMT, 1:2) : Set timezone to GMT! Warning in c.timeDate(GMT[1:2], ZUR[1:2]) : Set timezone to GMT! Warning in "[.timeDate"(ZUR, 1:2) : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(all, zone = "GMT", FinCenter = z[[1]]@FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-28] [2001-01-15] [1989-09-28] [2001-01-15] > c(ZUR[1:2], GMT[1:2]) Warning in "[.timeDate"(ZUR, 1:2) : Set timezone to GMT! Warning in c.timeDate(ZUR[1:2], GMT[1:2]) : Set timezone to GMT! Warning in "[.timeDate"(GMT, 1:2) : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(all, zone = "GMT", FinCenter = z[[1]]@FinCenter) : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28 01:00:00] [2001-01-15 01:00:00] [1989-09-28 01:00:00] [4] [2001-01-15 01:00:00] > rep(ZUR[2], times = 3) Warning in "[.timeDate"(ZUR, 2) : Set timezone to GMT! Warning in rep.timeDate(ZUR[2], times = 3) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(lt, zone = "GMT", FinCenter = x@FinCenter) : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [2001-01-15 01:00:00] [2001-01-15 01:00:00] [2001-01-15 01:00:00] > rep(ZUR[2:3], times = 2) Warning in "[.timeDate"(ZUR, 2:3) : Set timezone to GMT! Warning in rep.timeDate(ZUR[2:3], times = 2) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(lt, zone = "GMT", FinCenter = x@FinCenter) : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [2001-01-15 01:00:00] [2004-08-30 02:00:00] [2001-01-15 01:00:00] [4] [2004-08-30 02:00:00] > > ## round | truncate - > xmpBasics("\nNext: Round and Truncate timeDate Objects > ") > modify(GMT, "round", "days") Warning in modify.timeDate(GMT, "round", "days") : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(lt, zone = "GMT", FinCenter = x@FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-28] [2001-01-15] [2004-08-30] [1990-02-09] > modify(ZUR, "round", "days") Warning in modify.timeDate(ZUR, "round", "days") : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(lt, zone = "GMT", FinCenter = x@FinCenter) : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28 01:00:00] [2001-01-15 01:00:00] [2004-08-30 02:00:00] [4] [1990-02-09 01:00:00] > modify(GMT, "trunc", "days") Warning in modify.timeDate(GMT, "trunc", "days") : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(lt, zone = "GMT", FinCenter = x@FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [1989-09-28] [2001-01-15] [2004-08-30] [1990-02-09] > modify(ZUR, "trunc", "days") Warning in modify.timeDate(ZUR, "trunc", "days") : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(lt, zone = "GMT", FinCenter = x@FinCenter) : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28 01:00:00] [2001-01-15 01:00:00] [2004-08-30 02:00:00] [4] [1990-02-09 01:00:00] > > ## start | end | sort - > xmpBasics("\nNext: Extract First/Last, Sort timeDate Objects > ") > c(start(ZUR), end(ZUR)) Warning in start.timeDate(ZUR) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in "[.timeDate"(x, 1) : Set timezone to GMT! Warning in c.timeDate(start(ZUR), end(ZUR)) : Set timezone to GMT! Warning in end.timeDate(ZUR) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in "[.timeDate"(x, n) : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in timeDate(all, zone = "GMT", FinCenter = z[[1]]@FinCenter) : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28 01:00:00] [2004-08-30 02:00:00] > modify(ZUR, "sort") Warning in modify.timeDate(ZUR, "sort") : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Warning in "[.timeDate"(x, n) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "Europe/Zurich" [1] [1989-09-28 01:00:00] [1990-02-09 01:00:00] [2001-01-15 01:00:00] [4] [2004-08-30 02:00:00] > > ## as - > xmpBasics("\nNext: Convert timeDate Objects to Other Objects > ") > as.character(ZUR) Warning in as.character.timeDate(ZUR) : Set timezone to GMT! [1] "1989-09-28 01:00:00" "2001-01-15 01:00:00" "2004-08-30 02:00:00" [4] "1990-02-09 01:00:00" > as.data.frame(ZUR) Warning in as.data.frame.timeDate(ZUR) : Set timezone to GMT! x@Data 1 1989-09-28 01:00:00 2 2001-01-15 01:00:00 3 2004-08-30 02:00:00 4 1990-02-09 01:00:00 > as.POSIXct(ZUR) Warning in as.POSIXct.timeDate(ZUR) : Set timezone to GMT! [1] "1989-09-28 01:00:00 CET" "2001-01-15 01:00:00 CET" [3] "2004-08-30 02:00:00 CEST" "1990-02-09 01:00:00 CET" > > ## julian - > xmpBasics("\nNext: Julian Time in Days Since 1970-01-01 > ") > julian(ZUR) Warning in julian.timeDate(ZUR) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Time differences of 7209.958, 11336.958, 12659.917, 7343.958 days > as.integer(julian(ZUR)) Warning in julian.timeDate(ZUR) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! [1] 7209 11336 12659 7343 > julian(ZUR, "days") Warning in julian.timeDate(ZUR, "days") : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! Time differences of 7209.958, 11336.958, 12659.917, 7343.958 days > as.integer(julian(ZUR, "days")) Warning in julian.timeDate(ZUR, "days") : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in rulesFinCenter(FinCenter) : Set timezone to GMT! [1] 7209 11336 12659 7343 > > ## atoms - > xmpBasics("\nNext: Atoms from a timeDate Object > ") > atoms(ZUR) Warning in atoms.timeDate(ZUR) : Set timezone to GMT! Y m d H M S 1 1989 9 28 1 0 0 2 2001 1 15 1 0 0 3 2004 8 30 2 0 0 4 1990 2 9 1 0 0 > atoms(ZUR)[,3] Warning in atoms.timeDate(ZUR) : Set timezone to GMT! [1] 28 15 30 9 > atoms(ZUR)[, "d"] Warning in atoms.timeDate(ZUR) : Set timezone to GMT! [1] 28 15 30 9 > > > > cleanEx(); ..nameEx <- "A3-DaylightSavingTimeRules" > > ### * A3-DaylightSavingTimeRules > > flush(stderr()); flush(stdout()) > > ### Name: DaylightSavingTimeRules > ### Title: Daylight Saving Time Rules > ### Aliases: DaylightSavingTimeRules Adelaide Algiers Amsterdam Anchorage > ### Andorra Athens Auckland Bahrain Bangkok Beirut Belfast Belgrade > ### Berlin Bogota Bratislava Brisbane Brussels Bucharest Budapest > ### BuenosAires Cairo Calcutta Caracas Casablanca Cayman Chicago > ### Copenhagen Darwin Denver Detroit Dubai Dublin Eastern Edmonton > ### Frankfurt Helsinki HongKong Honolulu Indianapolis Istanbul Jakarta > ### Jerusalem Johannesburg Kiev KualaLumpur Kuwait Lagos Lisbon Ljubljana > ### London LosAngeles Luxembourg Madrid Manila Melbourne MexicoCity > ### Monaco Montreal Moscow Nairobi Nassau NewYork Nicosia Oslo Pacific > ### Paris Perth Prague Riga Riyadh Rome Seoul Shanghai Singapore Sofia > ### Stockholm Sydney Taipei Tallinn Tehran Tokyo Tunis Vaduz Vancouver > ### Vienna Vilnius Warsaw Winnipeg Zagreb Zurich > ### Keywords: data > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fBasics.E3-DaylightSavingTimeRules") > ## SOURCE("fBasics.Z1-BasicsTools") > > ## data - > xmpBasics("\nStart: DST Rules for Zurich > ") > Zurich() Zurich offSet 1 1894-05-31 23:30:16 3600 2 1940-11-01 23:00:00 7200 3 1940-12-30 22:00:00 3600 4 1941-05-04 01:00:00 7200 5 1941-10-04 22:00:00 3600 6 1942-05-03 01:00:00 7200 7 1942-10-03 22:00:00 3600 8 1980-12-31 23:00:00 3600 9 1981-03-29 01:00:00 7200 10 1981-09-27 01:00:00 3600 11 1982-03-28 01:00:00 7200 12 1982-09-26 01:00:00 3600 13 1983-03-27 01:00:00 7200 14 1983-09-25 01:00:00 3600 15 1984-03-25 01:00:00 7200 16 1984-09-30 01:00:00 3600 17 1985-03-31 01:00:00 7200 18 1985-09-29 01:00:00 3600 19 1986-03-30 01:00:00 7200 20 1986-09-28 01:00:00 3600 21 1987-03-29 01:00:00 7200 22 1987-09-27 01:00:00 3600 23 1988-03-27 01:00:00 7200 24 1988-09-25 01:00:00 3600 25 1989-03-26 01:00:00 7200 26 1989-09-24 01:00:00 3600 27 1990-03-25 01:00:00 7200 28 1990-09-30 01:00:00 3600 29 1991-03-31 01:00:00 7200 30 1991-09-29 01:00:00 3600 31 1992-03-29 01:00:00 7200 32 1992-09-27 01:00:00 3600 33 1993-03-28 01:00:00 7200 34 1993-09-26 01:00:00 3600 35 1994-03-27 01:00:00 7200 36 1994-09-25 01:00:00 3600 37 1995-03-26 01:00:00 7200 38 1995-09-24 01:00:00 3600 39 1996-03-31 01:00:00 7200 40 1996-10-27 01:00:00 3600 41 1997-03-30 01:00:00 7200 42 1997-10-26 01:00:00 3600 43 1998-03-29 01:00:00 7200 44 1998-10-25 01:00:00 3600 45 1999-03-28 01:00:00 7200 46 1999-10-31 01:00:00 3600 47 2000-03-26 01:00:00 7200 48 2000-10-29 01:00:00 3600 49 2001-03-25 01:00:00 7200 50 2001-10-28 01:00:00 3600 51 2002-03-31 01:00:00 7200 52 2002-10-27 01:00:00 3600 53 2003-03-30 01:00:00 7200 54 2003-10-26 01:00:00 3600 55 2004-03-28 01:00:00 7200 56 2004-10-31 01:00:00 3600 57 2005-03-27 01:00:00 7200 58 2005-10-30 01:00:00 3600 59 2006-03-26 01:00:00 7200 60 2006-10-29 01:00:00 3600 61 2007-03-25 01:00:00 7200 62 2007-10-28 01:00:00 3600 63 2008-03-30 01:00:00 7200 64 2008-10-26 01:00:00 3600 65 2009-03-29 01:00:00 7200 66 2009-10-25 01:00:00 3600 67 2010-03-28 01:00:00 7200 68 2010-10-31 01:00:00 3600 69 2011-03-27 01:00:00 7200 70 2011-10-30 01:00:00 3600 71 2012-03-25 01:00:00 7200 72 2012-10-28 01:00:00 3600 73 2013-03-31 01:00:00 7200 74 2013-10-27 01:00:00 3600 75 2014-03-30 01:00:00 7200 76 2014-10-26 01:00:00 3600 77 2015-03-29 01:00:00 7200 78 2015-10-25 01:00:00 3600 79 2016-03-27 01:00:00 7200 80 2016-10-30 01:00:00 3600 81 2017-03-26 01:00:00 7200 82 2017-10-29 01:00:00 3600 83 2018-03-25 01:00:00 7200 84 2018-10-28 01:00:00 3600 85 2019-03-31 01:00:00 7200 86 2019-10-27 01:00:00 3600 87 2020-03-29 01:00:00 7200 88 2020-10-25 01:00:00 3600 89 2021-03-28 01:00:00 7200 90 2021-10-31 01:00:00 3600 91 2022-03-27 01:00:00 7200 92 2022-10-30 01:00:00 3600 93 2023-03-26 01:00:00 7200 94 2023-10-29 01:00:00 3600 95 2024-03-31 01:00:00 7200 96 2024-10-27 01:00:00 3600 97 2025-03-30 01:00:00 7200 98 2025-10-26 01:00:00 3600 99 2026-03-29 01:00:00 7200 100 2026-10-25 01:00:00 3600 101 2027-03-28 01:00:00 7200 102 2027-10-31 01:00:00 3600 103 2028-03-26 01:00:00 7200 104 2028-10-29 01:00:00 3600 105 2029-03-25 01:00:00 7200 106 2029-10-28 01:00:00 3600 107 2030-03-31 01:00:00 7200 108 2030-10-27 01:00:00 3600 > > > > cleanEx(); ..nameEx <- "B1-HolidayDates" > > ### * B1-HolidayDates > > flush(stderr()); flush(stdout()) > > ### Name: HolidayDatabase > ### Title: Holiday Calendars and Utilities > ### Aliases: HolidayDatabase Septuagesima Quinquagesima AshWednesday > ### PalmSunday GoodFriday Easter EasterSunday EasterMonday RogationSunday > ### Ascension Pentecost PentecostMonday TrinitySunday CorpusChristi > ### ChristTheKing Advent1st Advent2nd Advent3rd Advent4th ChristmasEve > ### ChristmasDay BoxingDay NewYearsDay SolemnityOfMary Epiphany > ### PresentationOfLord Annunciation TransfigurationOfLord > ### AssumptionOfMary BirthOfVirginMary CelebrationOfHolyCross > ### MassOfArchangels AllSaints AllSouls LaborDay CHBerchtoldsDay > ### CHSechselaeuten CHAscension CHConfederationDay CHKnabenschiessen > ### GBMayDay GBBankHoliday GBSummerBankHoliday GBMilleniumDay DEAscension > ### DECorpusChristi DEGermanUnity DEChristmasEve DENewYearsEve > ### FRFetDeLaVictoire1945 FRAscension FRBastilleDay > ### FRAssumptionVirginMary FRAllSaints FRArmisticeDay ITEpiphany > ### ITLiberationDay ITAssumptionOfVirginMary ITAllSaints ITStAmrose > ### ITImmaculateConception USDecorationMemorialDay USPresidentsDay > ### USNewYearsDay USInaugurationDay USMLKingsBirthday USLincolnsBirthday > ### USWashingtonsBirthday USMemorialDay USIndependenceDay USLaborDay > ### USColumbusDay USElectionDay USVeteransDay USThanksgivingDay > ### USChristmasDay USCPulaskisBirthday USGoodFriday CAVictoriaDay > ### CACanadaDay CACivicProvincialHoliday CALabourDay CAThanksgivingDay > ### CaRemembranceDay JPNewYearsDay JPGantan JPBankHolidayJan2 > ### JPBankHolidayJan3 JPComingOfAgeDay JPSeijinNoHi JPNatFoundationDay > ### JPKenkokuKinenNoHi JPGreeneryDay JPMidoriNoHi JPConstitutionDay > ### JPKenpouKinenBi JPNationHoliday JPKokuminNoKyujitu JPChildrensDay > ### JPKodomoNoHi JPMarineDay JPUmiNoHi JPRespectForTheAgedDay > ### JPKeirouNOhi JPAutumnalEquinox JPShuubunNoHi JPHealthandSportsDay > ### JPTaiikuNoHi JPNationalCultureDay JPBunkaNoHi JPThanksgivingDay > ### JPKinrouKanshaNoHi JPEmperorsBirthday JPTennouTanjyouBi > ### JPBankHolidayDec31 > ### Keywords: chron > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fBasics.C5-HolidayCalendars") > ## SOURCE("fBasics.C6-HolidayDates") > ## SOURCE("fBasics.Z1-BasicsTools") > > ## CHSechselaeuten - > # Sechselaeuten a half Day Bank Holiday in Switzerland > CHSechselaeuten(2000:2010) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2000-04-17] [2001-04-23] [2002-04-15] [2003-04-28] [2004-04-19] [6] [2005-04-18] [2006-04-24] [2007-04-16] [2008-04-21] [2009-04-20] [11] [2010-04-19] > CHSechselaeuten(currentYear) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2005-04-18] > > > > cleanEx(); ..nameEx <- "B2-HolidayCalendars" > > ### * B2-HolidayCalendars > > flush(stderr()); flush(stdout()) > > ### Name: HolidayCalendars > ### Title: Holiday Calendars and Utilities > ### Aliases: HolidayCalendars easter holiday holiday.NYSE on.or.after > ### on.or.before nth.of.nday last.of.nday sjulian sdate sday.of.week > ### sleap.year print.sdate fjulian .julian month.day.year leap.year > ### day.of.week > ### Keywords: chron > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fBasics.E5-HolidayCalendars") > ## SOURCE("fBasics.E6-HolidayDates") > ## SOURCE("fBasics.Z1-BasicsTools") > > ## easter - > xmpBasics("\nStart: Easter and Easter Related Feasts > ") > # Dates for Easter and Pentecost from 2000 until 2010: > easter(2000:2010) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2000-04-23] [2001-04-15] [2002-03-31] [2003-04-20] [2004-04-11] [6] [2005-03-27] [2006-04-16] [2007-04-08] [2008-03-23] [2009-04-12] [11] [2010-04-04] > easter(2000:2010, -2) # This is Good Friday Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2000-04-21] [2001-04-13] [2002-03-29] [2003-04-18] [2004-04-09] [6] [2005-03-25] [2006-04-14] [2007-04-06] [2008-03-21] [2009-04-10] [11] [2010-04-02] > holiday(2000:2010, Easter) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2000-04-23] [2001-04-15] [2002-03-31] [2003-04-20] [2004-04-11] [6] [2005-03-27] [2006-04-16] [2007-04-08] [2008-03-23] [2009-04-12] [11] [2010-04-04] > holiday(2000:2010, GoodFriday) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2000-04-21] [2001-04-13] [2002-03-29] [2003-04-18] [2004-04-09] [6] [2005-03-25] [2006-04-14] [2007-04-06] [2008-03-21] [2009-04-10] [11] [2010-04-02] > > ## holidays - > xmpBasics("\nNext: Alternatively You can use > ") > Easter(2000:2010) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2000-04-23] [2001-04-15] [2002-03-31] [2003-04-20] [2004-04-11] [6] [2005-03-27] [2006-04-16] [2007-04-08] [2008-03-23] [2009-04-12] [11] [2010-04-04] > GoodFriday(2000:2010) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2000-04-21] [2001-04-13] [2002-03-29] [2003-04-18] [2004-04-09] [6] [2005-03-25] [2006-04-14] [2007-04-06] [2008-03-21] [2009-04-10] [11] [2010-04-02] > > ## holiday.NYSE - > xmpBasics("\nNext: Holiday Calendar for the New York Stock Exchange > ") > holiday.NYSE(currentYear) Warning in timeDate(holidays, format = "%Y%m%d", FinCenter = "GMT") : Set timezone to GMT! Warning in as.POSIXct.timeDate(ans) : Set timezone to GMT! Warning in "+.timeDate"(ans, as.integer(as.POSIXlt(as.POSIXct(ans))$wday == : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e1GMT + e2, zone = "GMT", FinCenter = e1@FinCenter) : Set timezone to GMT! Warning in as.POSIXct.timeDate(ans) : Set timezone to GMT! Warning in timeCalendar(y = y + (m + 1)%/%13, m = m + 1 - (m + 1)%/%13 * : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = "%Y%m%d%H%M%S", zone = FinCenter, : Set timezone to GMT! Warning in "-.timeDate"(timeCalendar(y = y + (m + 1)%/%13, m = m + 1 - (m + : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e1GMT - e2, zone = "GMT", FinCenter = e1@FinCenter) : Set timezone to GMT! Warning in as.POSIXct.timeDate(timeCalendar(y = y + (m + 1)%/%13, m = m + : Set timezone to GMT! Warning in timeDate(as.character(last.of.nday(year = y, month = m, lastday = lastday, : Set timezone to GMT! Warning in timeDate("1959-07-03", format = "%Y-%m-%d", FinCenter = "GMT") : Set timezone to GMT! Warning in Ops.timeDate(ans, timeDate("1959-07-03", format = "%Y-%m-%d", : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in as.POSIXct.timeDate(ans) : Set timezone to GMT! Warning in Ops.timeDate(ans, ExceptOnLastFriday) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in "-.timeDate"(ans, as.integer(ans >= timeDate("1959-07-03", format = "%Y-%m-%d", : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e1GMT - e2, zone = "GMT", FinCenter = e1@FinCenter) : Set timezone to GMT! Warning in "[.timeDate"(ans, !(as.POSIXlt(as.POSIXct(ans))$wday == 0 | as.POSIXlt(as.POSIXct(ans))$wday == : Set timezone to GMT! Warning in as.POSIXct.timeDate(ans) : Set timezone to GMT! Warning in as.POSIXct.timeDate(ans) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "America/New_York" [1] [2005-01-17] [2005-02-21] [2005-03-25] [2005-05-30] [2005-07-04] [6] [2005-09-05] [2005-11-24] [2005-12-26] > > ## on.or.after - > xmpBasics("\nStart: on.or.after > ") > # What date had the first advent 2001? > # The first advent is the Sunday on or after November 27th. > on.or.after(year = 2001, month = 11, day = 27, nday = 0) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2001-12-02] > > ## on.or.before - > xmpBasics("\nNext: on.or.before > ") > # What date had Monday on or after April, 1st, 2001? > on.or.before(year = 2001, month = 11, day = 27, nday = 1) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [2001-11-26] > > ## nth.of.nday - > xmpBasics("\nNext: nth.of.nday > ") > # What date had the second Sunday in October 1980? > nth.of.nday(year = 1980, month = 10, nday = 0, nth = 2) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [1980-10-12] > > ## last.of.nday - > xmpBasics("\nNext: last.of.nday > ") > # What date had the last Monday in September, 2002? > last.of.nday(year = 1996, month = 9, lastday = 31, nday = 1) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "Zurich" [1] [1996-09-30] > > ## fdates - > ## fjulian - > xmpBasics("\nStart: Convert Formatted Gregorian Dates > ") > fdates = c("8/11/73", "08-11-73", "August 11 1973", "Aug11/73") > fdates [1] "8/11/73" "08-11-73" "August 11 1973" "Aug11/73" > fjulian(fdates) [1] 4971 4971 4971 4971 > > ## fdates - > ## fjulian - > xmpBasics("\nNext: Convert with 'dmy' Order > ") > fdates = c("11/8/73", "11-08-73", "11 August 1973", "11Aug73") > fjulian(fdates, order = 'dmy') [1] 4971 4971 4971 4971 > > ## .julian - > ## day.of.week - > xmpBasics("\nNext: Day of Week > ") > # The number of days from January 1, 1990 to each of: > # January 15, 1990, February 15, 1991, March 15, 1992, etc. > .julian(1:12, rep(15,12), 1990+(0:11), origin = c(1, 1, 1990)) [1] 14 410 804 1200 1595 1991 2387 2783 3179 3574 3971 4366 > # November 12, 98, was a Wednesday. > day.of.week(m = 11, d = 12, y = 98) [1] 3 > > > > cleanEx(); ..nameEx <- "C1-TimeSeriesClass" > > ### * C1-TimeSeriesClass > > flush(stderr()); flush(stdout()) > > ### Name: TimeSeriesClass > ### Title: timeSeries Class and Methods > ### Aliases: TimeSeriesClass timeSeries timeSeries-class read.timeSeries > ### as.timeSeries is.timeSeries print.timeSeries plot.timeSeries > ### lines.timeSeries Ops.timeSeries [.timeSeries head.timeSeries > ### tail.timeSeries seriesData seriesPositions start.timeSeries > ### end.timeSeries as.vector.timeSeries as.matrix.timeSeries > ### as.data.frame.timeSeries applySeries cutSeries diffSeries lagSeries > ### mergeSeries returnSeries revSeries alignDailySeries ohlcDailyPlot > ### Keywords: chron > > ### ** Examples > > ## SOURCE("fBasics.E3-TimeSeriesClass") > ## SOURCE("fBasics.Z1-BasicsTools") > > ## data - > xmpBasics("\nStart: Load Microsoft Data > ") > data(msft.dat) > myFinCenter = "GMT" > msft.dat[1:3, ] X.m..d..Y Open High Low Close Volume 1 09/27/2000 63.4375 63.5625 59.8125 60.6250 53077800 2 09/28/2000 60.8125 61.8750 60.6250 61.3125 26180200 3 09/29/2000 61.0000 61.3125 58.6250 60.3125 37026800 > > ## timeSeries - > xmpBasics("\nNext: Create a timeSeries Object > ") > close = msft.dat[, 5] > ts = timeSeries(close, as.character(msft.dat[, 1]), format = "%m/%d/%Y", + units = "MSFT", zone = "GMT", FinCenter = "GMT") Warning in timeDate(charvec = charvec, format = format, zone = zone, FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! > class(ts) [1] "timeSeries" attr(,"package") [1] "fCalendar" > ts[1:3,] Warning in "[.timeSeries"(ts, 1:3, ) : Set timezone to GMT! MSFT 2000-09-27 60.6250 2000-09-28 61.3125 2000-09-29 60.3125 > c(start(ts), end(ts)) Warning in start.timeDate(seriesPositions(x)) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in "[.timeDate"(x, 1) : Set timezone to GMT! Warning in c.timeDate(start(ts), end(ts)) : Set timezone to GMT! Warning in end.timeDate(seriesPositions(x)) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in "[.timeDate"(x, n) : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(z[[i]], zone = z[[i]]@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(all, zone = "GMT", FinCenter = z[[1]]@FinCenter) : Set timezone to GMT! Warning in print.timeDate(list()) : Set timezone to GMT! [1] "GMT" [1] [2000-09-27] [2001-09-27] > > ## cutSeries - > xmpBasics("\nNext: Cut out April Data from 2001 > ") > ts.Apr01 = cutSeries(ts, "2001-04-01", "2001-04-30") Warning in timeDate(from) : Set timezone to GMT! Warning in timeDate(to) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in Ops.timeDate(Positions, from) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in Ops.timeDate(Positions, to) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! > ts.Apr01 MSFT 2001-04-02 55.8125 2001-04-03 53.3750 2001-04-04 51.9375 2001-04-05 56.7500 2001-04-06 56.1875 2001-04-09 57.1500 2001-04-10 59.6800 2001-04-11 60.0400 2001-04-12 62.1800 2001-04-16 60.7900 2001-04-17 61.4800 2001-04-18 65.4300 2001-04-19 68.0400 2001-04-20 69.0000 2001-04-23 68.2500 2001-04-24 67.5500 2001-04-25 69.6900 2001-04-26 69.1300 2001-04-27 67.1200 2001-04-30 67.7500 > > ## returnSeries - > xmpBasics("\nNext: Compute Returns > ") > # Compute Returns: > args(returnSeries) function (x, type = c("continuous", "discrete"), percentage = FALSE, trim = TRUE, digits = 4, units = NULL) NULL > # Continuous Returns: > returnSeries(ts.Apr01) Warning in "[.timeSeries"(ans, -1, ) : Set timezone to GMT! MSFT 2001-04-03 -0.0447 2001-04-04 -0.0273 2001-04-05 0.0886 2001-04-06 -0.0100 2001-04-09 0.0170 2001-04-10 0.0433 2001-04-11 0.0060 2001-04-12 0.0350 2001-04-16 -0.0226 2001-04-17 0.0113 2001-04-18 0.0623 2001-04-19 0.0391 2001-04-20 0.0140 2001-04-23 -0.0109 2001-04-24 -0.0103 2001-04-25 0.0312 2001-04-26 -0.0081 2001-04-27 -0.0295 2001-04-30 0.0093 > # Discrete Returns: > returnSeries(ts.Apr01, type = "discrete") Warning in "[.timeSeries"(ans, -1, ) : Set timezone to GMT! MSFT 2001-04-03 -0.0437 2001-04-04 -0.0269 2001-04-05 0.0927 2001-04-06 -0.0099 2001-04-09 0.0171 2001-04-10 0.0443 2001-04-11 0.0060 2001-04-12 0.0356 2001-04-16 -0.0224 2001-04-17 0.0114 2001-04-18 0.0642 2001-04-19 0.0399 2001-04-20 0.0141 2001-04-23 -0.0109 2001-04-24 -0.0103 2001-04-25 0.0317 2001-04-26 -0.0080 2001-04-27 -0.0291 2001-04-30 0.0094 > # Don't trim: > returnSeries(ts.Apr01, trim = FALSE) MSFT 2001-04-02 NA 2001-04-03 -0.0447 2001-04-04 -0.0273 2001-04-05 0.0886 2001-04-06 -0.0100 2001-04-09 0.0170 2001-04-10 0.0433 2001-04-11 0.0060 2001-04-12 0.0350 2001-04-16 -0.0226 2001-04-17 0.0113 2001-04-18 0.0623 2001-04-19 0.0391 2001-04-20 0.0140 2001-04-23 -0.0109 2001-04-24 -0.0103 2001-04-25 0.0312 2001-04-26 -0.0081 2001-04-27 -0.0295 2001-04-30 0.0093 > # Use Percentage Values: > returnSeries(ts.Apr01, percentage = TRUE, trim = FALSE) MSFT 2001-04-02 NA 2001-04-03 -4.47 2001-04-04 -2.73 2001-04-05 8.86 2001-04-06 -1.00 2001-04-09 1.70 2001-04-10 4.33 2001-04-11 0.60 2001-04-12 3.50 2001-04-16 -2.26 2001-04-17 1.13 2001-04-18 6.23 2001-04-19 3.91 2001-04-20 1.40 2001-04-23 -1.09 2001-04-24 -1.03 2001-04-25 3.12 2001-04-26 -0.81 2001-04-27 -2.95 2001-04-30 0.93 > > ## mergeSeries - > xmpBasics("\nNext: Merge Series with Returns > ") > # Include last Day from March: > ts.APR01 = cutSeries(ts, "2001-03-29", "2001-04-30") Warning in timeDate(from) : Set timezone to GMT! Warning in timeDate(to) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in Ops.timeDate(Positions, from) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in Ops.timeDate(Positions, to) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e2, zone = e2@FinCenter, FinCenter = "GMT") : Set timezone to GMT! > ts.merged = mergeSeries(x = ts.APR01, + returnSeries(ts.APR01, trim = FALSE)@Data, units = c("MSFT", "Returns")) > ts.merged MSFT Returns 2001-03-29 55.3750 NA 2001-03-30 54.6875 -0.0125 2001-04-02 55.8125 0.0204 2001-04-03 53.3750 -0.0447 2001-04-04 51.9375 -0.0273 2001-04-05 56.7500 0.0886 2001-04-06 56.1875 -0.0100 2001-04-09 57.1500 0.0170 2001-04-10 59.6800 0.0433 2001-04-11 60.0400 0.0060 2001-04-12 62.1800 0.0350 2001-04-16 60.7900 -0.0226 2001-04-17 61.4800 0.0113 2001-04-18 65.4300 0.0623 2001-04-19 68.0400 0.0391 2001-04-20 69.0000 0.0140 2001-04-23 68.2500 -0.0109 2001-04-24 67.5500 -0.0103 2001-04-25 69.6900 0.0312 2001-04-26 69.1300 -0.0081 2001-04-27 67.1200 -0.0295 2001-04-30 67.7500 0.0093 > > ## alignDailySeries - > xmpBasics("\nNext: Align with NA > ") > args(alignDailySeries) function (x, method = c("before", "after", "interp", "fillNA"), include.weekends = FALSE, units = NULL) NULL > ts.ret = returnSeries(ts.APR01, trim = TRUE) Warning in "[.timeSeries"(ans, -1, ) : Set timezone to GMT! > GoodFriday(2001) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "GMT" [1] [2001-04-13] > EasterMonday(2001) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "GMT" [1] [2001-04-16] > alignDailySeries(ts.ret, method = "fillNA", include.weekends = FALSE) Warning in "[.timeSeries"(x, , 1) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in julian.timeDate(seriesPositions(x)) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = format, zone = zone, FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in as.POSIXct.timeDate(x) : Set timezone to GMT! MSFT 2001-03-29 02:00:00 -0.0125 2001-03-30 02:00:00 NA 2001-04-02 02:00:00 -0.0447 2001-04-03 02:00:00 -0.0273 2001-04-04 02:00:00 0.0886 2001-04-05 02:00:00 -0.0100 2001-04-06 02:00:00 NA 2001-04-09 02:00:00 0.0433 2001-04-10 02:00:00 0.0060 2001-04-11 02:00:00 0.0350 2001-04-12 02:00:00 NA 2001-04-13 02:00:00 NA 2001-04-16 02:00:00 0.0113 2001-04-17 02:00:00 0.0623 2001-04-18 02:00:00 0.0391 2001-04-19 02:00:00 0.0140 2001-04-20 02:00:00 NA 2001-04-23 02:00:00 -0.0103 2001-04-24 02:00:00 0.0312 2001-04-25 02:00:00 -0.0081 2001-04-26 02:00:00 -0.0295 2001-04-27 02:00:00 NA > alignDailySeries(ts.ret, method = "fillNA", include.weekends = TRUE) Warning in "[.timeSeries"(x, , 1) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in julian.timeDate(seriesPositions(x)) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = format, zone = zone, FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! MSFT 2001-03-29 02:00:00 -0.0125 2001-03-30 02:00:00 NA 2001-03-31 02:00:00 NA 2001-04-01 02:00:00 0.0204 2001-04-02 02:00:00 -0.0447 2001-04-03 02:00:00 -0.0273 2001-04-04 02:00:00 0.0886 2001-04-05 02:00:00 -0.0100 2001-04-06 02:00:00 NA 2001-04-07 02:00:00 NA 2001-04-08 02:00:00 0.0170 2001-04-09 02:00:00 0.0433 2001-04-10 02:00:00 0.0060 2001-04-11 02:00:00 0.0350 2001-04-12 02:00:00 NA 2001-04-13 02:00:00 NA 2001-04-14 02:00:00 NA 2001-04-15 02:00:00 -0.0226 2001-04-16 02:00:00 0.0113 2001-04-17 02:00:00 0.0623 2001-04-18 02:00:00 0.0391 2001-04-19 02:00:00 0.0140 2001-04-20 02:00:00 NA 2001-04-21 02:00:00 NA 2001-04-22 02:00:00 -0.0109 2001-04-23 02:00:00 -0.0103 2001-04-24 02:00:00 0.0312 2001-04-25 02:00:00 -0.0081 2001-04-26 02:00:00 -0.0295 2001-04-27 02:00:00 NA 2001-04-28 02:00:00 NA 2001-04-29 02:00:00 0.0093 > > ## alignDailySeries - > xmpBasics("\nNext: Interpolate > ") > ts.ret MSFT 2001-03-30 -0.0125 2001-04-02 0.0204 2001-04-03 -0.0447 2001-04-04 -0.0273 2001-04-05 0.0886 2001-04-06 -0.0100 2001-04-09 0.0170 2001-04-10 0.0433 2001-04-11 0.0060 2001-04-12 0.0350 2001-04-16 -0.0226 2001-04-17 0.0113 2001-04-18 0.0623 2001-04-19 0.0391 2001-04-20 0.0140 2001-04-23 -0.0109 2001-04-24 -0.0103 2001-04-25 0.0312 2001-04-26 -0.0081 2001-04-27 -0.0295 2001-04-30 0.0093 > alignDailySeries(ts.ret, method = "interp", include.weekend = FALSE) Warning in "[.timeSeries"(x, , 1) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in julian.timeDate(positions) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in as.character.timeDate(positions) : Set timezone to GMT! Warning in timeSequence(from = poschar[1], to = poschar[length(poschar)], : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = NULL, zone = FinCenter, : Set timezone to GMT! Warning in as.character.timeDate(charvec) : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = format, zone = zone, FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in as.POSIXct.timeDate(x) : Set timezone to GMT! MSFT 2001-03-30 -0.0125 2001-04-02 0.0204 2001-04-03 -0.0447 2001-04-04 -0.0273 2001-04-05 0.0886 2001-04-06 -0.0100 2001-04-09 0.0170 2001-04-10 0.0433 2001-04-11 0.0060 2001-04-12 0.0350 2001-04-13 0.0206 2001-04-16 -0.0226 2001-04-17 0.0113 2001-04-18 0.0623 2001-04-19 0.0391 2001-04-20 0.0140 2001-04-23 -0.0109 2001-04-24 -0.0103 2001-04-25 0.0312 2001-04-26 -0.0081 2001-04-27 -0.0295 2001-04-30 0.0093 > alignDailySeries(ts.ret, method = "interp", include.weekend = TRUE) Warning in "[.timeSeries"(x, , 1) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in julian.timeDate(positions) : Set timezone to GMT! Warning in timeDate(x, zone = x@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in as.character.timeDate(positions) : Set timezone to GMT! Warning in timeSequence(from = poschar[1], to = poschar[length(poschar)], : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = NULL, zone = FinCenter, : Set timezone to GMT! Warning in as.character.timeDate(charvec) : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = format, zone = zone, FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! MSFT 2001-03-30 -0.012500000 2001-03-31 -0.001533333 2001-04-01 0.009433333 2001-04-02 0.020400000 2001-04-03 -0.044700000 2001-04-04 -0.027300000 2001-04-05 0.088600000 2001-04-06 -0.010000000 2001-04-07 -0.001000000 2001-04-08 0.008000000 2001-04-09 0.017000000 2001-04-10 0.043300000 2001-04-11 0.006000000 2001-04-12 0.035000000 2001-04-13 0.020600000 2001-04-14 0.006200000 2001-04-15 -0.008200000 2001-04-16 -0.022600000 2001-04-17 0.011300000 2001-04-18 0.062300000 2001-04-19 0.039100000 2001-04-20 0.014000000 2001-04-21 0.005700000 2001-04-22 -0.002600000 2001-04-23 -0.010900000 2001-04-24 -0.010300000 2001-04-25 0.031200000 2001-04-26 -0.008100000 2001-04-27 -0.029500000 2001-04-28 -0.016566667 2001-04-29 -0.003633333 2001-04-30 0.009300000 > > ## applySeries - > xmpBasics("\nNext: Aggregate weekly > ") > GoodFriday(2001) Warning in timeDate(x, ...) : Set timezone to GMT! Warning in print.timeDate(timeDate(x, ...)) : Set timezone to GMT! [1] "GMT" [1] [2001-04-13] > to = timeSequence(from = "2001-04-11", length.out = 3, + by = "weeks", format = "%Y-%m-%d", FinCenter = "GMT") Warning in timeSequence(from = "2001-04-11", length.out = 3, by = "weeks", : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = NULL, zone = FinCenter, : Set timezone to GMT! > from = to - 6*24*3600 Warning in "-.timeDate"(to, 6 * 24 * 3600) : Set timezone to GMT! Warning in timeDate(e1, zone = e1@FinCenter, FinCenter = "GMT") : Set timezone to GMT! Warning in timeDate(e1GMT - e2, zone = "GMT", FinCenter = e1@FinCenter) : Set timezone to GMT! > data.frame(from, to) Warning in as.data.frame.timeDate(x[[i]], optional = TRUE) : Set timezone to GMT! Warning in as.data.frame.timeDate(x[[i]], optional = TRUE) : Set timezone to GMT! from to 1 2001-04-05 2001-04-11 2 2001-04-12 2001-04-18 3 2001-04-19 2001-04-25 > applySeries(ts.ret, from, to, FUN = sum) Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in as.POSIXct.timeDate(seriesPositions(x)) : Set timezone to GMT! Warning in as.POSIXct.timeDate(from) : Set timezone to GMT! Warning in as.POSIXct.timeDate(to) : Set timezone to GMT! Warning in timeDate(charvec = object@positions, format = object@format, : Set timezone to GMT! Warning in as.character.timeDate(to) : Set timezone to GMT! Warning in as.character.timeDate(to) : Set timezone to GMT! Warning in timeDate(charvec = charvec, format = format, zone = zone, FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! Warning in Sys.timeDate() : Set timezone to GMT! Warning in timeDate(as.character(Sys.time()), zone = "GMT", FinCenter = FinCenter) : Set timezone to GMT! MSFT 2001-04-11 0.1449 2001-04-18 0.0860 2001-04-25 0.0631 > > > > cleanEx(); ..nameEx <- "D1-HighFrequencyDataTools" > > ### * D1-HighFrequencyDataTools > > flush(stderr()); flush(stdout()) > > ### Name: HighFrequencyDataTools > ### Title: Tools for FX High Frequency Data > ### Aliases: HighFrequencyDataTools xjulian xdate xday.of.week xleap.year > ### fxdata.contributors fxdata.parser fxdata.filter fxdata.varmin xts.log > ### xts.diff xts.cut xts.interp xts.map xts.upsilon xts.dvs xts.dwh > ### Keywords: data > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fBasics.E5-HolidayCalendars") > ## SOURCE("fBasics.F1-HighFrequencyDataTools") > ## SOURCE("fBasics.Z1-BasicsTools") > > ## xjulian - > xmpBasics("\nStart: Julian Counts > ") > # Return the number of minute counts for the last day in every > # month for year 2000 beginning January 1st, 2001 at 16:00: > xjulian(c( + 20000131, 20000229, 20000331, 20000430, 20000531, 20000630, + 20000731, 20000831, 20000930, 20001031, 20001130, 20001231)*10000 + + 1600, origin = 20000101) [1] 44160 85920 130560 173760 218400 261600 306240 350880 394080 438720 [11] 481920 526560 > # This doesn't work in S-Plus, you get a sequence of NA's, > # use instead: > xjulian(c( + 200001311600, 200002291600, 200003311600, 200004301600, 200005311600, + 200006301600, 200007311600, 200008311600, 200009301600, 200010311600, + 200011301600, 200012311600), origin = 20000101) [1] 44160 85920 130560 173760 218400 261600 306240 350880 394080 438720 [11] 481920 526560 > > ## xdate - > xmpBasics("\nNext: Convert Julian Counts to Dates > ") > # Return the number of minute counts for th > # Manage Date/Time in Extended Date/Time Format, ISO-8601 > # Date: 1973-01-01 15:30 > xjulian(197301011530) [1] 6839490 > print(xdate(xjulian(197301011530)), digits = 9) [1] 197301011530 > > ## xday.of.week - > # Calculate the day of week for 1973-01-01 16:15 > xmpBasics("\nNext: Compute Day of Week > ") > xday.of.week(197301011615) [1] 1 > > ## xleap.year - > xmpBasics("\nNext: Check for Leap Years > ") > # Falls Februar 1st, 2000 16:15 in a leap year? > xleap.year(200002011615) [1] TRUE > > ## fxdata.contributors - > xmpBasics("\nStart: Filter Contributors > ") > # Print contributor list: > data(usdthb) > usdthb[1:25, ] XDATE DELAY CONTRIBUTOR BID ASK FLAG 1 199706011928 1 ANZM 24.80 25.000 0 2 199706011931 1 CBAP 24.82 25.020 0 3 199706012126 1 ANZM 24.85 25.005 0 4 199706012134 1 CBAP 24.83 25.030 0 5 199706012134 1 CBAP 24.80 25.000 0 6 199706012136 1 ANZM 24.80 25.000 0 7 199706012138 1 CBAP 24.81 25.010 0 8 199706012218 1 ANZM 24.85 25.050 0 9 199706012224 1 CBAP 24.80 25.000 0 10 199706012330 1 ANZM 24.80 25.000 0 11 199706012338 1 AIGH 24.70 24.900 0 12 199706012340 1 AIGH 24.65 24.850 0 13 199706012343 1 MBRC 24.80 25.000 0 14 199706012343 1 AIGH 24.80 24.950 0 15 199706012344 1 AIGH 24.80 24.900 0 16 199706012345 1 SIME 24.70 24.800 0 17 199706012350 2 AIGH 24.75 24.850 0 18 199706012353 1 AIGH 24.80 24.850 0 19 199706012358 1 AIGH 24.75 24.820 0 20 199706012359 1 AIGH 24.77 24.820 0 21 199706020002 1 AIGH 24.80 24.820 0 22 199706020004 1 BBLS 24.80 24.850 0 23 199706020005 2 AIGH 24.75 24.800 0 24 199706020018 1 HKBK 24.75 24.850 0 25 199706020019 1 AIGH 24.80 24.850 0 > # Create contributor list: > fxdata.contributors(usdthb, include = 5) CONTRIBUTOR COUNTS PERCENT SELECT 1 ABNP 97 3.2507 F 2 ABNS 12 0.4021 F 3 AIGH 603 20.2078 T 4 AIGN 14 0.4692 F 5 ANZM 131 4.3901 F 6 ANZS 41 1.374 F 7 ANZZ 4 0.134 F 8 AYUD 1 0.0335 F 9 BATH 17 0.5697 F 10 BBLH 33 1.1059 F 11 BBLS 45 1.508 F 12 BBLT 63 2.1113 F 13 BBNF 18 0.6032 F 14 BGFX 134 4.4906 F 15 BLBS 4 0.134 F 16 BNST 15 0.5027 F 17 BNSV 18 0.6032 F 18 BOAS 79 2.6475 F 19 BOAT 32 1.0724 F 20 BTCO 5 0.1676 F 21 CBAP 25 0.8378 F 22 CBAX 33 1.1059 F 23 CHAB 18 0.6032 F 24 CHIC 82 2.748 F 25 CTBT 51 1.7091 F 26 CTRD 40 1.3405 F 27 DBBK 18 0.6032 F 28 DBSS 7 0.2346 F 29 EMFY 162 5.429 T 30 GBNP 48 1.6086 F 31 HKBK 235 7.8753 T 32 HKSX 1 0.0335 F 33 HSBK 19 0.6367 F 34 INBT 15 0.5027 F 35 INDS 35 1.1729 F 36 MBNY 2 0.067 F 37 MBRC 169 5.6635 T 38 MLMA 8 0.2681 F 39 MTKB 1 0.0335 F 40 NTBB 4 0.134 F 41 NWBO 46 1.5416 F 42 OUBV 7 0.2346 F 43 RABS 3 0.1005 F 44 RBCI 4 0.134 F 45 SBCN 4 0.134 F 46 SBES 2 0.067 F 47 SBIC 4 0.134 F 48 SCBK 14 0.4692 F 49 SCEX 81 2.7145 F 50 SCFE 220 7.3727 T 51 SCRS 30 1.0054 F 52 SHDR 15 0.5027 F 53 SIME 3 0.1005 F 54 STTA 10 0.3351 F 55 SUMS 74 2.4799 F 56 TDBB 32 1.0724 F 57 TLBS 1 0.0335 F 58 TMBB 7 0.2346 F 59 UBRC 10 0.3351 F 60 UOBX 60 2.0107 F 61 WBCM 16 0.5362 F 62 WLDB 1 0.0335 F 63 XXXX 1 0.0335 F > > ## fxdata.parser - > xmpBasics("\nNext: Parse Records > ") > # Parse data: > # Create a contributor list and mark the first 5 market makers: > parser.table = fxdata.contributors(usdthb, include = 5) > # Parse the market makers and print the first 25 entries: > fxdata.parser(usdthb, parser.table)[1:25,] XDATE DELAY CONTRIBUTOR BID ASK FLAG 11 199706012338 1 AIGH 24.70 24.90 0 12 199706012340 1 AIGH 24.65 24.85 0 13 199706012343 1 MBRC 24.80 25.00 0 14 199706012343 1 AIGH 24.80 24.95 0 15 199706012344 1 AIGH 24.80 24.90 0 17 199706012350 2 AIGH 24.75 24.85 0 18 199706012353 1 AIGH 24.80 24.85 0 19 199706012358 1 AIGH 24.75 24.82 0 20 199706012359 1 AIGH 24.77 24.82 0 21 199706020002 1 AIGH 24.80 24.82 0 23 199706020005 2 AIGH 24.75 24.80 0 24 199706020018 1 HKBK 24.75 24.85 0 25 199706020019 1 AIGH 24.80 24.85 0 26 199706020022 1 AIGH 24.70 24.80 0 28 199706020023 1 AIGH 24.70 24.75 0 29 199706020024 1 MBRC 24.70 24.80 0 31 199706020026 1 AIGH 24.75 24.80 0 32 199706020027 1 AIGH 24.70 24.80 0 33 199706020032 1 AIGH 24.75 24.80 0 34 199706020036 1 AIGH 24.70 24.75 0 35 199706020037 2 AIGH 24.75 24.77 0 38 199706020042 1 AIGH 24.80 24.90 0 39 199706020043 1 AIGH 24.80 24.85 0 41 199706020045 1 AIGH 24.75 24.85 0 42 199706020045 1 AIGH 24.80 24.85 0 > > ## fxdata.filter - > xmpBasics("\nNext: Filter Records > ") > # Filter data and plot unfiltered data: > par(mfrow = c(2, 1)) > NumberOfRecords = length(usdthb[,1]) > NumberOfRecords [1] 2984 > plot(usdthb[,4], type = "l", + xlab = "Tick Number from Reuters THB=", + ylab = "100*log(Bid[n]/Bid[1]) Bid", + ylim = c(-20,30), main="USDTHB June 1997 unfiltered") > lines(x = c(1, NumberOfRecords), y = rep(usdthb[1, 4], 2), col = 4) > lines(-100*log(usdthb[1, 4]/usdthb[, 4])) > lines(x = c(1, NumberOfRecords), y = c(0, 0), col = 4) > # Filter the data: > usdthb = fxdata.filter(usdthb, parameter = "strong") Filtering Data Set ... Filter Parameter: D = 0.5 S = 2 A = 0.18 Q = 0.25 C = 1.3 T = 45 U = 4 V = 1e-04 W = 0.025 > # Quick And Dirty Time Scaling > Records = length(usdthb$accepted[, 4]) > scale = NumberOfRecords/Records > # Plot filtered data: > plot(x=(1:Records)*scale, y = usdthb$accepted[, 4], type = "l", + xlab = "Tick Number from Reuters THB=", + ylab = "100*log(Bid[n]/Bid[1]) Bid", + ylim = c(-20, 30), main = "USDTHB June 1997 filtered") > y = rep(usdthb$accepted[1, 4], 2) > lines(x = c(1, NumberOfRecords), y = y, col = 4) > y = -100*log(usdthb$accepted[1, 4]/usdthb$accepted[, 4]) > lines(x = (1:Records)*scale, y = y) > lines(x = c(1, NumberOfRecords), y = c(0, 0), col = 4) > > ## fxdata.varmin - > xmpBasics("\nNext: Variable Minute Records > ") > # Variable Minute Records from filter accepted Data, > # create a varmin file and print the first 25 entries: > fxdata.varmin(usdthb$accepted, digits = 5)[1:25, ] XDATE DELAY CONTRIBUTOR BID ASK FLAG 1 199706011928 0 MEAN 24.8 25 1 2 199706011931 0 MEAN 24.82 25.02 1 3 199706012126 0 MEAN 24.85 25.005 1 4 199706012134 0 MEAN 24.815 25.015 2 5 199706012136 0 MEAN 24.8 25 1 6 199706012138 0 MEAN 24.81 25.01 1 7 199706012218 0 MEAN 24.85 25.05 1 8 199706012224 0 MEAN 24.8 25 1 9 199706012330 0 MEAN 24.8 25 1 10 199706012338 0 MEAN 24.7 24.9 1 11 199706012340 0 MEAN 24.65 24.85 1 12 199706012343 0 MEAN 24.8 24.975 2 13 199706012344 0 MEAN 24.8 24.9 1 14 199706012345 0 MEAN 24.7 24.8 1 15 199706012350 0 MEAN 24.75 24.85 1 16 199706012353 0 MEAN 24.8 24.85 1 17 199706012358 0 MEAN 24.75 24.82 1 18 199706012359 0 MEAN 24.77 24.82 1 19 199706020002 0 MEAN 24.8 24.82 1 20 199706020004 0 MEAN 24.8 24.85 1 21 199706020005 0 MEAN 24.75 24.8 1 22 199706020018 0 MEAN 24.75 24.85 1 23 199706020019 0 MEAN 24.8 24.85 1 24 199706020022 0 MEAN 24.725 24.85 2 25 199706020023 0 MEAN 24.7 24.75 1 > > ## xts.log - > xmpBasics("\nStart: Log Prices of FX Data > ") > # Calculate log-prices from AUDUSD bid prices > options(digits = 10) > data(audusd) > prices = list(t = audusd[,"XDATE"], x = audusd[,"BID"]) > # Print the first 25 entries: > log.prices = xts.log(prices) > data.frame(log.prices)[1:25, ] t x 1 199710010438 -0.3200675326 2 199710010438 -0.3199298200 3 199710010440 -0.3202052642 4 199710010440 -0.3200675326 5 199710010443 -0.3200675326 6 199710010444 -0.3199298200 7 199710010451 -0.3199298200 8 199710010456 -0.3202052642 9 199710010458 -0.3200675326 10 199710010458 -0.3199298200 11 199710010458 -0.3202052642 12 199710010458 -0.3200675326 13 199710010459 -0.3199298200 14 199710010501 -0.3224115530 15 199710010502 -0.3200675326 16 199710010502 -0.3202052642 17 199710010503 -0.3202052642 18 199710010505 -0.3197921264 19 199710010505 -0.3199298200 20 199710010507 -0.3199298200 21 199710010510 -0.3199298200 22 199710010516 -0.3196544517 23 199710010516 -0.3195167960 24 199710010518 -0.3195167960 25 199710010518 -0.3195167960 > > ## xts.diff - > xmpBasics("\nNext: Returns of FX Data > ") > # Calculate one hourly AUDUSD log-returns > prices = list(t = audusd[,"XDATE"], x = audusd[,"BID"]) > # Calculate the returns and print the first 25 entries: > data.frame(xts.diff(xts.log(prices)))[1:25, ] t x 1 199710010438 0.0000000000000 2 199710010438 0.0001377125940 3 199710010440 -0.0002754441554 4 199710010440 0.0001377315614 5 199710010443 0.0000000000000 6 199710010444 0.0001377125940 7 199710010451 0.0000000000000 8 199710010456 -0.0002754441554 9 199710010458 0.0001377315614 10 199710010458 0.0001377125940 11 199710010458 -0.0002754441554 12 199710010458 0.0001377315614 13 199710010459 0.0001377125940 14 199710010501 -0.0024817329710 15 199710010502 0.0023440203769 16 199710010502 -0.0001377315614 17 199710010503 0.0000000000000 18 199710010505 0.0004131377873 19 199710010505 -0.0001376936319 20 199710010507 0.0000000000000 21 199710010510 0.0000000000000 22 199710010516 0.0002753683068 23 199710010516 0.0001376557233 24 199710010518 0.0000000000000 25 199710010518 0.0000000000000 > > ## xts.cut - > xmpBasics("\nNext: Cut out a Piece From a FX File > ") > # Retrieve the AUDUSD bid quotes for October 21, 1997, 16:00 > prices = list(t = audusd[,"XDATE"], x = audusd[,"BID"]) > # Retrieve prices and print the first 25 entries: > data.frame(xts.cut(prices, from.date = 19971021, + to.date = 19971021))[1:25,] t x 1 199710210002 0.7293 2 199710210002 0.7292 3 199710210003 0.7292 4 199710210005 0.7290 5 199710210007 0.7292 6 199710210007 0.7291 7 199710210009 0.7292 8 199710210010 0.7293 9 199710210011 0.7290 10 199710210011 0.7289 11 199710210011 0.7290 12 199710210011 0.7291 13 199710210011 0.7290 14 199710210012 0.7291 15 199710210012 0.7291 16 199710210012 0.7290 17 199710210013 0.7289 18 199710210015 0.7290 19 199710210017 0.7289 20 199710210018 0.7288 21 199710210019 0.7289 22 199710210021 0.7290 23 199710210021 0.7290 24 199710210022 0.7289 25 199710210027 0.7290 > > ## xts.interp - > xmpBasics("\nNext: Interpolate of FX Data > ") > # Interpolate AUDUSD bid prices > # on a 15 minutes time scale for October 21, 1997: > prices = list(t = audusd[,"XDATE"], x = audusd[,"BID"]) > # Interpolate the prices and print the first 25 entries: > data.frame(xts.interp(prices, deltat = 15))[1:25, ] t x 1 199710010000 0.7261 2 199710010015 0.7261 3 199710010030 0.7261 4 199710010045 0.7261 5 199710010100 0.7261 6 199710010115 0.7261 7 199710010130 0.7261 8 199710010145 0.7261 9 199710010200 0.7261 10 199710010215 0.7261 11 199710010230 0.7261 12 199710010245 0.7261 13 199710010300 0.7261 14 199710010315 0.7261 15 199710010330 0.7261 16 199710010345 0.7261 17 199710010400 0.7261 18 199710010415 0.7261 19 199710010430 0.7261 20 199710010445 0.7262 21 199710010500 0.7262 22 199710010515 0.7262 23 199710010530 0.7265 24 199710010545 0.7264 25 199710010600 0.7268 > > ## xts.map - > xmpBasics("\nNext: Create Business Time Map > ") > options(object.size = 5e8) > par(mfrow = c(2, 1)) > # Load and plot prices: > data(fdax9710) > index = list(t = fdax9710[,"XDATE"], x = fdax9710[,"FDAX"]) > # Start on Monday - end on Sunday, 3 weeks: > index = xts.cut(index, from.date=19971006, to.date=19971026) > plot(index$x, type = "l", xlab = "Prices", main = "Prices in event time") > # Create hourly upsilon time map - start on Monday - end on Sunday: > tmap = xts.map(index, mean.deltat = 60, alpha = 1.05) Warning in approx(cumvmean, 1:10080, tvals, method = "linear") : collapsing to unique 'x' values > plot(x = tmap$xmap, y = tmap$ymap, ylim = c(0, max(tmap$x)), type="l", + main = "Time Mapping") > tmap $xmap [1] 60 120 180 240 300 360 420 480 540 600 660 720 [13] 780 840 900 960 1020 1080 1140 1200 1260 1320 1380 1440 [25] 1500 1560 1620 1680 1740 1800 1860 1920 1980 2040 2100 2160 [37] 2220 2280 2340 2400 2460 2520 2580 2640 2700 2760 2820 2880 [49] 2940 3000 3060 3120 3180 3240 3300 3360 3420 3480 3540 3600 [61] 3660 3720 3780 3840 3900 3960 4020 4080 4140 4200 4260 4320 [73] 4380 4440 4500 4560 4620 4680 4740 4800 4860 4920 4980 5040 [85] 5100 5160 5220 5280 5340 5400 5460 5520 5580 5640 5700 5760 [97] 5820 5880 5940 6000 6060 6120 6180 6240 6300 6360 6420 6480 [109] 6540 6600 6660 6720 6780 6840 6900 6960 7020 7080 7140 7200 [121] 7260 7320 7380 7440 7500 7560 7620 7680 7740 7800 7860 7920 [133] 7980 8040 8100 8160 8220 8280 8340 8400 8460 8520 8580 8640 [145] 8700 8760 8820 8880 8940 9000 9060 9120 9180 9240 9300 9360 [157] 9420 9480 9540 9600 9660 9720 9780 9840 9900 9960 10020 10080 $ymap [1] 518 526 539 554 570 590 605 621 638 659 682 704 731 754 779 [16] 799 821 848 872 891 917 937 955 968 986 1004 1957 1964 1982 2004 [31] 2025 2041 2056 2073 2092 2116 2141 2170 2199 2222 2244 2267 2287 2308 2325 [46] 2342 2359 2378 2396 2412 2428 2442 2927 3399 3405 3422 3440 3462 3488 3511 [61] 3534 3551 3576 3593 3617 3637 3659 3676 3701 3718 3735 3753 3768 3785 3800 [76] 3816 3829 3841 3848 3858 3869 3881 3893 4837 4847 4858 4865 4875 4890 4903 [91] 4918 4935 4952 4965 4982 4996 5012 5028 5046 5061 5075 5089 5108 5121 5131 [106] 5135 5144 5157 5170 5180 5191 5196 5207 5215 5227 5237 5243 5250 5258 5268 [121] 5279 5286 5295 5304 5314 5324 5335 6278 6279 6280 6284 6297 6306 6322 6341 [136] 6356 6371 6384 6401 6416 6439 6459 6479 6495 6513 6535 6561 6577 6595 6613 [151] 6630 6632 6638 6644 6651 6657 6666 6676 6684 6696 6704 6715 6723 6731 6740 [166] 6753 6766 8430 > > ## xts.upsilon - > xmpBasics("\nNext: De-seasonalize in Upsilon Time > ") > index = list(t = fdax9710[,"XDATE"], x = fdax9710[,"FDAX"]) > # Start on Monday - end on Sunday, 3 weeks: > index = xts.cut(index, from.date = 19971006, to.date = 19971026) > plot(index$x, type = "l", xlab = "Prices", main = "Prices in event time") > # Create hourly upsilon time map - start on Monday - end on Sunday: > tmap = xts.map(index, mean.deltat = 60, alpha = 1.05) Warning in approx(cumvmean, 1:10080, tvals, method = "linear") : collapsing to unique 'x' values > # Extract data records according to time map: > index.ups = xts.upsilon(index, weekly.map = tmap$ymap, + main="Prices in Upsilon time") > > ## xts.dvs - > xmpBasics("\nNext: De-volatilize Time Series > ") > index = list(t=fdax9710[,"XDATE"], x=fdax9710[,"FDAX"]) > # Start on Monday - end on Sunday, 3 weeks: > index = xts.cut(index, from.date=19971006, to.date=19971026) > plot(index$x, type = "l", ylab = "Prices", main = "Prices in event time") > # Devolatilize Time Series With dv-Series Algorithm: > index.dvs = xts.dvs(index, k = 8, + volatility = 13.15*var(diff(log(index$x))), main = "Prices from dv-series") > > ## Not run: > ##D ## xts.dws - > ##D xmpBasics("\nNext: Plot daily/weekly Charts > ") > ##D # NOTE: > ##D # The file this-is-escaped-code{ is too large and therefore not part > ##D # of this distribution. Please contact \emph{inf@rmetrics.org}. > ##D data(fdax97m) > ##D xts = list(t = fdax97m[,"XDATE"], x = fdax97m[,"FDAX"]) > ##D # Start on Monday - end on Sunday, 3 weeks: > ##D xts = xts.cut(index, from.date = 19970106, to.date = 19971228) > ##D # Create Daily and Weekly Histograms: > ##D result = xts.dwh (xts, period = "both", dolog = TRUE, > ##D dodiff = TRUE, deltat = 30, doplot = TRUE) > ## End(Not run) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "X1-CalendarData" > > ### * X1-CalendarData > > flush(stderr()); flush(stdout()) > > ### Name: CalendarData > ### Title: fCalendar Data Sets > ### Aliases: CalendarData timezones.db > ### Keywords: datasets > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fCalendar.Z1-CalendarTools") > > > > cleanEx(); ..nameEx <- "Z1-CalendarTools" > > ### * Z1-CalendarTools > > flush(stderr()); flush(stdout()) > > ### Name: CalendarTools > ### Title: fCalendar Tools > ### Aliases: CalendarTools myFinCenter myUnits currentYear xmpCalendar > ### xmpfCalendar modify modify.default atoms atoms.default > ### Keywords: programming > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fCalendar.Z1-CalendarTools") > > ## myFinCenter - > myFinCenter [1] "Zurich" > > ## currentYear - > currentYear [1] 2005 > > ## date - > date() [1] "Wed Jul 13 14:05:35 2005" > > > > cleanEx(); ..nameEx <- "Z2-FunctionAddon" > > ### * Z2-FunctionAddon > > flush(stderr()); flush(stdout()) > > ### Name: FunctionAddon > ### Title: Demo Function Addon > ### Aliases: FunctionAddon > ### Keywords: programming > > ### ** Examples > > ## SOURCE("fBasics.A0-SPlusCompatibility") > ## SOURCE("fCalendar.Z1-BasicsTools") > > ## funBasics - > # The examples can be found in > # the demo file "funBasics". > > > > ### *