Dear all,  

I have come across the issue and I hope you will be able to help me.

I have minute data and unfortunately it has weekends in it and unfortunately 
the values on weekend are not 0s and not NAs, but rather last trading price of 
friday. I want to cut the ranges out as it slows down strategy testing.

Say we have xts object with timeDate index
temp <- xts(1:84, timeCalendar(m=1, d=rep(1:7,each=12),h = seq(0,23,2)))


I want to cut rows from friday 20:00 to sunday 20:00.
I started writing function, but it just does not seem right…

filtertime <- function(x, rwd <- "5/2", rt <- "0800/1400"){
    is.within   <- function(x){
        value   <- hour(x)*60+minute(x)
        (value > range[1] && value < range[2])}
    rwd     <- as.numeric(strsplit(rwd,"/")[[1]])
    rt      <- as.numeric(strsplit(rt,"/")[[1]])
    rt      <- (rt%/%100)*60+(rt%%100)
    time    <- index(x)
    if(rwd[1]>rwd[2]){ wsq <- c((rwd[1]:7), (1:rwd[2]))
    }else{wsq <- rwd[1]:rwd[2]}
    wweek   <- sapply(time, function(x){x[all(dayOfWeek(x) != wsq)]})
    wweek   <- x[all(dayOfWeek(x) != wsq)]

}
I am not looking for help on this function, I hope someone could suggest some 
efficient way to solve my problem as I am working on 1 year 1minute data.
Thank you in advance.

Kind regards,--  
Dominykas Grigonis


        [[alternative HTML version deleted]]

_______________________________________________
[email protected] 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.

Reply via email to