//------------------------------------------------------------------------- public virtual void test_builder() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.builder().currencyPair(EUR_USD).name("EUR::USD").spotDateOffset(PLUS_TWO_DAYS).businessDayAdjustment(BDA_FOLLOW).build(); assertEquals(test.Name, "EUR::USD"); assertEquals(test.CurrencyPair, EUR_USD); assertEquals(test.SpotDateOffset, PLUS_TWO_DAYS); assertEquals(test.BusinessDayAdjustment, BDA_FOLLOW); }
public virtual void test_toTemplate_badDateOrder() { ImmutableFxSwapConvention @base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate nearDate = date(2015, 4, 5); LocalDate farDate = date(2015, 7, 5); assertThrowsIllegalArg(() => @base.toTrade(tradeDate, nearDate, farDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS)); }
//------------------------------------------------------------------------- public virtual void test_of_bda() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); assertEquals(test.Name, EUR_USD.ToString()); assertEquals(test.CurrencyPair, EUR_USD); assertEquals(test.SpotDateOffset, PLUS_TWO_DAYS); assertEquals(test.BusinessDayAdjustment, BDA_FOLLOW); }
//------------------------------------------------------------------------- public virtual void coverage() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); coverImmutableBean(test); ImmutableFxSwapConvention test2 = ImmutableFxSwapConvention.builder().name("GBP/USD").currencyPair(GBP_USD).spotDateOffset(PLUS_ONE_DAY).businessDayAdjustment(BDA_MODFOLLOW).build(); coverBeanEquals(test, test2); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { ImmutableFxSwapConvention other = (ImmutableFxSwapConvention)obj; return(JodaBeanUtils.equal(currencyPair, other.currencyPair) && JodaBeanUtils.equal(name, other.name) && JodaBeanUtils.equal(spotDateOffset, other.spotDateOffset) && JodaBeanUtils.equal(businessDayAdjustment, other.businessDayAdjustment)); } return(false); }
//------------------------------------------------------------------------- public virtual void test_toTrade_periods() { ImmutableFxSwapConvention @base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); Period startPeriod = Period.ofMonths(3); Period endPeriod = Period.ofMonths(6); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate spotDate = PLUS_TWO_DAYS.adjust(tradeDate, REF_DATA); LocalDate nearDate = spotDate.plus(startPeriod); LocalDate farDate = spotDate.plus(endPeriod); FxSwapTrade test = @base.createTrade(tradeDate, startPeriod, endPeriod, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS, REF_DATA); FxSwap expected = FxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, BDA_FOLLOW); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); }
public virtual void test_toTrade_dates() { ImmutableFxSwapConvention @base = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); LocalDate tradeDate = LocalDate.of(2015, 5, 5); LocalDate nearDate = LocalDate.of(2015, 7, 5); LocalDate nearDateAdj = LocalDate.of(2015, 7, 6); // Adjusted: 5 is Sunday LocalDate farDate = LocalDate.of(2015, 9, 5); LocalDate farDateAdj = LocalDate.of(2015, 9, 7); // Adjusted: 5 is Saturday FxSwapTrade test = @base.toTrade(tradeDate, nearDate, farDate, BUY, NOTIONAL_EUR, FX_RATE_NEAR, FX_RATE_PTS); FxSwap expected = FxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), FxRate.of(EUR, USD, FX_RATE_NEAR), FX_RATE_PTS, nearDate, farDate, BDA_FOLLOW); assertEquals(test.Info.TradeDate, tradeDate); assertEquals(test.Product, expected); ResolvedFxSwap resolvedExpected = ResolvedFxSwap.ofForwardPoints(CurrencyAmount.of(EUR, NOTIONAL_EUR), USD, FX_RATE_NEAR, FX_RATE_PTS, nearDateAdj, farDateAdj); assertEquals(test.Product.resolve(REF_DATA), resolvedExpected); }
/// <summary> /// Obtains a convention based on the specified currency pair, spot date offset and adjustment. /// <para> /// Use the <seealso cref="#builder() builder"/> for unusual conventions. /// /// </para> /// </summary> /// <param name="currencyPair"> the currency pair associated to the convention </param> /// <param name="spotDateOffset"> the spot date offset </param> /// <param name="businessDayAdjustment"> the business day adjustment to apply </param> /// <returns> the convention </returns> public static ImmutableFxSwapConvention of(CurrencyPair currencyPair, DaysAdjustment spotDateOffset, BusinessDayAdjustment businessDayAdjustment) { ArgChecker.notNull(businessDayAdjustment, "businessDayAdjustment"); return(ImmutableFxSwapConvention.builder().currencyPair(currencyPair).spotDateOffset(spotDateOffset).businessDayAdjustment(businessDayAdjustment).build()); }
//------------------------------------------------------------------------- /// <summary> /// Obtains a convention based on the specified currency pair and spot date offset. /// <para> /// Use the <seealso cref="#builder() builder"/> for unusual conventions. /// /// </para> /// </summary> /// <param name="currencyPair"> the currency pair associated to the convention </param> /// <param name="spotDateOffset"> the spot date offset </param> /// <returns> the convention </returns> public static ImmutableFxSwapConvention of(CurrencyPair currencyPair, DaysAdjustment spotDateOffset) { return(ImmutableFxSwapConvention.builder().currencyPair(currencyPair).spotDateOffset(spotDateOffset).build()); }
public virtual void test_serialization() { ImmutableFxSwapConvention test = ImmutableFxSwapConvention.of(EUR_USD, PLUS_TWO_DAYS, BDA_FOLLOW); assertSerialization(test); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "calendar") public void test_calendar(ImmutableFxSwapConvention convention, com.opengamma.strata.basics.date.HolidayCalendarId cal) public virtual void test_calendar(ImmutableFxSwapConvention convention, HolidayCalendarId cal) { assertEquals(convention.SpotDateOffset.Calendar, cal); assertEquals(convention.BusinessDayAdjustment.Calendar, cal); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "currencyPair") public void test_currency_pair(ImmutableFxSwapConvention convention, com.opengamma.strata.basics.currency.CurrencyPair ccys) public virtual void test_currency_pair(ImmutableFxSwapConvention convention, CurrencyPair ccys) { assertEquals(convention.CurrencyPair, ccys); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "spotLag") public void test_spot_lag(ImmutableFxSwapConvention convention, int lag) public virtual void test_spot_lag(ImmutableFxSwapConvention convention, int lag) { assertEquals(convention.SpotDateOffset.Days, lag); }