//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(FixedOvernightSwapConvention convention, String name)
        public virtual void test_extendedEnum(FixedOvernightSwapConvention convention, string name)
        {
            FixedOvernightSwapConvention.of(name);     // ensures map is populated
            ImmutableMap <string, FixedOvernightSwapConvention> map = FixedOvernightSwapConvention.extendedEnum().lookupAll();

            assertEquals(map.get(name), convention);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "stubOn") public void test_stub_overnight(FixedOvernightSwapConvention convention, com.opengamma.strata.basics.date.Tenor tenor)
        public virtual void test_stub_overnight(FixedOvernightSwapConvention convention, Tenor tenor)
        {
            LocalDate    tradeDate    = LocalDate.of(2015, 10, 20);
            SwapTrade    swap         = convention.createTrade(tradeDate, tenor, BuySell.BUY, 1, 0.01, REF_DATA);
            ResolvedSwap swapResolved = swap.Product.resolve(REF_DATA);
            LocalDate    endDate      = swapResolved.getLeg(PayReceive.PAY).get().EndDate;

            assertTrue(endDate.isAfter(tradeDate.plus(tenor).minusMonths(1)));
            assertTrue(endDate.isBefore(tradeDate.plus(tenor).plusMonths(1)));
        }
 private FixedOvernightSwapTemplate(Period periodToStart, Tenor tenor, FixedOvernightSwapConvention convention)
 {
     JodaBeanUtils.notNull(periodToStart, "periodToStart");
     JodaBeanUtils.notNull(tenor, "tenor");
     JodaBeanUtils.notNull(convention, "convention");
     this.periodToStart = periodToStart;
     this.tenor         = tenor;
     this.convention    = convention;
     validate();
 }
        public virtual void test_toTrade_periodTenor()
        {
            FixedOvernightSwapConvention @base = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);
            LocalDate tradeDate = LocalDate.of(2015, 5, 5);
            LocalDate startDate = date(2015, 8, 7);
            LocalDate endDate   = date(2025, 8, 7);
            SwapTrade test      = @base.createTrade(tradeDate, Period.ofMonths(3), TENOR_10Y, BUY, NOTIONAL_2M, 0.25d, REF_DATA);
            Swap      expected  = Swap.of(FIXED.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d), FFUND_LEG.toLeg(startDate, endDate, RECEIVE, NOTIONAL_2M));

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
        public virtual void test_toTrade_dates()
        {
            FixedOvernightSwapConvention @base = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);
            LocalDate tradeDate = LocalDate.of(2015, 5, 5);
            LocalDate startDate = date(2015, 8, 5);
            LocalDate endDate   = date(2015, 11, 5);
            SwapTrade test      = @base.toTrade(tradeDate, startDate, endDate, BUY, NOTIONAL_2M, 0.25d);
            Swap      expected  = Swap.of(FIXED.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d), FFUND_LEG.toLeg(startDate, endDate, RECEIVE, NOTIONAL_2M));

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

            if (!matcher.matches())
            {
                throw new System.ArgumentException(Messages.format("Invalid time format for Fixed-Overnight swap: {}", timeStr));
            }
            Period periodToEnd = Period.parse("P" + matcher.group(1));
            FixedOvernightSwapConvention convention = FixedOvernightSwapConvention.of(conventionStr);
            FixedOvernightSwapTemplate   template   = FixedOvernightSwapTemplate.of(Tenor.of(periodToEnd), convention);

            return(FixedOvernightSwapCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
        }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -574688858:         // periodToStart
                    this.periodToStart_Renamed = (Period)newValue;
                    break;

                case 110246592:         // tenor
                    this.tenor_Renamed = (Tenor)newValue;
                    break;

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

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
 public virtual void test_of_lookup_notFound()
 {
     assertThrowsIllegalArg(() => FixedOvernightSwapConvention.of("Rubbish"));
 }
//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(FixedOvernightSwapConvention convention, String name)
        public virtual void test_of_lookup(FixedOvernightSwapConvention convention, string name)
        {
            assertEquals(FixedOvernightSwapConvention.of(name), convention);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "dayConvention") public void test_day_convention(FixedOvernightSwapConvention convention, com.opengamma.strata.basics.date.BusinessDayConvention dayConvention)
        public virtual void test_day_convention(FixedOvernightSwapConvention convention, BusinessDayConvention dayConvention)
        {
            assertEquals(convention.FixedLeg.AccrualBusinessDayAdjustment.Convention, dayConvention);
        }
//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(FixedOvernightSwapConvention convention, String name)
        public virtual void test_name(FixedOvernightSwapConvention convention, string name)
        {
            assertEquals(convention.Name, 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_toString(FixedOvernightSwapConvention convention, String name)
        public virtual void test_toString(FixedOvernightSwapConvention 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 = "period") public void test_paymentPeriod(FixedOvernightSwapConvention convention, com.opengamma.strata.basics.schedule.Frequency frequency)
        public virtual void test_paymentPeriod(FixedOvernightSwapConvention convention, Frequency frequency)
        {
            assertEquals(convention.FixedLeg.PaymentFrequency, frequency);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "period") public void test_accrualPeriod(FixedOvernightSwapConvention convention, com.opengamma.strata.basics.schedule.Frequency frequency)
        public virtual void test_accrualPeriod(FixedOvernightSwapConvention convention, Frequency frequency)
        {
            assertEquals(convention.FixedLeg.AccrualFrequency, frequency);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains a template based on the specified tenor and convention.
 /// <para>
 /// The swap will start on the spot date.
 ///
 /// </para>
 /// </summary>
 /// <param name="tenor">  the tenor of the swap </param>
 /// <param name="convention">  the market convention </param>
 /// <returns> the template </returns>
 public static FixedOvernightSwapTemplate of(Tenor tenor, FixedOvernightSwapConvention convention)
 {
     return(of(Period.ZERO, tenor, convention));
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "floatLeg") public void test_float_leg(FixedOvernightSwapConvention convention, com.opengamma.strata.basics.index.OvernightIndex floatLeg)
        public virtual void test_float_leg(FixedOvernightSwapConvention convention, OvernightIndex floatLeg)
        {
            assertEquals(convention.FloatingLeg.Index, floatLeg);
        }
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => FixedOvernightSwapConvention.of((string)null));
 }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(FixedOvernightSwapTemplate beanToCopy)
 {
     this.periodToStart_Renamed = beanToCopy.PeriodToStart;
     this.tenor_Renamed         = beanToCopy.Tenor;
     this.convention_Renamed    = beanToCopy.Convention;
 }
 /// <summary>
 /// Obtains a template based on the specified period, tenor and convention.
 /// <para>
 /// The period from the spot date to the start date is specified.
 ///
 /// </para>
 /// </summary>
 /// <param name="periodToStart">  the period between the spot date and the start date </param>
 /// <param name="tenor">  the tenor of the swap </param>
 /// <param name="convention">  the market convention </param>
 /// <returns> the template </returns>
 public static FixedOvernightSwapTemplate of(Period periodToStart, Tenor tenor, FixedOvernightSwapConvention convention)
 {
     return(FixedOvernightSwapTemplate.builder().periodToStart(periodToStart).tenor(tenor).convention(convention).build());
 }
 /// <summary>
 /// Sets the market convention of the swap. </summary>
 /// <param name="convention">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder convention(FixedOvernightSwapConvention convention)
 {
     JodaBeanUtils.notNull(convention, "convention");
     this.convention_Renamed = convention;
     return(this);
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "dayCount") public void test_day_count(FixedOvernightSwapConvention convention, com.opengamma.strata.basics.date.DayCount dayCount)
        public virtual void test_day_count(FixedOvernightSwapConvention convention, DayCount dayCount)
        {
            assertEquals(convention.FixedLeg.DayCount, dayCount);
        }