For very large data pulls with Bloomberg, I found it easier to pull into
excel and then use read.table to get into R.   Like Dirk said, for some
reason, Bloomberg does not like it when are greedy with data pulls.
I pulled fundamental data across the Russell 3000 for a long time period
into excel and then loaded into xts.  It was easier to check if the data was
all there visually, then push into R.

I used this code to create the xts objects from the flat files.

f.import_data <- function(datamatrixfile) {
#11/01/08
jj.holder <- read.table(datamatrixfile, header = TRUE, row.names = 1, sep =
'\t')
xts.datamatrix <- xts(jj.holder, as.Date(rownames(jj.holder), format =
'%m/%d/%Y'))
return(xts.datamatrix)
}

HTH


On Mon, Jan 19, 2009 at 11:04 AM, Dirk Eddelbuettel <edd@debian.org> wrote:

>
> On 19 January 2009 at 17:24, Sergey Goriatchev wrote:
> | Hello everyone,
> |
> | I have two issues that I want to ask.
> |
> | 1)
> | I have problems with loading data with RBloomberg.
> | More precisely, I do not seem to be able to load data into a data.frame.
> | I get an error message:
> |
> | start.date    <- as.chron("1990-01-19")
> | end.date      <- as.chron("2009-01-19")
> |
> | conn <- blpConnect(show.days="week", na.action="na", periodicity="daily")
> |
> | > bldata <- blpGetData(conn, c("ED4 Comdty", "ED12 Comdty"), "PX_LAST",
> start=start.date, end=end.date, retval="data.frame")
> | Error in if (typ[n] == "character") { : argument is of length zero
> |
> | What does that error message mean and what can I do to avoid this error
> message?
>
> Your problem is not really in the assignment to bldata. Your problme is
> indicated by the 'argument is of length zero': you didn't get any data from
> Bloomberg.  You need to fix that first.  As a first guess, try a less
> 'greedy' retrieval.  You are unlikely to get 20 years of daily data in one
> request.
>
> | 2)
> | If I load data from Bloomberg in matrix format, the date is converted
> | to a number. For example:
> |
> | > bldata <- blpGetData(conn, "ED4 Comdty", "PX_LAST", start=start.date,
> end=end.date, retval="matrix")
> | > head(bldata)
> |      [DATETIME] PX_LAST
> | [1,]      32892   91.36
> | [2,]      32895   91.37
> | [3,]      32896   91.38
> | [4,]      32897   91.38
> | [5,]      32898   91.34
> | [6,]      32899   91.28
> |
> | I tried to convert the number to normal date and by trial and error I
> | found the following:
> |
> | > as.Date(32892, "1899-12-30")
> | [1] "1990-01-19"
> |
> | Is it really true that count starts from December 30th 1899? Why?
>
> Different offsets for 'the first known day' between different applications
> and systems, eg Excel uses something very different from Unix etc.
>
> Try return type 'zoo' instead of matrix -- zoo is a class that knows how to
> deal with dates.  You may need to run    install.packages("zoo")   first.
>
> Hope this helps, Dirk
>
> --
> Three out of two people have difficulties with fractions.
>
> _______________________________________________
> R-SIG-Finance@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



-- 
Michael Sankowski, CFA, CAIA
312.404.8717
michael.sankowski@gmail.com

	[[alternative HTML version deleted]]

