Search code examples
bloomberg

Why is my code dropping ticks in BLPAPI


Most ticks are fine, but quite often some ticks are missing

Pseudo code:

    Foreach Message msg in myEvent
    {
       if (m.hasField(BID))
       {
            handlebid(m.getFieldasFloat64(BID);
       }

       if (m.hasField(BID_SIZE))
       {

           int bidsize=m.getFieldasInt(BID_SIZE);
           if (bidsize==0)
           {
                  return -1;
           }
           handlebidsize(bidsize);
      }

      if (m.hasField(ASK))
      {
           handleask(m.getFieldasFloat64(ASK);
      }

      if (m.hasField(ASK_SIZE))
      {
           int asksize=m.getFieldasInt(ASK_SIZE);
           if (asksize==0)
           {
                  return -1;
           }
           handleasksize(asksize);
      }
}

Solution

  • Events can contain multiple messages

    If your event handler does a return or breaks out of the loop in any way instead of going to the next loop iteration, then any messages in the event after the one that triggered the loop exit will not be processed. Any ticks in those messages will be "dropped"

    Never exit an event processing loop with return or break