Monday, December 23, 2019

Bloomberg API from Linux using standard terminal.


I switched my PC to linux recently (lubuntu) and so far everything is running smoothly, but there are some windows-only software lacking. One such thing is Bloomberg.

The company does offer Bloomberg Anywhere, which runs Terminal app and Excel in data centers and displays them remotely via Citrix on your PC. This covers the basic usage, but gives no way to access their APIs, which are often used to download data for analysis with python or java extensive toolbox. They also do offer server gateways(b-pipe?), but the cost and complexity can only be afforded by big companies.

Here is not quite easy or elegant, but a working solution to this.
  1. You need to run Windows on virtual machine(VM). I use VirtualBox, but VMware probably works as well. Bloomberg software is installed there.
  2. You need a dual port forward, both in VM and Windows. Here is the dataflow: HostOS/localhost:8194->GuestOS/ip:8194->GuestOS/localhost:8194
Step 1 is time consuming, but straightforward.

Step 2 is more involved. Firstly you need a port forward in VBox to be able to access guest VM from host via TCP/IP. This can be done via VBox dynamically( don't need to reboot VM):
The tricky part is you need to run another port forward in windows and built-in one, netsh, won't work with loopback interface bbcomm runs on, but I got PortMapper from AnalogX (http://www.analogx.com/contents/download/Network/pmapper/Freeware.htm) to work. Again this is configured via UI:
Install Linux API packages, login to the terminal, start PortMapper (in this order!) and all should work:
$ cd
$ cd blpapi_cpp_3.13.1.1/Linux

$ LD_LIBRARY_PATH=. ./SimpleBlockingRequestExample_32
SimpleBlockingRequestExample
Connecting to localhost:8194
Subscribing to IBM US Equity
Requesting reference data IBM US Equity
ReferenceDataResponse = {
    securityData[] = {
        securityData = {
            security = "IBM US Equity"

...

2 comments:

  1. Is this allowed under the Bloomberg licence agreement?

    ReplyDelete
  2. I assume so. The usage is still personal, as long you don't open this to other people, etc.

    ReplyDelete