protected void initializeFrom(FieldMap source) { fields.clear(); fields.putAll(source.fields); for (Entry<Integer, List<Group>> entry : source.groups.entrySet()) { final List<Group> clones = new ArrayList<>(); for (final Group group : entry.getValue()) { final Group clone = new Group(group.getFieldTag(), group.delim(), group.getFieldOrder()); clone.initializeFrom(group); clones.add(clone); } groups.put(entry.getKey(), clones); } }
/** * Copy a group. * * @param group the group to copy */ public Group(Group group) { this(group.getFieldTag(), group.delim(), group.getFieldOrder()); setFields(group); setGroups(group); }
public Group getGroup(int num, Group group) throws FieldNotFound { final List<Group> groupList = getGroups(group.getFieldTag()); if (num > groupList.size()) { throw new FieldNotFound(group.getFieldTag() + ", index=" + num); } final Group grp = groupList.get(num - 1); group.setFields(grp); group.setGroups(grp); return group; }
char entryType = mdEntry.getChar(quickfix.field.MDEntryType.FIELD); if(entryType == quickfix.field.MDEntryType.EMPTY_BOOK) { continue; char updateAction = mdEntry.getChar(quickfix.field.MDUpdateAction.FIELD); switch(updateAction) { case quickfix.field.MDUpdateAction.CHANGE: Date date = mdEntry.getUtcDateOnly(quickfix.field.MDEntryDate.FIELD); Date time = mdEntry.getUtcTimeOnly(quickfix.field.MDEntryTime.FIELD); Date eventDate = new Date(date.getTime()+time.getTime()); switch(entryType) { QuoteEventBuilder<BidEvent> bidBuilder = QuoteEventBuilder.bidEvent(instrument); bidBuilder.withAction(quoteAction); bidBuilder.withCount(mdEntry.getInt(quickfix.field.NumberOfOrders.FIELD)); bidBuilder.withEventType(inIsSnapshot?EventType.SNAPSHOT_PART:EventType.UPDATE_PART); bidBuilder.withExchange(exchange); int level = mdEntry.getInt(quickfix.field.MDEntryPositionNo.FIELD); bidBuilder.withLevel(level); bidBuilder.withPrice(mdEntry.getDecimal(quickfix.field.MDEntryPx.FIELD)); bidBuilder.withProcessedTimestamp(System.nanoTime()); bidBuilder.withProvider(provider); bidBuilder.withQuoteDate(eventDate); bidBuilder.withReceivedTimestamp(inReceivedTimestamp); bidBuilder.withSize(mdEntry.getDecimal(quickfix.field.MDEntrySize.FIELD)); bidBuilder.withSource(requestId); if(instrument instanceof Option) {
/** * @deprecated Use getFieldTag * @return the field's tag number */ public int field() { return getFieldTag(); } }
char type = group.getChar(MDEntryType.FIELD); switch (type) { case MDEntryType.BID: px = group.getDecimal(MDEntryPx.FIELD); tickerBuilder.bid(px); break; case MDEntryType.OFFER: px = group.getDecimal(MDEntryPx.FIELD); tickerBuilder.ask(px); break; case MDEntryType.TRADE: px = group.getDecimal(MDEntryPx.FIELD); tickerBuilder.last(px); break; px = group.getDecimal(MDEntryPx.FIELD); tickerBuilder.high(px); break; case MDEntryType.TRADING_SESSION_LOW_PRICE: px = group.getDecimal(MDEntryPx.FIELD); tickerBuilder.low(px); break; size = group.getDecimal(MDEntrySize.FIELD); tickerBuilder.volume(size); Date date = group.getField(new MDEntryDate()).getValue(); Date time = group.getField(new MDEntryTime()).getValue();
public void replaceGroup(int num, Group group) { final int offset = num - 1; final List<Group> groupList = getGroups(group.getFieldTag()); if (offset < 0 || offset >= groupList.size()) { return; } groupList.set(offset, new Group(group)); }
if (tag == firstField) { addGroupRefToParent(group, parent); group = new Group(groupCountTag, firstField, groupDataDictionary.getOrderedFields()); group.setField(field); firstFieldFound = true; previousOffset = -1; if (offset <= previousOffset) { group.setField(field); addGroupRefToParent(group, parent); throw new FieldException( group.setField(field); } else {
char type = group.getChar(MDEntryType.FIELD); BigDecimal px = group.getField(new MDEntryPx()).getValue(); BigDecimal size = group.isSetField(MDEntrySize.FIELD) ? group.getField(new MDEntrySize()).getValue() : null; log.trace("{} {}@{}", type, size, px); break; case MDEntryType.TRADE: OrderType orderType = group.getField(new Side()).getValue() == Side.BUY ? OrderType.BID : OrderType.ASK; Trade trade = new Trade.Builder().currencyPair(currencyPair).type(orderType).price(px).tradableAmount(size).build(); trades.add(trade);
/** * Create an MDEntry group. * * @param inMessageFactory a <code>FIXMessageFactory</code> value * @param inMdEntryType a <code>char</code> value * @return a <code>Group</code> value */ public Group createMdEntryGroup(String inMsgType, char inMdEntryType) { Group newGroup = createGroup(inMsgType, quickfix.field.NoMDEntries.FIELD); newGroup.setField(new quickfix.field.MDEntryType(inMdEntryType)); return newGroup; } /**
final Group group = message.getGroup(i, NoMDEntries.FIELD); final char action = group.getChar(MDUpdateAction.FIELD); final char type = group.getChar(MDEntryType.FIELD); final BigDecimal px = group.getDecimal(MDEntryPx.FIELD); final BigDecimal size = group.getDecimal(MDEntrySize.FIELD);
public void addGroup(Group group) { addGroupRef(new Group(group)); }
private FieldMap extractGroup(Message message, Integer groupID, Integer groupDiscriminatorID, Object groupDiscriminatorValue) { FieldMap map = null; try { Group aGroup = messageFactory.createGroup(message.getHeader().getString(MsgType.FIELD), groupID); if (aGroup !=null){ int groupTag = aGroup.getFieldTag(); int numGroups = message.getInt(groupTag); String discriminatorString = groupDiscriminatorValue.toString(); for (int i = 1; i<= numGroups; i++){ message.getGroup(i, aGroup); String messageDiscriminatorValue = aGroup.getString(groupDiscriminatorID); if (discriminatorString.equals(messageDiscriminatorValue)){ return aGroup; } } } else { return null; } } catch (FieldNotFound e) { } return map; } /**
symbolGroup); symbolGroup.removeField(quickfix.field.Currency.FIELD); symbolGroup.removeField(quickfix.field.OrdType.FIELD); if(inExchange != null && !inExchange.isEmpty()) { symbolGroup.setField(new quickfix.field.SecurityExchange(inExchange));
int calculateLength() { int result = 0; for (final Field<?> field : fields.values()) { int tag = field.getField(); if (tag != BeginString.FIELD && tag != BodyLength.FIELD && tag != CheckSum.FIELD && !isGroupField(tag)) { result += field.getLength(); } } for (Entry<Integer, List<Group>> entry : groups.entrySet()) { final List<Group> groupList = entry.getValue(); if (!groupList.isEmpty()) { final IntField groupField = new IntField(entry.getKey()); groupField.setValue(groupList.size()); result += groupField.getLength(); for (final Group group : groupList) { result += group.calculateLength(); } } } return result; }
int calculateChecksum() { int result = 0; for (final Field<?> field : fields.values()) { if (field.getField() != CheckSum.FIELD && !isGroupField(field.getField())) { result += field.getChecksum(); } } for (Entry<Integer, List<Group>> entry : groups.entrySet()) { final List<Group> groupList = entry.getValue(); if (!groupList.isEmpty()) { if(IS_STRING_EQUIVALENT) { String value = NumbersCache.get(entry.getKey()); for (int i = value.length(); i-- != 0;) result += value.charAt(i); value = NumbersCache.get(groupList.size()); for (int i = value.length(); i-- != 0;) result += value.charAt(i); result += '=' + 1; } else { final IntField groupField = new IntField(entry.getKey()); groupField.setValue(groupList.size()); result += groupField.getChecksum(); } for (int i = 0; i < groupList.size(); i++) { result += groupList.get(i).calculateChecksum(); } } } return result & 0xFF; }
List<Group> groups = getGroups(tag); for (int i = 0; i < groups.size(); i++) { groups.get(i).calculateString(buffer, preFields, postFields); buffer.append(NumbersCache.get(groupCount)).append('\001'); for (int i = 0; i < groups.size(); i++) { groups.get(i).calculateString(buffer, preFields, postFields);
public static void mergeMarketDataMessages(Message marketDataSnapshotFullRefresh, Message marketDataIncrementalRefresh, FIXMessageFactory factory){ if (!isMarketDataSnapshotFullRefresh(marketDataSnapshotFullRefresh)){ throw new IllegalArgumentException(Messages.FIX_MD_MERGE_INVALID_INCOMING_SNAPSHOT.getText()); } if (!isMarketDataIncrementalRefresh(marketDataIncrementalRefresh)){ throw new IllegalArgumentException(Messages.FIX_MD_MERGE_INVALID_INCOMING_INCREMENTAL.getText()); } HashMap<Character, Group> consolidatingSet = new HashMap<Character, Group>(); addGroupsToMap(marketDataSnapshotFullRefresh, factory, consolidatingSet); addGroupsToMap(marketDataIncrementalRefresh, factory, consolidatingSet); marketDataSnapshotFullRefresh.removeGroup(NoMDEntries.FIELD); for (Group aGroup : consolidatingSet.values()) { Group group = factory.createGroup(MsgType.MARKET_DATA_SNAPSHOT_FULL_REFRESH, NoMDEntries.FIELD); group.setFields(aGroup); marketDataSnapshotFullRefresh.addGroup(group); } }
private static void addGroupsToMap(Message marketDataMessage, FIXMessageFactory factory, HashMap<Character, Group> consolidatingSet){ try { int noMDEntries = marketDataMessage.getInt(NoMDEntries.FIELD); String msgType = marketDataMessage.getHeader().getString(MsgType.FIELD); for (int i = 1; i <= noMDEntries; i++){ Group group = factory.createGroup(msgType, NoMDEntries.FIELD); try { marketDataMessage.getGroup(i, group); consolidatingSet.put(group.getChar(MDEntryType.FIELD), group); } catch (FieldNotFound e) { //just continue } } } catch (FieldNotFound e) { // ignore } } /**
char entryType = mdEntry.getChar(quickfix.field.MDEntryType.FIELD); QuoteAction quoteAction = QuoteAction.ADD; if(!inIsSnapshot) { char updateAction = mdEntry.getChar(quickfix.field.MDUpdateAction.FIELD); switch(updateAction) { case quickfix.field.MDUpdateAction.CHANGE: Date date = mdEntry.getUtcDateOnly(quickfix.field.MDEntryDate.FIELD); Date time = mdEntry.getUtcTimeOnly(quickfix.field.MDEntryTime.FIELD); Date eventDate = new Date(date.getTime()+time.getTime()); switch(entryType) { QuoteEventBuilder<BidEvent> bidBuilder = QuoteEventBuilder.bidEvent(instrument); bidBuilder.withAction(quoteAction); bidBuilder.withCount(mdEntry.getInt(quickfix.field.NumberOfOrders.FIELD)); bidBuilder.withEventType(inIsSnapshot?EventType.SNAPSHOT_PART:EventType.UPDATE_PART); bidBuilder.withExchange(exchange); int level = mdEntry.getInt(quickfix.field.MDEntryPositionNo.FIELD); bidBuilder.withLevel(level); bidBuilder.withPrice(mdEntry.getDecimal(quickfix.field.MDEntryPx.FIELD)); bidBuilder.withProcessedTimestamp(System.nanoTime()); bidBuilder.withProvider(ExsimFeedModuleFactory.IDENTIFIER); bidBuilder.withQuoteDate(eventDate); bidBuilder.withReceivedTimestamp(receivedTimestamp); bidBuilder.withSize(mdEntry.getDecimal(quickfix.field.MDEntrySize.FIELD)); bidBuilder.withSource(requestId); if(instrument instanceof Option) { QuoteEventBuilder<AskEvent> askBuilder = QuoteEventBuilder.askEvent(instrument);