/** * Returns the currency CFI code for the supplied currency instrument type * * @param inInstrument the instrument. * * @return the currency CFI code. */ static String getCFICode(Currency inInstrument) { StringBuffer code = new StringBuffer(); code.append("F"); // for futures-settling //$NON-NLS-1$ code.append("F"); // for financial instrument //$NON-NLS-1$ code.append("C"); // for currencies //$NON-NLS-1$ code.append("P"); // for physically-delivered //$NON-NLS-1$ code.append("N"); // for non-standard //$NON-NLS-1$ if(inInstrument.isSwap()) { code.append("W"); // for Swap //$NON-NLS-1$ } else { code.append("O"); // for outright } return code.toString(); }
@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 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); } } } /**