public void test_matching() { assertEquals(FpmlPartySelector.matching("a1").selectParties(MAP), ImmutableList.of("A")); assertEquals(FpmlPartySelector.matching("a2").selectParties(MAP), ImmutableList.of("A")); assertEquals(FpmlPartySelector.matching("b").selectParties(MAP), ImmutableList.of("B")); assertEquals(FpmlPartySelector.matching("c").selectParties(MAP), ImmutableList.of()); }
@Test(dataProvider = "parse") public void parse(String location) { ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertEquals(trades.size(), 1); }
public void fxForward_splitDate() { String location = "classpath:com/opengamma/strata/loader/fpml/fx-ex03-fx-fwd-split-date.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), FxSingleTrade.class); FxSingleTrade fxTrade = (FxSingleTrade) trade; assertEquals(fxTrade.getInfo().getTradeDate(), Optional.of(date(2001, 11, 19))); FxSingle fx = fxTrade.getProduct(); assertEquals(fx.getBaseCurrencyPayment(), Payment.of(EUR, 10000000, date(2001, 12, 21))); assertEquals(fx.getCounterCurrencyPayment(), Payment.of(USD, -9175000, date(2001, 12, 22))); }
public void fxSpot() { String location = "classpath:com/opengamma/strata/loader/fpml/fx-ex01-fx-spot.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), FxSingleTrade.class); FxSingleTrade fxTrade = (FxSingleTrade) trade; assertEquals(fxTrade.getInfo().getTradeDate(), Optional.of(date(2001, 10, 23))); FxSingle fx = fxTrade.getProduct(); assertEquals(fx.getBaseCurrencyPayment(), Payment.of(GBP, 10000000, date(2001, 10, 25))); assertEquals(fx.getCounterCurrencyPayment(), Payment.of(USD, -14800000, date(2001, 10, 25))); }
public void fxForward() { String location = "classpath:com/opengamma/strata/loader/fpml/fx-ex03-fx-fwd.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), FxSingleTrade.class); FxSingleTrade fxTrade = (FxSingleTrade) trade; assertEquals(fxTrade.getInfo().getTradeDate(), Optional.of(date(2001, 11, 19))); FxSingle fx = fxTrade.getProduct(); assertEquals(fx.getBaseCurrencyPayment(), Payment.of(EUR, 10000000, date(2001, 12, 21))); assertEquals(fx.getCounterCurrencyPayment(), Payment.of(USD, -9175000, date(2001, 12, 21))); }
public void bulletPayment() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex28-bullet-payments.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), BulletPaymentTrade.class); BulletPaymentTrade bpTrade = (BulletPaymentTrade) trade; assertEquals(bpTrade.getInfo().getTradeDate(), Optional.of(date(2001, 4, 29))); BulletPayment bp = bpTrade.getProduct(); assertEquals(bp.getPayReceive(), PAY); assertEquals(bp.getDate(), AdjustableDate.of(date(2001, 7, 27), BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO_USNY))); assertEquals(bp.getValue(), CurrencyAmount.of(USD, 15000)); }
public void termDeposit() { String location = "classpath:com/opengamma/strata/loader/fpml/td-ex01-simple-term-deposit.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), TermDepositTrade.class); TermDepositTrade tdTrade = (TermDepositTrade) trade; assertEquals(tdTrade.getInfo().getTradeDate(), Optional.of(date(2002, 2, 14))); TermDeposit td = tdTrade.getProduct(); assertEquals(td.getBuySell(), BUY); assertEquals(td.getStartDate(), date(2002, 2, 14)); assertEquals(td.getEndDate(), date(2002, 2, 15)); assertEquals(td.getCurrency(), CHF); assertEquals(td.getNotional(), 25000000d); assertEquals(td.getRate(), 0.04); assertEquals(td.getDayCount(), ACT_360); }
public void fra_wrapper2() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra-wrapper2.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertFra(trades, false); }
public void fra_wrapper_clearingStatus() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra-wrapper-clearing-status.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertFra(trades, false); }
public void fra() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertFra(trades, false); }
public void fra_namespace() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra-namespace.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertFra(trades, false); }
public void fra_interpolated() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra-interpolated.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertFra(trades, true); }
public void fra_wrapper1() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ex08-fra-wrapper1.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertFra(trades, false); }
public void fxSwap() { String location = "classpath:com/opengamma/strata/loader/fpml/fx-ex08-fx-swap.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), FxSwapTrade.class); FxSwapTrade fxTrade = (FxSwapTrade) trade; assertEquals(fxTrade.getInfo().getTradeDate(), Optional.of(date(2002, 1, 23))); FxSwap fx = fxTrade.getProduct(); FxSingle nearLeg = fx.getNearLeg(); assertEquals(nearLeg.getBaseCurrencyPayment(), Payment.of(GBP, 10000000, date(2002, 1, 25))); assertEquals(nearLeg.getCounterCurrencyPayment(), Payment.of(USD, -14800000, date(2002, 1, 25))); FxSingle farLeg = fx.getFarLeg(); assertEquals(farLeg.getBaseCurrencyPayment(), Payment.of(GBP, -10000000, date(2002, 2, 25))); assertEquals(farLeg.getCounterCurrencyPayment(), Payment.of(USD, 15000000, date(2002, 2, 25))); }
public void fxNdf() { String location = "classpath:com/opengamma/strata/loader/fpml/fx-ex07-non-deliverable-forward.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0); assertEquals(trade.getClass(), FxNdfTrade.class); FxNdfTrade fxTrade = (FxNdfTrade) trade; assertEquals(fxTrade.getInfo().getTradeDate(), Optional.of(date(2002, 1, 9))); FxNdf fx = fxTrade.getProduct(); assertEquals(fx.getSettlementCurrencyNotional(), CurrencyAmount.of(USD, 10000000)); assertEquals(fx.getAgreedFxRate(), FxRate.of(USD, INR, 43.4)); assertEquals(fx.getIndex(), ImmutableFxIndex.builder() .name("Reuters/RBIB/14:30") .currencyPair(CurrencyPair.of(USD, INR)) .fixingCalendar(USNY) .maturityDateOffset(DaysAdjustment.ofCalendarDays(-2)) .build()); assertEquals(fx.getPaymentDate(), date(2002, 4, 11)); }
public void cdsIndex01() { String location = "classpath:com/opengamma/strata/loader/fpml/cdindex-ex01-cdx.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertEquals(trades.size(), 1); CdsIndexTrade cdsTrade = (CdsIndexTrade) trades.get(0); assertEquals(cdsTrade.getInfo().getTradeDate(), Optional.of(date(2005, 1, 24))); CdsIndex expected = CdsIndex.builder() .buySell(BUY) .cdsIndexId(StandardId.of("CDX-Name", "Dow Jones CDX NA IG.2")) .currency(USD) .notional(25000000d) .paymentSchedule(PeriodicSchedule.builder() .startDate(date(2004, 3, 23)) .endDate(date(2009, 3, 20)) .startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .endDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .businessDayAdjustment(BusinessDayAdjustment.NONE) .frequency(Frequency.P3M) .build()) .fixedRate(0.0060) .dayCount(ACT_360) .build(); assertEqualsBean(cdsTrade.getProduct(), expected); assertEquals(cdsTrade.getUpfrontFee().get(), AdjustablePayment.of(USD, 16000, AdjustableDate.of(date(2004, 3, 23)))); }
public void cds02() { String location = "classpath:com/opengamma/strata/loader/fpml/cd-ex02-2003-short-asia-corp-fixreg.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertEquals(trades.size(), 1); CdsTrade cdsTrade = (CdsTrade) trades.get(0); assertEquals(cdsTrade.getInfo().getTradeDate(), Optional.of(date(2002, 12, 4))); Cds expected = Cds.builder() .buySell(SELL) .legalEntityId(StandardId.of("http://www.fpml.org/coding-scheme/external/entity-id-RED-1-0", "008FAQ")) .currency(JPY) .notional(500000000d) .paymentSchedule(PeriodicSchedule.builder() .startDate(date(2002, 12, 5)) .endDate(date(2007, 12, 5)) .startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .endDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .businessDayAdjustment(BusinessDayAdjustment.NONE) .firstRegularStartDate(date(2003, 3, 5)) .frequency(Frequency.P3M) .rollConvention(RollConventions.DAY_5) .build()) .fixedRate(0.007) .dayCount(ACT_360) .build(); assertEqualsBean(cdsTrade.getProduct(), expected); assertEquals(cdsTrade.getUpfrontFee().isPresent(), false); }
public void cds01() { String location = "classpath:com/opengamma/strata/loader/fpml/cd-ex01-long-asia-corp-fixreg.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertEquals(trades.size(), 1); CdsTrade cdsTrade = (CdsTrade) trades.get(0); assertEquals(cdsTrade.getInfo().getTradeDate(), Optional.of(date(2002, 12, 4))); Cds expected = Cds.builder() .buySell(BUY) .legalEntityId(StandardId.of("http://www.fpml.org/spec/2003/entity-id-RED-1-0", "004CC9")) .currency(JPY) .notional(500000000d) .paymentSchedule(PeriodicSchedule.builder() .startDate(date(2002, 12, 5)) .endDate(date(2007, 12, 5)) .startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .endDateBusinessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO_USNY_JPTO)) .businessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, GBLO_USNY_JPTO)) .firstRegularStartDate(date(2003, 3, 5)) .frequency(Frequency.P3M) .rollConvention(RollConventions.DAY_5) .build()) .fixedRate(0.007) .dayCount(ACT_360) .build(); assertEqualsBean(cdsTrade.getProduct(), expected); assertEquals(cdsTrade.getUpfrontFee().isPresent(), false); }
public void iborFloatingLegNoResetDates() { String location = "classpath:com/opengamma/strata/loader/fpml/ird-ibor-no-reset-dates.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0);
public void brlCdiSwap() { String location = "classpath:com/opengamma/strata/loader/fpml/brl-future-value-notional.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party1")).parseTrades(resource); assertEquals(trades.size(), 1); Trade trade = trades.get(0);