Skip to content

RBloomberg/RJava Issue

1 message · Benjamin, Michael

#
Hello

I have upgraded my Bloomberg.  Although my Bloomberg worked with the COM connection, now when I execute 
require(RBloomberg)
require(rJava)
conn <- blpConnect() # or "conn <- blpConnect(blpapi.jar.file="C:\\Program Files\\blp\\API\\blpapi3.jar")"

I get an error message

conn <- blpConnect()
R version 2.14.0 (2011-10-31) 
rJava Version 0.9-2 
RBloomberg Version 0.4-150 
Java environment initialized successfully.
Looking for most recent blpapi3.jar file...
Adding C:\blp\API\blpapi3.jar to Java classpath
Error in .jnew("org/findata/blpwrapper/Connection", java.log.level) : 
  java.lang.NoClassDefFoundError: com/bloomberglp/blpapi/SessionOptions


My session info is
R version 2.14.0 (2011-10-31)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] grDevices datasets  stats     utils     graphics  methods   base     

other attached packages:
[1] RBloomberg_0.4-150           rJava_0.9-2                  RDCOMClient_0.92-0.1                     
[6]          

loaded via a namespace (and not attached):
[1]


Do you know what I need to do to overcome this issue to get the calls


ticker <- "AGS BB Equity"
start.time <- "2011-09-12 08:00:00.000"
end.time <- "2011-09-12 16:30:00.000"
trades.1 <- bar(conn, ticker, "TRADE", start.time, end.time, "1")

to work?

Regards

Michael


-----Original Message-----
From: r-sig-finance-bounces at r-project.org [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of r-sig-finance-request at r-project.org
Sent: 02 December 2011 11:00
To: r-sig-finance at r-project.org
Subject: R-SIG-Finance Digest, Vol 91, Issue 2

Send R-SIG-Finance mailing list submissions to
	r-sig-finance at r-project.org

To subscribe or unsubscribe via the World Wide Web, visit
	https://stat.ethz.ch/mailman/listinfo/r-sig-finance
or, via email, send a message with subject or body 'help' to
	r-sig-finance-request at r-project.org

You can reach the person managing the list at
	r-sig-finance-owner at r-project.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-SIG-Finance digest..."


Today's Topics:

   1. Re: HELP: Problem with RBloomberg blp intraday data (John Laing)
   2. Re: PerformanceAnalytics - Sharpes Style Analysis- but with
      intercept? (Philipp)
   3. Constrained Regression with Intercept in pcls (Philipp)
   4. Re: Constrained Regression with Intercept in pcls
      (Enrico Schumann)
   5. Re: Constrained Regression with Intercept in pcls
      (thomas.chan.sf at boci-pru.com.hk)


----------------------------------------------------------------------

Message: 1
Date: Thu, 1 Dec 2011 07:58:23 -0500
From: John Laing <john.laing at gmail.com>
To: "Benjamin, Michael" <Michael.Benjamin at bernstein.com>
Cc: r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] HELP: Problem with RBloomberg blp
	intraday data
Message-ID:
	<CAA3Wa=tSoMCzVnZdCy5P970-8dFgXp=VMV2mp=hDcYqN_vELbw at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Michael,

This works in the current version of RBloomberg:

#############################################################
require(RBloomberg)
conn <- blpConnect()

ticker <- "AGS BB Equity"
start.time <- "2011-09-12 08:00:00.000"
end.time <- "2011-09-12 16:30:00.000"

trades.1 <- bar(conn, ticker, "TRADE", start.time, end.time, "1")
trades.510 <- bar(conn, ticker, "TRADE", start.time, end.time, "510")
sum(trades.1$numEvents) == sum(trades.510$numEvents) ## TRUE

bids.1 <- bar(conn, ticker, "BID", start.time, end.time, "1")
bids.510 <- bar(conn, ticker, "BID", start.time, end.time, "510")
sum(bids.1$numEvents) == sum(bids.510$numEvents) ## TRUE

asks.1 <- bar(conn, ticker, "ASK", start.time, end.time, "1")
asks.510 <- bar(conn, ticker, "ASK", start.time, end.time, "510")
sum(asks.1$numEvents) == sum(asks.510$numEvents) ## TRUE
#############################################################

If there are still problems or unexpected NAs after you upgrade, I'd
be happy to help.

Thanks,
John

On Tue, Nov 29, 2011 at 7:11 AM, Benjamin, Michael
<Michael.Benjamin at bernstein.com> wrote:
------------------------------

Message: 2
Date: Thu, 1 Dec 2011 08:04:21 -0800 (PST)
From: Philipp <jasonhome at freenet.de>
To: r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] PerformanceAnalytics - Sharpes Style
	Analysis- but with intercept?
Message-ID: <1322755461301-4129124.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Thanks for the commented Function. So i can understand a little bit more
about it. 

In fact I want to run following constrained Regression. R.f=w0 +
w1*Rs_1+w2*Rs_2+w3*Rs_3 
with the constraints: (1) w1+w2+w3 =1 (2) w1,w2,w3>0. So the Intercept(w0)
is not included in the Constraints. In my case, R.f is a country return,
which I regress on an intercept and Industryreturnbenchmarks. The purpose is
to find a quantity of how well the Industries can explain a country-index.
(Which will be done by Rsquared, The question why an intercept is integrated
(That has been done in some papers, considering this topic), I can not
explain.Maybe because of a better fit). 

If I would consider an intercept I have to fix the Calculation of D and d in
the code of style.QPfit. The purpose is to minimize Var(R.fund-sum[w_i*Rs_i
+w0]). Then I get Var(R.f)(=0)+Var(wiRs_i+w0)-2Cov(Rfund, Rstyle+w0). So in
the Calculation of D and d I get D (=Dmat)=Cov(Rstyle+w0); d=Cov(R.fund,
Rstyle+w0). So my Problem is now to find the right function to minimize
under estimating w, without changing the constraints. 

Thanks,

Best regards

Philipp

--
View this message in context: http://r.789695.n4.nabble.com/PerformanceAnalytics-Sharpes-Style-Analysis-but-with-intercept-tp4125767p4129124.html
Sent from the Rmetrics mailing list archive at Nabble.com.



------------------------------

Message: 3
Date: Thu, 1 Dec 2011 08:18:14 -0800 (PST)
From: Philipp <jasonhome at freenet.de>
To: r-sig-finance at r-project.org
Subject: [R-SIG-Finance] Constrained Regression with Intercept in pcls
Message-ID: <1322756294407-4129187.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Dear all,

I already asked about to run a constrained regression like y=b0 +
b1X1+b2x2+b3x3, with constraints:

b1+b2+b3=1 and b1,b2,b3>=0. I thought it will run with style.QPfit with the
performance Analytic packages.

However the style.QPfit function does not estimate an intercept. As i really
can not extend this function for my problem, I noticed pcls. Pcls is maybe
an alternative for my problem. Can somebody help me to implement the
constraints in pcls. Maybe it can be done by designing a designed matrix X
with extra column for the inercept (b0) and to force C in a way. But how I
do not know.

Your help is greatly appreciated

Philipp

--
View this message in context: http://r.789695.n4.nabble.com/Constrained-Regression-with-Intercept-in-pcls-tp4129187p4129187.html
Sent from the Rmetrics mailing list archive at Nabble.com.



------------------------------

Message: 4
Date: Thu, 01 Dec 2011 22:24:52 +0100
From: Enrico Schumann <enricoschumann at yahoo.de>
To: Philipp <jasonhome at freenet.de>
Cc: r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] Constrained Regression with Intercept in
	pcls

Content-Type: text/plain; charset=ISO-8859-1; format=flowed


Hi Philipp,

you should be able to solve this with package quadprog/solve.QP.

require(quadprog)

p <- 3    ## number of regressors
T <- 100  ## number of obs
X <- array(rnorm(T*p), dim = c(T,p))
X <- cbind(1,X)  ## add a constant
y <- rnorm(T)


## variant 1 -- linear regression
coef(lm(y ~ -1 + X))


## variant 2 -- quadprog (should be the same as variant 1)
Dmat <- crossprod(X)
dvec <- as.vector(t(as.matrix(y)) %*% X)
Amat <- as.matrix(rep(0, p+1))
solve.QP(Dmat = Dmat, dvec = dvec, Amat = Amat)$solution


## variant 3 -- quadprog, now with restrictions
bvec <- c(1, rep(0, p))
Amat <- rbind(1,diag(p))
Amat <- cbind(0, Amat)
w <- solve.QP(Dmat = Dmat, dvec = dvec, Amat = t(Amat), bvec=bvec, 
meq=1)$solution
w          ## result
sum(w[-1]) ## check constraint

see also here http://comisef.wikidot.com/tutorial:minimisevariance

regards,
Enrico




Am 01.12.2011 17:18, schrieb Philipp: