BSRCH
This is related to the closed issue #82, I suppose, but as it is now a standard feature as per comments on that page, I am trying to get it to work with my updated Rblpapi
I do not manage to get examples of use to work:
head(bsrch("COMDTY:VESSELS"), 20)
The standard bdh() examples, etc, work, but not bsrch. R hangs and has to be shut down...
Is the intended functionality supposed to be in line with 7.10.1 Security Lookup Request in API manual page 101?
I am very much interested in getting it to work: they have C++ sample code on page 102, but I and C++ are not friends...
I can confirm the problem with
res2 <- bsrch("COMDTY:VESSELS")
which hangs the session for me too. Any idea, @wmorgan85 ?
OTOH the other one
bsrch("COMDTY:NGFLOW")
works fine. There seems to be an error we are not trapping...
Indeed, the second example works (and produces many results), but I am now more unsure about the intended use of the function.
In the terminal, if I go to SECF COMTY and then enter NGFLOW, I get no results. Similarly, if I enter NGFLOW into the search field, I also get no results prompted.
Going to the first result on the list, I see it is some sort of Natural Gas Flow Index by some company. NGFLOW becomes more meaningful, but does not clarify how the function is to be used.
Trying to stumble on the correct answer I have tried:
bsrch("iShares Dow Jones U.S. Basic Materials Sector Index Fund")
bsrch("EQUITY:iShares Dow Jones U.S. Basic Materials Sector Index Fund")
bsrch("EQTY:iShares Dow Jones U.S. Basic Materials Sector Index Fund")
bsrch(paste0(gsub(" ","* ",toupper("EQTY:iShares Dow Jones U.S. Basic Materials Sector Index Fund")),"*"))
Each of the above crashes R.
Having checked, it looks like the example is actually incorrect. It should be COMDTY:Vessel, not COMDTY:Vessels.
The intended use of the function is to replicate the =BSRCH() formula from Excel. As per documentation, "It can be a user defined SRCH screen, commodity screen or one of the variety of Bloomberg examples." It is not intended to replicate the behaviour of the SECF screen.
I cannot replicate the crashes but we should probably take into account any errors that are returned by the service better than we do today.
Ahh. Confirming better luck with COMDTY:Vessel. I'll update the files in a minute.
I may leave this open as a reminder that we need to trap the bad results better. I may play with that first in a standalone C++ executable.
Update: Currently no blow-ups occur. This must have been backend-dependent.
Thank you for clarification, @wmorgan85 Is there any hope of getting to the Security Lookup feature of the API working in the package? (SECF screen equivalent)? The code below is from the API pdf (referenced above) and is in C++:
Service secfService = session.getService("//blp/instruments");
Request request = secfService.createRequest("instrumentListRequest");
request.asElement().setElement("query", "IBM");
request.asElement().setElement("yellowKeyFilter", "YK_FILTER_CORP");
request.asElement().setElement("languageOverride", "LANG_OVERRIDE_NONE");
request.asElement().setElement("maxResults", 10);
sendRequest(request, session);
[ OT: @ucb: Have a look at how I formatted your post. Three apostrophes is what it takes. Thanks. ]
Thank you for the message formatting pointer, @eddelbuettel
I see there is a SecurityLookupExample.cpp in the API folder too. I have not managed to convince Rcpp to accept the file, but then I have never used Rcpp directly...
@ucb what would you be trying to use it for in the R context out of interest? I'm sure such a feature would be welcomed into the package were someone to produce a working version.
@wmorgan85 this function allows to find best matching tickers by name (and optionally type), just like the search field of the terminal.
If you have a list of names for securities of interest (possibly from another data source) and you would like to find their Bloomberg identifiers so that you could download other data from Bloomberg.
In my earlier question, I used example of a MF name. If you have thousands of MFs in your data, finding Bloomberg identifiers by hand is not an option. With this function, on the other hand...
As mentioned, I do not know C++. I have tried to build the function based on the existing cpp file, but I get errors. I have tried loading .h files and the library files by adjusting environmental variables from R first (PKG_CXXFLAGS and PKG_LIBS), but I must have done it wrong, as I still get errors of missing .h files. If I copy .h files into the same directory as the .cpp, .h errors go away, but it still does not compile. I am guessing because it is missing the lib directory files (copying files from the lib directory does not help)? Gives several errors like this:
C:/blp/API/APIv3/C++API/v3.8.13.1/examples/blpapi_timepoint.h: In static member function 'static long long int BloombergLP::blpapi::TimePointUtil::nanosecondsBetween(const TimePoint&, const TimePoint&)':
C:/blp/API/APIv3/C++API/v3.8.13.1/examples/blpapi_call.h:46:9: error: operands to ?: have different types 'long long int (*)(const blpapi_TimePoint_t*, const blpapi_TimePoint_t*) {aka long long int (*)(const blpapi_TimePoint*, const blpapi_TimePoint*)}' and 'int'
? (g_blpapiFunctionEntries.FUNCNAME) \
^
Does the current functionality only allow you to call the domain with no parameters or output options? In excel the format to download vessel data is: =BSRCH("COMDTY:Vessel","Type=Bulk Carrier|Ore Carrier| Ore/Oil Carrier","DWT=48000:450000","Output=DWT|Max Draft"). Is there a way to specify output and parameters?
@ucb @eddelbuettel is there a substitute for SECF in rblpapi? As an example, I am looking for all the tickers in when searching for "IEA CRUDE". There are 7000+ tickers and using the 250 at a time export will take too long.
Created a new issue for the SECF substitute: https://github.com/Rblp/Rblpapi/issues/215