Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bloomberg API request timing out

Having set up a ReferenceDataRequest I send it along to an EventQueue

Service refdata = _session.GetService("//blp/refdata");
Request request = refdata.CreateRequest("ReferenceDataRequest");
// append the appropriate symbol and field data to the request
EventQueue eventQueue = new EventQueue();
Guid guid = Guid.NewGuid();
CorrelationID id = new CorrelationID(guid);
_session.SendRequest(request, eventQueue, id);
long _eventWaitTimeout = 60000;
myEvent = eventQueue.NextEvent(_eventWaitTimeout);

Normally I can grab the message from the queue, but I'm hitting the situation now that if I'm making a number of requests in the same run of the app (normally around the tenth), I see a TIMEOUT EventType

if (myEvent.Type == Event.EventType.TIMEOUT)
    throw new Exception("Timed Out - need to rethink this strategy");
else
    msg = myEvent.GetMessages().First();

These are being made on the same thread, but I'm assuming that there's something somewhere along the line that I'm consuming and not releasing.

Anyone have any clues or advice?

There aren't many references on SO to BLP's API, but hopefully we can start to rectify that situation.

like image 980
Unsliced Avatar asked Sep 18 '09 09:09

Unsliced


1 Answers

I just wanted to share something, thanks to the code you included in your initial post.

If you make a request for historical intraday data for a long duration (which results in many events generated by Bloomberg API), do not use the pattern specified in the API documentation, as it may end up making your application very slow to retrieve all events. Basically, do not call NextEvent() on a Session object! Use a dedicated EventQueue instead.

Instead of doing this:

var cID = new CorrelationID(1);
session.SendRequest(request, cID);
do {
   Event eventObj = session.NextEvent();
   ...
}

Do this:

var cID = new CorrelationID(1);
var eventQueue = new EventQueue();
session.SendRequest(request, eventQueue, cID);
do {
   Event eventObj = eventQueue.NextEvent();
   ...
}

This can result in some performance improvement, though the API is known to not be particularly deterministic...

like image 192
Erwin Mayer Avatar answered Sep 19 '22 02:09

Erwin Mayer