Beispiel #1
0
 /// <summary>
 /// Obtains a template based on the specified periods and convention.
 /// <para>
 /// The periods from the spot date to the start date and to the end date are specified.
 /// </para>
 /// <para>
 /// For example, a '2 x 5' FRA has a period to the start date of 2 months and
 /// a period to the end date of 5 months.
 ///
 /// </para>
 /// </summary>
 /// <param name="periodToStart">  the period between the spot date and the start date </param>
 /// <param name="periodToEnd">  the period between the spot date and the end date </param>
 /// <param name="convention">  the market convention </param>
 /// <returns> the template </returns>
 public static FraTemplate of(Period periodToStart, Period periodToEnd, FraConvention convention)
 {
     ArgChecker.notNull(periodToStart, "periodToStart");
     ArgChecker.notNull(periodToEnd, "periodToEnd");
     ArgChecker.notNull(convention, "convention");
     return(FraTemplate.builder().periodToStart(periodToStart).periodToEnd(periodToEnd).convention(convention).build());
 }
        public virtual void test_builder_defaults()
        {
            FraTemplate test = FraTemplate.builder().periodToStart(Period.ofMonths(2)).convention(FRA_GBP_LIBOR_3M).build();

            assertEquals(test.PeriodToStart, Period.ofMonths(2));
            assertEquals(test.PeriodToEnd, Period.ofMonths(5));     // defaulted
            assertEquals(test.Convention, FRA_GBP_LIBOR_3M);
        }
        public virtual void test_of_PeriodPeriodConvention()
        {
            FraTemplate test = FraTemplate.of(Period.ofMonths(2), Period.ofMonths(4), FRA_GBP_LIBOR_3M);

            assertEquals(test.PeriodToStart, Period.ofMonths(2));
            assertEquals(test.PeriodToEnd, Period.ofMonths(4));
            assertEquals(test.Convention, FRA_GBP_LIBOR_3M);
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_PeriodIndex()
        {
            FraTemplate test = FraTemplate.of(Period.ofMonths(2), GBP_LIBOR_3M);

            assertEquals(test.PeriodToStart, Period.ofMonths(2));
            assertEquals(test.PeriodToEnd, Period.ofMonths(5));     // defaulted
            assertEquals(test.Convention, FRA_GBP_LIBOR_3M);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FraTemplate test = FraTemplate.of(Period.ofMonths(2), GBP_LIBOR_3M);

            coverImmutableBean(test);
            FraTemplate test2 = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), FraConvention.of(USD_LIBOR_3M));

            coverBeanEquals(test, test2);
        }
        //-------------------------------------------------------------------------
        public virtual void test_createTrade()
        {
            FraTemplate @base     = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), FRA_GBP_LIBOR_3M);
            LocalDate   tradeDate = LocalDate.of(2015, 5, 4);   // trade date is a holiday!
            FraTrade    test      = @base.createTrade(tradeDate, BUY, NOTIONAL_2M, 0.25d, REF_DATA);
            Fra         expected  = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).fixedRate(0.25d).index(GBP_LIBOR_3M).build();

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
        public virtual void test_createTrade_paymentOffset()
        {
            FraConvention convention = ((ImmutableFraConvention)FRA_GBP_LIBOR_3M).toBuilder().paymentDateOffset(PLUS_TWO_DAYS).build();
            FraTemplate   @base      = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), convention);
            LocalDate     tradeDate  = LocalDate.of(2015, 5, 4); // trade date is a holiday!
            FraTrade      test       = @base.createTrade(tradeDate, BUY, NOTIONAL_2M, 0.25d, REF_DATA);
            Fra           expected   = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(date(2015, 8, 7), PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build();

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
Beispiel #8
0
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FraTemplate other = (FraTemplate)obj;
         return(JodaBeanUtils.equal(periodToStart, other.periodToStart) && JodaBeanUtils.equal(periodToEnd, other.periodToEnd) && JodaBeanUtils.equal(convention, other.convention));
     }
     return(false);
 }
 public virtual void test_builder_insufficientInfo()
 {
     assertThrowsIllegalArg(() => FraTemplate.builder().convention(FRA_GBP_LIBOR_3M).build());
     assertThrowsIllegalArg(() => FraTemplate.builder().periodToStart(Period.ofMonths(2)).build());
 }
        public virtual void test_serialization()
        {
            FraTemplate test = FraTemplate.of(Period.ofMonths(2), GBP_LIBOR_3M);

            assertSerialization(test);
        }