-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getMultipleTicks(..., returnAs="xts") is broken #76
Comments
can we do this on the c++ side. I have some code around for this type of thing. |
Awesome sauce! Below is a recent snippet going straight to the c++ side. Also note the R> res <- Rblpapi:::getTicks_Impl(con, "ES1 Index", c("TRADE", "BID", "ASK"), "2015-09-30 15:00:00", "2015-09-30 15:00:10", TRUE)
Sending Request: IntradayTickRequest = { security = "ES1 Index" eventTypes[] = { TRADE BID ASK } startDateTime = 2015-09-30 endDateTime = 2015-09-30 }
Processing Response
Response contains 46 items
Time Type Value Size Condition Code
9/30/2015 0:0 BID 1875.500000 30
9/30/2015 0:0 BID 1875.500000 29
9/30/2015 0:0 BID 1875.500000 30
9/30/2015 0:0 BID 1875.500000 31
9/30/2015 0:0 ASK 1875.750000 14
9/30/2015 0:0 BID 1875.500000 32
9/30/2015 0:0 BID 1875.500000 34
9/30/2015 0:0 BID 1875.500000 32 |
huh? |
That is the data we get. I also split this into vectors which I then merge but that merge assumes unique timestamps. Also in the example above timestamps miss the 'T' required: 2015-09-30T15:00:00, not '2015-09 30 15:00:00'. |
So what were you thinking of @armstrtw ? |
if you have something working, that's great. I haven't even looked at that function yet. I don't know what you ended up doing on c++ side, but I historically have just used some stl stuff to merge and cbind. |
If you re-read the tread, and look at the two (short) files involved, things should become clearer. And I did not say or mean to imply that I have something working. I demonstrated what get from Bbg: a mix of rows. |
It's month end. I'll follow up on this tomorrow. |
How about this: # data for reproducible example
set.seed(21)
N <- 40
eventType <- c("BID","ASK","TRADE")
res <- data.frame(
time=.POSIXct(rep(0:1,each=N/2), tz="UTC"),
type=sample(eventType, N, TRUE, c(40,40,20)),
value=runif(N, 21, 22), size=sample(N)*100)
# end
## Make timestamps unique
res$time <- make.index.unique(res$time, eps=1e-5)
## Subset into blocks for each event type, creating xts
rl <- lapply(eventType,
function(s) {
x <- subset(res, res$type==s)
colnames(x)[3] <- tolower(s)
colnames(x)[4] <- paste0(tolower(s), "sz")
xts::xts(x[,3:4], order.by=x[,1])
})
x <- do.call(merge, rl)
options(digits.secs=6) # make unique index values visible |
I thought about uniquefying the timestamps too. But I am afraid that we may have more than 1e5 at the same time stamps. Also, maybe we should |
The suggestion works -- I added two lines to make column unique as you suggested, and later trunc() the time back down. That should do it. More testing tomorrow. |
We rely on xts to merge the bid, ask, trade, ... vectors but the timestamps are not unique. So the merged xts is not valid.
The text was updated successfully, but these errors were encountered: