[R-SIG-Finance] subset section of trading day from RBloomberg bar download

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Thu Jul 25 20:54:20 CEST 2013



On Jul 25, 2013, at 14:40, Tim Meggs <twmeggs at gmail.com> wrote:

> Hi R finance people,
> 
> I have downloaded some 15-min price Bar data across a number of days from
> Bloomberg for the March13 FTSE futures. 
> 
> library(Rbbg)
> conn <- blpConnect()
> ftse <- "Z H3 Index"
> ftse_Bars <- bar(conn, ftse, "TRADE", "2013-01-04 07:00:00.000", "2013-02-01
> 20:00:00.000", "15")
> ftse_Bars<-as.xts(ftse_Bars)
> blpDisconnect(conn)
> 
> The data looks like this:
> 
>                                           time   open   high    low  close
> numEvents volume
> 2013-01-10T01:00:00.000 2013-01-10T01:00:00.000 6050.5 6050.5 6047.0 6048.0       
> 12     12
> 2013-01-10T01:15:00.000 2013-01-10T01:15:00.000 6046.5 6047.5 6046.5 6047.5        
> 2      2
> 2013-01-10T01:30:00.000 2013-01-10T01:30:00.000 6046.5 6046.5 6044.5 6045.0       
> 12     21
> 2013-01-10T01:45:00.000 2013-01-10T01:45:00.000 6044.5 6045.5 6044.5 6045.5        
> 6      9
> 2013-01-10T02:00:00.000 2013-01-10T02:00:00.000 6045.5 6049.0 6045.5 6047.5       
> 11     13
> 2013-01-10T02:15:00.000 2013-01-10T02:15:00.000 6053.0 6059.0 6049.0 6058.0       
> 37     68
> 
> I would like to remove those bars that fall outside the hours 07:00 UTC to
> 15:30 UTC, to leave me with data just from the hours when the cash index is
> open.  Given the time column I receive from Bloomberg is in the slightly odd
> format format "%Y-%m-%dT%H:%M:%S" with the strange "T" in the middle how can
> subset out my desired data?

Assuming the as.xts call went properly, I believe you can just use the time-period form of ISO8601 subsetting. I'm not in a position to test, but I think it's 

CC['07:00/15:30']

There might be a T in there. Check ?"[.xts" and ?xts for details. 

Note that I'm assuming you got the as.xts call to work properly. If Bloomberg does put in that T, I'd have thought you'd need to pass an explicit format string. 

Michael

> 
> Any help greatly appreciated.
> 
> Thanks
> Tim
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/subset-section-of-trading-day-from-RBloomberg-bar-download-tp4672338.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
> 
> _______________________________________________
> 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.



More information about the R-SIG-Finance mailing list