/** * Returns a copy of this payment with the value negated. * <p> * This takes this payment and negates it. * <p> * This instance is immutable and unaffected by this method. * * @return a payment based on this with the value negated */ public AdjustablePayment negated() { return AdjustablePayment.of(value.negated(), date); }
public void test_negated() { AdjustablePayment test = AdjustablePayment.ofReceive(GBP_P1000, DATE_2015_06_30); assertEquals(test.negated(), AdjustablePayment.of(GBP_M1000, DATE_2015_06_30)); }
/** * Obtains an instance of a Swaption trade with a fixed payment. * * @param info the trade info * @param product the product * @param premium the premium * @return the trade */ public static SwaptionTrade of(TradeInfo info, Swaption product, Payment premium) { return new SwaptionTrade(info, product, AdjustablePayment.of(premium)); }
/** * Obtains an instance based on a {@code Payment}. * * @param payment the fixed payment * @return the adjustable payment instance */ public static AdjustablePayment of(Payment payment) { return of(payment.getValue(), payment.getDate()); }
public void test_serialization() { AdjustablePayment test = AdjustablePayment.of(GBP_P1000, DATE_2015_06_30); assertSerialization(test); }
private AdjustablePayment parsePremium(XmlElement swaptionEl, FpmlDocument document, TradeInfoBuilder tradeInfoBuilder) { XmlElement premiumEl = swaptionEl.getChild("premium"); PayReceive payReceive = document.parsePayerReceiver(premiumEl, tradeInfoBuilder); XmlElement paymentAmountEl = premiumEl.getChild("paymentAmount"); CurrencyAmount ccyAmount = document.parseCurrencyAmount(paymentAmountEl); ccyAmount = payReceive.isPay() ? ccyAmount.negated() : ccyAmount; AdjustableDate paymentDate = premiumEl.findChild("paymentDate") .map(el -> document.parseAdjustableDate(el)).get(); return AdjustablePayment.of(ccyAmount, paymentDate); }
static SwaptionTrade sut2() { return SwaptionTrade.builder() .premium(AdjustablePayment.of(CurrencyAmount.of(Currency.USD, -3050000d), LocalDate.of(2014, 3, 17))) .product(SwaptionTest.sut2()) .build(); }
static FxVanillaOptionTrade sut2() { AdjustablePayment premium = AdjustablePayment.of(CurrencyAmount.of(EUR, NOTIONAL * 0.01), date(2014, 11, 13)); return FxVanillaOptionTrade.builder() .product(PRODUCT2) .premium(premium) .build(); }
public void test_createTrade_withFee() { DatesCdsTemplate base = DatesCdsTemplate.of(START, END, CONV1); LocalDate tradeDate = LocalDate.of(2015, 5, 5); AdjustablePayment payment = AdjustablePayment.of(EUR, NOTIONAL_2M, CONV1.getSettlementDateOffset().adjust(tradeDate, REF_DATA)); CdsTrade test = base.createTrade(LEGAL_ENTITY, tradeDate, BUY, NOTIONAL_2M, 0.05d, payment, REF_DATA); Cds expected = Cds.of(BUY, LEGAL_ENTITY, CONV1.getCurrency(), NOTIONAL_2M, START, END, Frequency.P3M, CONV1.getSettlementDateOffset().getCalendar(), 0.05d); PeriodicSchedule sch1 = expected.getPaymentSchedule(); expected = expected.toBuilder() .paymentSchedule(sch1.toBuilder() .startDateBusinessDayAdjustment(sch1.getBusinessDayAdjustment()) .rollConvention(RollConventions.DAY_20) .build()) .build(); assertEquals(test.getInfo().getTradeDate(), Optional.of(tradeDate)); assertEquals(test.getUpfrontFee(), Optional.of(payment)); assertEquals(test.getProduct(), expected); }
public void coverage() { FxSingleBarrierOptionTrade test1 = sut(); FxSingleBarrierOptionTrade test2 = FxSingleBarrierOptionTrade.builder() .product(FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER)) .premium(AdjustablePayment.of(CurrencyAmount.of(EUR, NOTIONAL * 0.01), date(2014, 11, 13))) .build(); coverImmutableBean(test1); coverBeanEquals(test1, test2); }
public void test_positive_notional() { assertThrows(() -> Bill.builder() .dayCount(DAY_COUNT) .legalEntityId(LEGAL_ENTITY) .notional(AdjustablePayment.of(CurrencyAmount.of(CCY, -10), MATURITY_DATE_ADJ)) .securityId(SECURITY_ID) .settlementDateOffset(SETTLE) .yieldConvention(YIELD_CONVENTION).build()); }
LocalDate tradeDate = LocalDate.of(2015, 5, 5); AdjustablePayment payment1 = AdjustablePayment.of(EUR, NOTIONAL_2M, CONV1.getSettlementDateOffset().adjust(tradeDate, REF_DATA)); AdjustablePayment payment2 = AdjustablePayment.of(USD, NOTIONAL_2M, CONV2.getSettlementDateOffset().adjust(tradeDate, REF_DATA)); LocalDate startDate1 = date(2015, 3, 20); LocalDate endDate1 = date(2025, 6, 20);
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)))); }
assertEquals(test4, expected); AdjustablePayment upfront = AdjustablePayment.of(CurrencyAmount.of(GBP, 0.1 * NOTIONAL), settlementDate); CdsTrade expectedWithUf = CdsTrade.builder() .info(info)
public void coverage() { BillSecurity test1 = BillSecurity.builder() .dayCount(DAY_COUNT) .info(INFO) .legalEntityId(LEGAL_ENTITY) .notional(NOTIONAL) .settlementDateOffset(SETTLE) .yieldConvention(YIELD_CONVENTION) .build(); coverImmutableBean(test1); BillSecurity test2 = BillSecurity.builder() .dayCount(DayCounts.ACT_365F) .info(SecurityInfo.of(SecurityId.of("OG-Test", "ID2"), PRICE_INFO)) .legalEntityId(LegalEntityId.of("OG-Ticker", "LE2")) .notional(AdjustablePayment.of(CurrencyAmount.of(CCY, 10), MATURITY_DATE_ADJ)) .settlementDateOffset(DaysAdjustment.ofBusinessDays(2, EUTA, BUSINESS_ADJUST)) .yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY) .build(); coverBeanEquals(test1, test2); }