[R-SIG-Finance] Determine the number of trading days for XETRA or EUREX in a given period

Enrico Schumann enricoschumann at yahoo.de
Mon Jan 2 17:55:27 CET 2012


Hi Joachim,

I don't think you need much experience with R to count the days; but it 
may take some work to tabulate the holidays.

You could do something like this:

start <- as.Date("2012-01-01")
end <- as.Date("2012-12-31")

## define a list of holidays
holidays <- as.Date(c("2012-01-01","2012-12-25"))

## create date sequence
allDates <- seq(start, end, by = "day")

## remove weekends
dayofweek <- as.POSIXlt(allDates)$wday
isweekend <- dayofweek==0L | dayofweek==6L
allDates <- allDates[!isweekend]

## delete holidays
allDates <- allDates[-match(holidays, allDates, nomatch = 0L)]

## count (including 'start' and 'end')
length(allDates)


Quite a lot of this seems already implemented in package RQuantLib. I 
say 'seems' because I do not use these functions, so I cannot guarantee 
that the package gives you what you need. Try this:


require("RQuantLib")
allDates <- seq(start, end, by = "day")
istradingday <- !isHoliday("Germany/Eurex", allDates)
length(allDates[istradingday])

## or ...
businessDaysBetween(calendar = "Germany/Eurex",
                     from = start,
                     to = end,
                     includeFirst = 1, includeLast = 1)

Regards,
Enrico


-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net/

Am 02.01.2012 09:08, schrieb Joachim Breit:
> Mark, I was hoping that somebody else had done that job already... :-)
> After all, I should not be the only person interested in the problem.
> Besides, function holidayNYSE looks intimidating for an R newbie.
>
> Regards,
> Joachim
>
> Am 31.12.2011 10:37, schrieb Mark Breman:
>> Hello Joachim,
>>
>> Why not create a holidayEUREX yourself? Look at holidayNYSE for an
>> example and it should not be too difficult.
>>
>> Regards,
>>
>> -Mark-
>>
>>
>> 2011/12/30 Joachim Breit <jbreit at nexgo.de <mailto:jbreit at nexgo.de>>
>>
>> Hello,
>>
>> say you want to determine the number of trading days for DAX options
>> on EUREX from now til day x.
>>
>> I am looking for a function for this task.
>>
>> Looked in package timeDate but found nothing for the german exchanges.
>>
>> Can somebody help, please?
>>
>> Joachim
>>
>> _________________________________________________
>> R-SIG-Finance at r-project.org <mailto:R-SIG-Finance at r-project.org>
>> mailing list
>> https://stat.ethz.ch/mailman/__listinfo/r-sig-finance
>> <https://stat.ethz.ch/mailman/listinfo/r-sig-finance>
>> -- 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.
>>
>>
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- 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.
>

-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net/



More information about the R-SIG-Finance mailing list