FraTradeSecurityExtractor extends TradeSecurityExtractor<FraTrade> { @Override public ManageableSecurity[] extractSecurities() { FraTrade fraTrade = getTrade(); validate(fraTrade); boolean payFixed = fraTrade.isPayFixed(); double specifiedNotional = fraTrade.getNotional().doubleValue(); double absoluteNotional = payFixed ? specifiedNotional : -specifiedNotional; ExternalId underlyingIdentifier = fraTrade.getFixingIndex().getIndex().toExternalId(); FRASecurity fraSecurity = new FRASecurity(fraTrade.getCurrency(), fraTrade.getRegionId().toExternalId(), convertLocalDate(fraTrade.getEffectiveDate()), convertLocalDate(fraTrade.getTerminationDate()), fraTrade.getRate().doubleValue(), absoluteNotional, underlyingIdentifier, convertLocalDate(fraTrade.getFixingDate())); return securityArray(addIdentifier(fraSecurity)); } FraTradeSecurityExtractor(FraTrade trade); @Override ManageableSecurity[] extractSecurities();  }
@Test public void testExtractSecurities() { FraTrade fra = createBasicFra(); FraTradeSecurityExtractor fraExtractor = new FraTradeSecurityExtractor(fra); ManageableSecurity[] extractSecurities = fraExtractor.extractSecurities(); assertEquals(1, extractSecurities.length, "One fra expected"); assertEquals(FRASecurity.class, extractSecurities[0].getClass(), "Expected instance of FraSecurity"); }
@Test(expectedExceptions={OpenGammaRuntimeException.class}) public void testExtractSecuritiesBadPaymentDate() { FraTrade fra = createBasicFra(); fra.setPaymentDate(fra.getEffectiveDate().plusDays(1)); FraTradeSecurityExtractor fraExtractor = new FraTradeSecurityExtractor(fra); fraExtractor.extractSecurities(); }
@Test public void testExtractSecuritiesWithCalendarInfo() { FraTrade fra = createBasicFra(); fra.setDayCount("Modified Following"); fra.setBusinessDayConvention("Actual/365"); FraTradeSecurityExtractor fraExtractor = new FraTradeSecurityExtractor(fra); ManageableSecurity[] extractSecurities = fraExtractor.extractSecurities(); assertEquals(1, extractSecurities.length, "One fra expected"); assertEquals(FRASecurity.class, extractSecurities[0].getClass(), "Expected instance of FraSecurity"); }