@Override public void validate(Instrument inInstrument) throws OrderValidationException { Currency currency = (Currency) inInstrument; validateCurrencySymbol(currency.getSymbol()); if(currency.getNearTenor() !=null && !currency.getNearTenor().isEmpty()) { validateTenor(currency.getNearTenor()); } if(currency.getFarTenor() !=null && !currency.getFarTenor().isEmpty()) { validateTenor(currency.getFarTenor()); } }
@Override public int compareTo(Currency o2) { Currency o1 = this; if(o2==null){ //throw new NullPointerException("compareTo invalid for null objects in Currency.compareTo"); return 1; // prefer to say this object is always greater than a null? } int symbolComp = o1.getSymbol().compareTo(o2.getSymbol()); if(symbolComp==0){ int nearTenorComp = o1.getNearTenor().compareTo(o2.getNearTenor()); if(nearTenorComp==0){ if(o1.isSwap() && o2.isSwap()){ return o1.getFarTenor().compareTo(o2.getFarTenor()); }else{ return 0; } }else{ return nearTenorComp; } }else{ return symbolComp; } }
@Override public int compare(Currency inO1,Currency inO2) { return new CompareToBuilder().append(inO1.getSymbol(), inO2.getSymbol()) .append(inO1.getNearTenor(), inO2.getNearTenor()) .append(inO1.getFarTenor(), inO2.getFarTenor()).toComparison(); } }
@Override public void set(Instrument instrument, DataDictionary dictionary,String msgType, FieldMap message) { // always include the symbol message.setString(Symbol.FIELD, instrument.getSymbol()); message.setString(SecurityType.FIELD,SecurityType.FOREIGN_EXCHANGE_CONTRACT); if (dictionary.isMsgField(msgType, Product.FIELD)) { message.setInt(Product.FIELD, Product.CURRENCY); } Currency currencyInstrument = (Currency) instrument; if (dictionary.isMsgField(msgType, quickfix.field.Currency.FIELD) && currencyInstrument.getTradedCCY()!=null) { message.setString(quickfix.field.Currency.FIELD,currencyInstrument.getTradedCCY()); } if(MsgType.ORDER_CANCEL_REQUEST.equals(msgType)) { message.removeField(FutSettDate.FIELD); message.removeField(quickfix.field.OrdType.FIELD); } else { if(currencyInstrument.getNearTenor() !=null) { message.setString(FutSettDate.FIELD,currencyInstrument.getNearTenor()); } if (currencyInstrument.isSwap()) { message.setString(FutSettDate2.FIELD,currencyInstrument.getFarTenor()); message.setChar(quickfix.field.OrdType.FIELD,quickfix.field.OrdType.FOREX_SWAP); } } } /**