Technology weblog

IT-Essence
Thursday Jan 05, 2012

Reading repeating groups in FIX market data reponse

This short post details how to read out repeating groups in a FIX 4.4 MsgType.MARKET_DATA_SNAPSHOT_FULL_REFRESH message using QuickFix/J. In the example below I have requested the bid and offer prices, which implies that I get returned two repeating groups. First all groups are retrieved, and then we loop through the groups to extract the subsequent fields:

final String symbol = message.getString(Symbol.FIELD);

final List<Group> groups = message.getGroups(NoMDEntries.FIELD);
BigDecimal bidPrice = null;
BigDecimal offerPrice = null;
BigDecimal bidSize = null;
BigDecimal offerSize = null;
for (final Group oneGroup : groups) {
  final char type = oneGroup.getChar(MDEntryType.FIELD);
  if (type == MDEntryType.OFFER) {
    offerPrice = oneGroup.getDecimal(MDEntryPx.FIELD);
    offerSize = oneGroup.getDecimal(MDEntrySize.FIELD);
  } else if (type == MDEntryType.BID) {
    bidPrice = oneGroup.getDecimal(MDEntryPx.FIELD);
    bidSize = oneGroup.getDecimal(MDEntrySize.FIELD);
  }
}

Comments:

Post a Comment:
Comments are closed for this entry.

Hire us
Archives
Tags
Links
Stats
Referrers