public virtual void test_of_near_far() { FxSwapTemplate test = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); assertEquals(test.PeriodToNear, NEAR_PERIOD); assertEquals(test.PeriodToFar, FAR_PERIOD); assertEquals(test.Convention, CONVENTION); assertEquals(test.CurrencyPair, EUR_USD); }
//------------------------------------------------------------------------- public virtual void coverage() { FxSwapTemplate test = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); coverImmutableBean(test); FxSwapTemplate test2 = FxSwapTemplate.of(Period.ofMonths(4), Period.ofMonths(7), CONVENTION2); coverBeanEquals(test, test2); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { FxSwapTemplate other = (FxSwapTemplate)obj; return(JodaBeanUtils.equal(periodToNear, other.periodToNear) && JodaBeanUtils.equal(periodToFar, other.periodToFar) && JodaBeanUtils.equal(convention, other.convention)); } return(false); }
//------------------------------------------------------------------------- public virtual void test_createTrade() { FxSwapTemplate @base = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); LocalDate tradeDate = LocalDate.of(2015, 10, 29); FxSwapTrade test = @base.createTrade(tradeDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS, REF_DATA); LocalDate spotDate = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA); LocalDate nearDate = spotDate.plus(NEAR_PERIOD); LocalDate farDate = spotDate.plus(FAR_PERIOD); BusinessDayAdjustment bda = CONVENTION.BusinessDayAdjustment; FxSwap expected = FxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, bda); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
//------------------------------------------------------------------------- /// <summary> /// Obtains a template based on the specified period and convention. /// <para> /// The near date is equal to the spot date. /// The period from the spot date to the far date is specified /// </para> /// <para> /// For example, a '6M' FX swap has a near leg on the spot date and a period from spot to the far date of 6 months /// /// </para> /// </summary> /// <param name="periodToFar"> the period between the spot date and the far date </param> /// <param name="convention"> the market convention </param> /// <returns> the template </returns> public static FxSwapTemplate of(Period periodToFar, FxSwapConvention convention) { return(FxSwapTemplate.builder().periodToNear(Period.ZERO).periodToFar(periodToFar).convention(convention).build()); }
public virtual void test_builder_insufficientInfo() { assertThrowsIllegalArg(() => FxSwapTemplate.builder().convention(CONVENTION).build()); assertThrowsIllegalArg(() => FxSwapTemplate.builder().periodToNear(NEAR_PERIOD).build()); assertThrowsIllegalArg(() => FxSwapTemplate.builder().periodToFar(FAR_PERIOD).build()); }
public virtual void test_serialization() { FxSwapTemplate test = FxSwapTemplate.of(NEAR_PERIOD, FAR_PERIOD, CONVENTION); assertSerialization(test); }