2
$\begingroup$

I'm downloading intraday bar data using Bloomberg API and C#.

I have adapted the official Bloomberg c# "IntradayBarExample” to suit my needs.

However downloads are really slow, I found this post recommending to use a dedicated EventQueue instead of calling NextEvent() on a Session object. But the improvement is not really detectable.

As illustration, you can download the 5Min Bar – Best Bid Event- of the last 100 days for AAL UW Equity ticker, it takes very long time to obtain at the end not so much data (< 1Mo).

Did you face the same problem ?

$\endgroup$
  • $\begingroup$ using an EventQueue synchronizes the response and I don't think it will improve performance much. What would probably improve your throughput is to run requests in parallel (in several threads) $\endgroup$ – assylias Jan 19 '16 at 16:20
0
$\begingroup$

As suggested by assylias I have modified my code to run requests in several threads. In case you need to do so, these are some valuable informations :

1- Create a thread-safe request procedure and assign differents requestID to your requests. Pass these arguments to processResponseEvent via the eventloop function. This will allow you to make a check regarding the message you are receiving by using a simple condition:

            if (msg.CorrelationID != requestID)
            {
                System.Console.WriteLine("WRONG ID ");
                return;
            }

2- Make your request in parallel, meaning you enclosed the aforementioned request in a loop such as :

     WaitHandle[] waitHandles = new WaitHandle[numOfThreads];
        for (int i = 0; i < numOfThreads; i++)
        {
            var j = i;
            var handle = new EventWaitHandle(false, EventResetMode.ManualReset);
            var thread = new Thread(() =>
            {
                 /// CALL HERE YOU REQUEST PROCEDURE FROM STEP 1

                handle.Set();
            });
            waitHandles[j] = handle;
            thread.Start();
        }
        foreach (var ee in waitHandles)
            ee.WaitOne();

At the end it won't increase the waiting time for each request but since your are performing a bunch of them together you'll still save a LOT of time.

Ps: you can use the variable i (from for (int i = 0; i < numOfThreads; i++)) as requestID.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.