Skip to content

Pulling minute bar data with bar() function in Rbbg(RBloomberg) package in R

1 message · David Reiner

#
Sorry for the late reply - I was out for a few days.
(It's generally better to go to the list so you have more chances of getting a reply.)

I follow the last example under ?merge.xts to align my incomplete series:
just generate a sequence of date-times you want and merge the zero-width xts object with your other xts object.
You'll get NA's where there's no data, and you can leave them or use locf from zoo.
HTH,
-- David


-----Original Message-----
From: Alex Bennett [mailto:ppminers11 at yahoo.com] 
Sent: Wednesday, August 14, 2013 4:04 PM
To: David Reiner
Subject: Re: [SPAM] - [R-SIG-Finance] Pulling minute bar data with bar() function in Rbbg(RBloomberg) package in R - Email found in subject

Hi David,

Thank you so much for the help - this worked perfectly! 

Using the "isBizday()" function at the start of the for loop circumvents the 4th and stops the error I was getting. 

One more quick question regarding this: Right now the code only returns lines from minutes there was volume moved, and I am wondering if it is possible to add something (either code or a parameter) that will cause the bar() function to return a line for every minute instead of just minutes in which there were trades. For example, for a liquid name, like SPY, there will be 390 lines (one for every minute since there is volume moving every minute); however, for more illiquid names there could only be 100 lines returned because there are several minutes with no volume.  What I would like is for there to always be 390 lines returned, and, in the event there was no volume moved, have a zero on the line corresponding to those minutes. This would cause the "use" data frame to have 390*n rows. 

Ultimately I would like a column with a number, 1-390, corresponding to each minute bar for a given day, and I cannot think of a way to efficiently add this column without having 390 rows per day from the start. 

Does this make sense? Do you have any insights as to how to achieve this goal? 

Thanks for your help!

Best, 
Alex Bennett
On Aug 14, 2013, at 10:38 AM, David Reiner <David.Reiner at xrtrading.com> wrote: