Reputation: 1535
Have anyone had problem with Rbbg
when trying to override the quote type for bond? (Background, we can quote bond in either price or yield, in Bloomberg, you can override it by using a field called QtTyp
)
I tried the same formula in excel API and it worked fine, but when I try it in R, it gives me an error when I use the override:
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
org.findata.blpwrapper.WrapperException: response error: Invalid override field id specified [nid:908]
Formula in excel is:
=BDH("EC223677@BGN Corp","LAST_PRICE","02/01/2000","02/01/2000","QtTyp=P")
Formula in R is:
> bdh(conn, "EC223677@BGN Corp","LAST_PRICE",as.Date("02/01/2000","%m/%d/%Y"),as.Date("02/01/2000","%m/%d/%Y"))
date LAST_PRICE
2000-02-01 2000-02-01 0.983
> bdh(conn, "EC223677@BGN Corp","LAST_PRICE",as.Date("02/01/2000","%m/%d/%Y"),as.Date("02/01/2000","%m/%d/%Y"), override_fields = "QtTyp", override_values = "P")
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
org.findata.blpwrapper.WrapperException: response error: Invalid override field id specified [nid:908]
Upvotes: 2
Views: 831
Reputation: 364
Following the Bloomberg API document, one has to set the "pricingOption" to either "PRICING_OPTION_PRICE" or "PRICING_OPTION_YIELD".
If you do that it should work. However, as of today I have just changed our new R package RbbgExtension from a private repository on GitHub to public. This package aims to extend the functionality and make it easier to use Rbbg - see it as a wrapper on top of Rbbg that in itself is a Java wrapper.
Based on your question I just made patch to RbbgExtension to include the pricingOption variable as default to "PRICING_OPTION_PRICE". Which means that to get the price you want, you just type in the following...
> HistData(tickers = "EC223677",
+ type = "Govt",
+ fields = "PX_LAST",
+ startdate = "20000201",
+ enddate="20000201")
R version 3.1.1 (2014-07-10)
rJava Version 0.9-6
Rbbg Version 0.5.2
Java environment initialized successfully.
Looking for most recent blpapi3.jar file...
Adding C:\blp\API\APIv3\JavaAPI\v3.7.1.1\lib\blpapi3.jar to Java classpath
Bloomberg API Version 3.7.1.1
PX_LAST
2000-02-01 100.082
If you install the devtools package by Hadley Wickham then you can easily install the latest version of RbbgExtension by typing in install_github("pgarnry/RbbgExtension").
If you want the yield instead you just change the pricing variable for the function.
We are actually discussing whether to change the variable inputs in the function to be similar to the Excel naming convention to make things more like-for-like, but for now option names like the pricing option is set using the full input name and not by abbreviations such as "P" or "Y" as in Excel, but as said it might change in future versions.
Upvotes: 2