[R-SIG-Finance] Retrieving Historical Intraday Data withRBloomberg

davidr at rhotrading.com davidr at rhotrading.com
Tue Feb 9 15:54:23 CET 2010


OK, I got the new version from R-forge and it does say to use blp() now.
Still needs a little work since ?blp gives me no help.
I ran your AUD example and got the same answer AND ALSO A WARNING about my time zone:
Warning message:
In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'CST'

That may explain why my result is a little funky. If you got this warning, too,
you might try setting your timezone.
(Unfortunately, the last time I changed my environment to make this work,
it broke some production stuff so I better not mess with it right now.)

-- David


-----Original Message-----
From: r-sig-finance-bounces at stat.math.ethz.ch [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Kanin Kaninski
Sent: Monday, February 08, 2010 5:22 PM
To: r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] Retrieving Historical Intraday Data withRBloomberg

Sarbo, thank you for your answer. 

1) You don't really need to include "LAST_PRICE" as the argument for "barfields". Actually, you don't really need to specify anything there at all.

If I don't specify anything, i.e. if I just write:

> AUD2 <- blp(conn, "AUD Curncy", fields = "LAST_PRICE", start ="2009-12-15 00:00", end = "2010-01-18 23:59", barsize=5, retval="zoo")
> head(AUD2)

I will receive the following, which contains more information than I wanted, but actually not the "close bar" (the close bar column contains N/A - another strange thing...):

                    LAST_PRICE.OPEN LAST_PRICE.HIGH LAST_PRICE.LOW LAST_PRICE.LAST_TRADE LAST_PRICE.NUMBER_TICKS LAST_PRICE.VOLUME
2009-12-14 23:00:00        0.915705        0.915705       0.915400                    NA                    1127                 0
2009-12-15 00:05:00        0.915450        0.916075       0.915450                    NA                    1183                 0
2009-12-15 00:10:00        0.916005        0.916185       0.915998                    NA                     746                 0
2009-12-15 00:15:00        0.916160        0.916530       0.916000                    NA                    1230                 0
2009-12-15 00:20:00        0.916200        0.916307       0.916135                    NA                    1021                 0
2009-12-15 00:25:00        0.916188        0.916350       0.916095                 NA                    1271                 0

2) It's probably because there was no data available for 2009-12-15
00:00. You're looking at 5-minute intervals of data. My guess is that
either Bloomberg's servers didn't record the data between 2009-12-14
23:00 and 2009-12-15 00:00. It's not that big a deal unless you're actually planning to trade using that data.
No there is data there, and I am pretty sure the data is correct but the time stamp received is displaced by one hour for some reason:

> head(AUD)
                        LAST
2009-12-14 23:00:00 0.915447
2009-12-15 00:05:00 0.916005
2009-12-15 00:10:00 0.916167
2009-12-15 00:15:00 0.916200
2009-12-15 00:20:00 0.916188
2009-12-15 00:25:00 0.916265

>
AUD_lag <- blp(conn, "AUD Curncy", fields = "LAST_PRICE", start
="2009-12-14 00:00", end = "2010-01-18 23:59", barsize=5, barfields= "
LAST_PRICE", retval="zoo")
> AUD_lag <- as.xts(AUD_lag)

> AUD_lag["2009-12-15 00:00:00"]
           LAST_PRICE. LAST_PRICE
2009-12-15               0.915447

> AUD_lag["2009-12-14 23:00:00"]
                    LAST_PRICE. LAST_PRICE
2009-12-14 23:00:00               0.915585

So I could probably force the change of time stamp to 2009-12-15 00:00:00 but that would be the same as assuming that there is a bug in RBloomberg. Given that this should be such a basic function, I would be surprised if this was a bug. It is more probable this is a config issue. But as a total newbie I struggle to see from where this comes.

You'd probably be better off using the blpGetData function instead. It's
a wrapper function and more generic to boot.
Running blpGetData() I receive the following:
> blpGetData is deprecated, please update your code to call blp() instead. blpGetData will be removed in an upcoming version of RBloomberg.
So my understanding is the blp() is what shoudl be used. The package used is 'http://R-forge.R-project.org/bin/windows/contrib/2.10/RBloomberg_0.2-2.zip'

===============
David, I agree the space is a strange error. Look at the two outputs belows:

# This is with space:

> AUD <- blp(conn, "AUD Curncy", fields = "LAST_PRICE", start ="2009-12-15 00:00", end = "2010-01-18 23:59", barsize=5, barfields= " LAST_PRICE", retval="zoo")
> head(AUD)
                    LAST_PRICE. LAST_PRICE
2009-12-14 23:00:00               0.915447
2009-12-15 00:05:00               0.916005
2009-12-15 00:10:00               0.916167
2009-12-15 00:15:00               0.916200
2009-12-15 00:20:00               0.916188
2009-12-15 00:25:00               0.916265

# Now if I try without the space:

> AUD <- blp(conn, "AUD Curncy", fields = "LAST_PRICE", start ="2009-12-15 00:00", end = "2010-01-18 23:59", barsize=5, barfields= "LAST_PRICE", retval="zoo")
Error in blp(conn, "AUD Curncy", fields = "LAST_PRICE", start = "2009-12-15 00:00",  : 
  barfields must be one or more of  OPEN, HIGH, LOW, LAST_PRICE, VOLUME, NUMBER_TICKS


=======================
Any help appreciated! Thanks in advance.










      
	[[alternative HTML version deleted]]



This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws.  Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.
 
THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND.  TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.



More information about the R-SIG-Finance mailing list