//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_extendedEnum(FraConvention convention, String name)
        public virtual void test_extendedEnum(FraConvention convention, string name)
        {
            FraConvention.of(name);     // ensures map is populated
            ImmutableMap <string, FraConvention> map = FraConvention.extendedEnum().lookupAll();

            assertEquals(map.get(name), convention);
        }
Exemple #2
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_createTrade_periods()
        {
            FraConvention @base     = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).build();
            LocalDate     tradeDate = LocalDate.of(2015, 5, 5);
            FraTrade      test      = @base.createTrade(tradeDate, Period.ofMonths(3), Period.ofMonths(6), 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_toTemplate_badDateOrder()
        {
            FraConvention @base       = FraConvention.of(GBP_LIBOR_3M);
            LocalDate     tradeDate   = LocalDate.of(2015, 5, 5);
            LocalDate     startDate   = date(2015, 4, 5);
            LocalDate     endDate     = date(2015, 7, 5);
            LocalDate     paymentDate = date(2015, 8, 7);

            assertThrowsIllegalArg(() => @base.toTrade(tradeDate, startDate, endDate, paymentDate, BUY, NOTIONAL_2M, 0.25d));
        }
Exemple #5
0
 private FraTemplate(Period periodToStart, Period periodToEnd, FraConvention convention)
 {
     JodaBeanUtils.notNull(periodToStart, "periodToStart");
     JodaBeanUtils.notNull(periodToEnd, "periodToEnd");
     JodaBeanUtils.notNull(convention, "convention");
     this.periodToStart = periodToStart;
     this.periodToEnd   = periodToEnd;
     this.convention    = convention;
     validate();
 }
        public virtual void test_createTrade_periods_adjust_payOffset()
        {
            FraConvention @base     = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).paymentDateOffset(PLUS_TWO_DAYS).build();
            LocalDate     tradeDate = LocalDate.of(2016, 8, 11);
            FraTrade      test      = @base.createTrade(tradeDate, Period.ofMonths(1), Period.ofMonths(4), BUY, NOTIONAL_2M, 0.25d, REF_DATA);
            Fra           expected  = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2016, 9, 12)).endDate(date(2016, 12, 12)).paymentDate(AdjustableDate.of(date(2016, 9, 14), PLUS_TWO_DAYS.Adjustment)).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);
        }
        public virtual void test_toTrade_dates_paymentOffset()
        {
            FraConvention @base       = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).paymentDateOffset(PLUS_TWO_DAYS).build();
            LocalDate     tradeDate   = LocalDate.of(2015, 5, 5);
            LocalDate     startDate   = date(2015, 8, 5);
            LocalDate     endDate     = date(2015, 11, 5);
            LocalDate     paymentDate = date(2015, 8, 7);
            FraTrade      test        = @base.toTrade(tradeDate, startDate, endDate, paymentDate, BUY, NOTIONAL_2M, 0.25d);
            Fra           expected    = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(paymentDate, PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build();

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
Exemple #9
0
        private static CurveNode curveFraCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            Matcher matcher = FRA_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (!matcher.matches())
            {
                throw new System.ArgumentException(Messages.format("Invalid time format for FRA: {}", timeStr));
            }
            Period periodToStart = Period.parse("P" + matcher.group(1) + "M");
            Period periodToEnd   = Period.parse("P" + matcher.group(2) + "M");

            FraConvention convention = FraConvention.of(conventionStr);
            FraTemplate   template   = FraTemplate.of(periodToStart, periodToEnd, convention);

            return(FraCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_index()
        {
            ImmutableFraConvention test = ImmutableFraConvention.of(GBP_LIBOR_3M);

            assertEquals(test.Index, GBP_LIBOR_3M);
            assertEquals(test.Name, GBP_LIBOR_3M.Name);
            assertEquals(test.Currency, GBP);
            assertEquals(test.SpotDateOffset, GBP_LIBOR_3M.EffectiveDateOffset);
            assertEquals(test.BusinessDayAdjustment, BDA_MOD_FOLLOW);
            assertEquals(test.PaymentDateOffset, DaysAdjustment.NONE);
            assertEquals(test.FixingDateOffset, GBP_LIBOR_3M.FixingDateOffset);
            assertEquals(test.DayCount, ACT_365F);
            assertEquals(test.Discounting, ISDA);
            // ensure other factories match
            assertEquals(FraConvention.of(GBP_LIBOR_3M), test);
            assertEquals(FraConventions.of(GBP_LIBOR_3M), test);
        }
Exemple #11
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -574688858:         // periodToStart
                    this.periodToStart_Renamed = (Period)newValue;
                    break;

                case -970442977:         // periodToEnd
                    this.periodToEnd_Renamed = (Period)newValue;
                    break;

                case 2039569265:         // convention
                    this.convention_Renamed = (FraConvention)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Exemple #12
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains a template based on the specified period and index.
 /// <para>
 /// The period from the spot date to the start date is specified.
 /// The period from the spot date to the end date will be the period to start
 /// plus the tenor of the index.
 /// </para>
 /// <para>
 /// For example, a '2 x 5' FRA has a period to the start date of 2 months.
 /// The index will be a 3 month index, such as 'USD-LIBOR-3M'.
 /// The period to the end date will be the period to the start date plus the index tenor.
 ///
 /// </para>
 /// </summary>
 /// <param name="periodToStart">  the period between the spot date and the start date </param>
 /// <param name="index">  the index that defines the market convention </param>
 /// <returns> the template </returns>
 public static FraTemplate of(Period periodToStart, IborIndex index)
 {
     return(of(periodToStart, periodToStart.plus(index.Tenor.Period), FraConvention.of(index)));
 }
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => FraConvention.of((string)null));
 }
 public virtual void test_of_lookup_notFound()
 {
     assertThrowsIllegalArg(() => FraConvention.of("Rubbish"));
 }
Exemple #15
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FraTemplate beanToCopy)
 {
     this.periodToStart_Renamed = beanToCopy.PeriodToStart;
     this.periodToEnd_Renamed   = beanToCopy.PeriodToEnd;
     this.convention_Renamed    = beanToCopy.Convention;
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_of_lookup(FraConvention convention, String name)
        public virtual void test_of_lookup(FraConvention convention, string name)
        {
            assertEquals(FraConvention.of(name), convention);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_toString(FraConvention convention, String name)
        public virtual void test_toString(FraConvention convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "name") public void test_name(FraConvention convention, String name)
        public virtual void test_name(FraConvention convention, string name)
        {
            assertEquals(convention.Name, name);
        }
 public virtual void test_unknownIndex()
 {
     assertThrowsIllegalArg(() => FraConvention.of("Rubbish"));
 }
Exemple #20
0
 /// <summary>
 /// Sets the underlying FRA convention.
 /// <para>
 /// This specifies the market convention of the FRA to be created.
 /// </para>
 /// </summary>
 /// <param name="convention">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder convention(FraConvention convention)
 {
     JodaBeanUtils.notNull(convention, "convention");
     this.convention_Renamed = convention;
     return(this);
 }
 /// <summary>
 /// Obtains a convention based on the specified index.
 /// <para>
 /// This uses the index name to find the matching convention.
 /// By default, this will always return a convention, however configuration may be added
 /// to restrict the conventions that are registered.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the index, from which the index name is used to find the matching convention </param>
 /// <returns> the convention </returns>
 /// <exception cref="IllegalArgumentException"> if no convention is registered for the index </exception>
 public static FraConvention of(IborIndex index)
 {
     return(FraConvention.of(index));
 }
        //-------------------------------------------------------------------------
        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);
        }