if (secIdField != null) {
secLink.setObjectId(deserializer.fieldValueToObject(ObjectId.class, secIdField));
}
}
SimpleTrade trade = new SimpleTrade();
trade.setSecurityLink(secLink);
if (message.hasField(UNIQUE_ID_FIELD_NAME)) {
FudgeField uniqueIdField = message.getByName(UNIQUE_ID_FIELD_NAME);
if (uniqueIdField != null) {
trade.setUniqueId(deserializer.fieldValueToObject(UniqueId.class, uniqueIdField));
}
}
if (message.hasField(QUANTITY_FIELD_NAME)) {
FudgeField quantityField = message.getByName(QUANTITY_FIELD_NAME);
if (quantityField != null) {
trade.setQuantity(message.getFieldValue(BigDecimal.class, quantityField));
}
}
if (message.hasField(COUNTERPARTY_FIELD_NAME)) {
FudgeField counterpartyField = message.getByName(COUNTERPARTY_FIELD_NAME);
if (counterpartyField != null) {
trade.setCounterparty(new SimpleCounterparty(deserializer.fieldValueToObject(ExternalId.class, counterpartyField)));
}
}
if (message.hasField(TRADE_DATE_FIELD_NAME)) {
FudgeField tradeDateField = message.getByName(TRADE_DATE_FIELD_NAME);
if (tradeDateField != null) {
trade.setTradeDate(message.getFieldValue(LocalDate.class, tradeDateField));
}
}
if (message.hasField(TRADE_TIME_FIELD_NAME)) {
FudgeField tradeTimeField = message.getByName(TRADE_TIME_FIELD_NAME);
if (tradeTimeField != null) {
trade.setTradeTime(message.getFieldValue(OffsetTime.class, tradeTimeField));
}
}
if (message.hasField(PREMIUM_FIELD_NAME)) {
trade.setPremium(message.getDouble(PREMIUM_FIELD_NAME));
}
if (message.hasField(PREMIUM_CURRENCY_FIELD_NAME)) {
String currencyCode = message.getString(PREMIUM_CURRENCY_FIELD_NAME);
if (currencyCode != null) {
trade.setPremiumCurrency(Currency.of(currencyCode));
}
}
if (message.hasField(PREMIUM_DATE_FIELD_NAME)) {
FudgeField premiumDate = message.getByName(PREMIUM_DATE_FIELD_NAME);
if (premiumDate != null) {
trade.setPremiumDate(message.getFieldValue(LocalDate.class, premiumDate));
}
}
if (message.hasField(PREMIUM_TIME_FIELD_NAME)) {
FudgeField premiumTime = message.getByName(PREMIUM_TIME_FIELD_NAME);
if (premiumTime != null) {
trade.setPremiumTime(message.getFieldValue(OffsetTime.class, premiumTime));
}
}
if (message.hasField(ATTRIBUTES_FIELD_NAME)) {
FudgeMsg attributesMsg = message.getMessage(ATTRIBUTES_FIELD_NAME);
for (FudgeField fudgeField : attributesMsg) {
String key = fudgeField.getName();
Object value = fudgeField.getValue();
if (key != null && value != null) {
trade.addAttribute(key, (String) value);
}
}
}
return trade;
}