This project has moved and is read-only. For the latest updates, please go here.

My first impressions with the emulator

Jan 15, 2014 at 1:06 PM
First of all I want to thank Robinson664 for this useful project. Although I have heard that Bloomberg is working on a simulator for developers, it seems they are not in a hurry.

I have started to work with the Java version of the emulator and I would like to show some minor issues I have experienced.

The first is related to the RandomDataGenerator and the randomDouble method. It is assuming the english locale, but if your native locale (detected by java) is a different one it returns a exception. For instance, in Spanish the decimal comma is represented by "," rather than ".", so the decimal format "#.####" complaints about it. These are my modifications:
    public static double randomDouble(double low, double high)
        DecimalFormat twoDForm = new DecimalFormat("#.####", 
        double result = RandomDataGenerator._rand.nextDouble() * (high - low) + low; 
        return Double.valueOf(twoDForm.format(result));
On the other hand, the Session class lacks of a nextEvent(long) method included in the official API (probably an API update?). I have added it redirecting to nexEvent. Also I have added a checking to prevent the method of throwing an exception when the sentRequests queue is empty. These are the changes.
    public Event nextEvent() throws Exception
        if (this._sentRequests.isEmpty()) return null;
            boolean isLastRequest = this._sentRequests.size() == 1;
            Request next = this._sentRequests.poll();
            return Event.EventFactory(next, isLastRequest);
    public Event nextEvent(long timeoutMillis) throws Exception
        return nextEvent();
I hope this helps to someone.


PS: Just a brief question if somebody knows about it. The code renaming to work with the official API is necessary? I mean, is it because of a legal issue with using the package "com.blombergblp.blpapi"? Replacing the jar would be faster and easier. Thanks.
Jan 27, 2014 at 8:21 PM

Sorry for the late reply. Thank you for your input:

1) I changed the randomDouble function, but not in the way that you recommended. I wanted to return random doubles rounded to four decimal places. The DecimalFormat method I used must have been the first method I found online that would do this. I now shift the decimal, round the number, and then shift the decimal back. I think this will work in any culture.

2) I put these changes directly in the code.

3) The reason I don't include the Bloomberg libraries is because I am hesitant to distribute them. I tried to make the conversion as simple as possible.

Thank you for your interest in my project. Please feel free to contact me with any other questions here, or directly.

Jan 27, 2014 at 9:48 PM
Hi, Jordan. Thanks again for your work. Currently I'm playing around with the emulator trying to connect it with the OpenGamma project.

Obviously I'm not the lucky man with money enough to have a Bloomberg Terminal so I test the integration by trial and error. I guess the guys form OpenGamma have tested hard their software against the Bloomberg API, so the emulator should react transparently to the OpenGamma calls.

I have some changes made to the emulator, although I have still to test all services, I mean mkt, hist and ref. Mainly these changes complete some methods declared in the official API but missing in the emulator. I hope to show soon these changes in this forum.

About the point 3) I think I didn't explain it clearly. I didn't talk about distributing the official API with the Bloomberg implementation, I meant that a convenient way to replace the library would be to keep the original API declaration (package name) with the emulated implementation instead. That is, bemu-xxx.jar and blpapi-xxx.jar should share the same public interface (according to com.blombergblp.blpapi package) but a different implementation.

Best regards.