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

            assertEquals(map.get(name), convention);
        }
 private AbsoluteIborFutureTemplate(YearMonth yearMonth, IborFutureConvention convention)
 {
     JodaBeanUtils.notNull(yearMonth, "yearMonth");
     JodaBeanUtils.notNull(convention, "convention");
     this.yearMonth  = yearMonth;
     this.convention = convention;
 }
Ejemplo n.º 3
0
 private RelativeIborFutureTemplate(Period minimumPeriod, int sequenceNumber, IborFutureConvention convention)
 {
     JodaBeanUtils.notNull(minimumPeriod, "minimumPeriod");
     ArgChecker.notNegativeOrZero(sequenceNumber, "sequenceNumber");
     JodaBeanUtils.notNull(convention, "convention");
     this.minimumPeriod  = minimumPeriod;
     this.sequenceNumber = sequenceNumber;
     this.convention     = convention;
 }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -496678845:         // yearMonth
                    this.yearMonth = (YearMonth)newValue;
                    break;

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

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Ejemplo n.º 5
0
        public virtual void test_toTrade()
        {
            LocalDate            date       = LocalDate.of(2015, 10, 20);
            Period               start      = Period.ofMonths(2);
            int                  number     = 2; // Future should be 20 Dec 15 + 2 IMM = effective 15-Jun-2016, fixing 13-Jun-2016
            IborFutureConvention convention = ImmutableIborFutureConvention.of(USD_LIBOR_3M, QUARTERLY_IMM);
            double               quantity   = 3;
            double               price      = 0.99;
            SecurityId           secId      = SecurityId.of("OG-Future", "GBP-LIBOR-3M-Jun16");
            IborFutureTrade      trade      = convention.createTrade(date, secId, start, number, quantity, NOTIONAL_1M, price, REF_DATA);

            assertEquals(trade.Product.FixingDate, LocalDate.of(2016, 6, 13));
            assertEquals(trade.Product.Index, USD_LIBOR_3M);
            assertEquals(trade.Product.Notional, NOTIONAL_1M);
            assertEquals(trade.Product.AccrualFactor, 0.25);
            assertEquals(trade.Quantity, quantity);
            assertEquals(trade.Price, price);
        }
Ejemplo n.º 6
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -1855508625:         // minimumPeriod
                    this.minimumPeriod = (Period)newValue;
                    break;

                case -1353995670:         // sequenceNumber
                    this.sequenceNumber = (int?)newValue.Value;
                    break;

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

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
Ejemplo n.º 7
0
        private static CurveNode curveIborFutureCurveNode(string conventionStr, string timeStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            Matcher matcher = FUT_TIME_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (matcher.matches())
            {
                Period periodToStart            = Period.parse("P" + matcher.group(1));
                int    sequenceNumber           = int.Parse(matcher.group(2));
                IborFutureConvention convention = IborFutureConvention.of(conventionStr);
                IborFutureTemplate   template   = IborFutureTemplate.of(periodToStart, sequenceNumber, convention);
                return(IborFutureCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
            }
            Matcher matcher2 = FUT_MONTH_REGEX.matcher(timeStr.ToUpper(Locale.ENGLISH));

            if (matcher2.matches())
            {
                YearMonth            yearMonth  = YearMonth.parse(matcher2.group(1), YM_FORMATTER);
                IborFutureConvention convention = IborFutureConvention.of(conventionStr);
                IborFutureTemplate   template   = IborFutureTemplate.of(yearMonth, convention);
                return(IborFutureCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
            }
            throw new System.ArgumentException(Messages.format("Invalid time format for Ibor Future: {}", timeStr));
        }
Ejemplo n.º 8
0
        public virtual void test_serialization()
        {
            IborFutureConvention test = ImmutableIborFutureConvention.of(USD_LIBOR_3M, QUARTERLY_IMM);

            assertSerialization(test);
        }
Ejemplo n.º 9
0
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => IborFutureConvention.of((string)null));
 }
Ejemplo n.º 10
0
 public virtual void test_of_lookup_notFound()
 {
     assertThrowsIllegalArg(() => IborFutureConvention.of("Rubbish"));
 }
Ejemplo n.º 11
0
//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(IborFutureConvention convention, String name)
        public virtual void test_of_lookup(IborFutureConvention convention, string name)
        {
            assertEquals(IborFutureConvention.of(name), convention);
        }
Ejemplo n.º 12
0
//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(IborFutureConvention convention, String name)
        public virtual void test_toString(IborFutureConvention convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }
Ejemplo n.º 13
0
//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(IborFutureConvention convention, String name)
        public virtual void test_name(IborFutureConvention convention, string name)
        {
            assertEquals(convention.Name, name);
        }
        static CalibrationZeroRateUsd2OisFuturesHWIrsTest()
        {
            DSC_NAMES[DSCON_CURVE_NAME] = USD;
            ISet <Index> usdFedFundSet = new HashSet <Index>();

            usdFedFundSet.Add(USD_FED_FUND);
            IDX_NAMES[DSCON_CURVE_NAME] = usdFedFundSet;
            ISet <Index> usdLibor3Set = new HashSet <Index>();

            usdLibor3Set.Add(USD_LIBOR_3M);
            IDX_NAMES[FWD3_CURVE_NAME] = usdLibor3Set;
            for (int i = 0; i < DSC_NB_DEPO_NODES; i++)
            {
                BusinessDayAdjustment bda        = BusinessDayAdjustment.of(FOLLOWING, USNY);
                TermDepositConvention convention = ImmutableTermDepositConvention.of("USD-Dep", USD, bda, ACT_360, DaysAdjustment.ofBusinessDays(DSC_DEPO_OFFSET[i], USNY));
                DSC_NODES[i] = TermDepositCurveNode.of(TermDepositTemplate.of(Period.ofDays(1), convention), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])));
            }
            for (int i = 0; i < DSC_NB_OIS_NODES; i++)
            {
                DSC_NODES[DSC_NB_DEPO_NODES + i] = FixedOvernightSwapCurveNode.of(FixedOvernightSwapTemplate.of(Period.ZERO, Tenor.of(DSC_OIS_TENORS[i]), USD_FIXED_1Y_FED_FUND_OIS), QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[DSC_NB_DEPO_NODES + i])));
            }
            FWD3_NODES[0] = IborFixingDepositCurveNode.of(IborFixingDepositTemplate.of(USD_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[0])));
            IborFutureConvention convention = ImmutableIborFutureConvention.of(USD_LIBOR_3M, DateSequences.QUARTERLY_IMM);

            for (int i = 0; i < FWD3_NB_FUT_NODES; i++)
            {
                IborFutureTemplate template = IborFutureTemplate.of(Period.ofDays(7), FWD3_FUT_SEQ[i], convention);
                FWD3_NODES[i + 1] = IborFutureCurveNode.of(template, QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i + 1])));
            }
            for (int i = 0; i < FWD3_NB_IRS_NODES; i++)
            {
                FWD3_NODES[i + 1 + FWD3_NB_FUT_NODES] = FixedIborSwapCurveNode.of(FixedIborSwapTemplate.of(Period.ZERO, Tenor.of(FWD3_IRS_TENORS[i]), USD_FIXED_6M_LIBOR_3M), QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i + 1 + FWD3_NB_FUT_NODES])));
            }
            ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(VAL_DATE);

            for (int i = 0; i < DSC_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, DSC_ID_VALUE[i])), DSC_MARKET_QUOTES[i]);
            }
            for (int i = 0; i < FWD3_NB_NODES; i++)
            {
                builder.addValue(QuoteId.of(StandardId.of(SCHEME, FWD3_ID_VALUE[i])), FWD3_MARKET_QUOTES[i]);
            }
            ALL_QUOTES = builder.build();
            IList <CurveNode[]> groupDsc = new List <CurveNode[]>();

            groupDsc.Add(DSC_NODES);
            CURVES_NODES.Add(groupDsc);
            IList <CurveNode[]> groupFwd3 = new List <CurveNode[]>();

            groupFwd3.Add(FWD3_NODES);
            CURVES_NODES.Add(groupFwd3);
            IList <CurveMetadata> groupDsc = new List <CurveMetadata>();

            groupDsc.Add(DefaultCurveMetadata.builder().curveName(DSCON_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).build());
            CURVES_METADATA.Add(groupDsc);
            IList <CurveMetadata> groupFwd3 = new List <CurveMetadata>();

            groupFwd3.Add(DefaultCurveMetadata.builder().curveName(FWD3_CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(CURVE_DC).build());
            CURVES_METADATA.Add(groupFwd3);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains a template based on the specified convention.
 /// <para>
 /// The future is selected from a sequence of futures based on a year-month.
 /// In most cases, the date of the future will be in the same month as the specified month,
 /// but this is not guaranteed.
 ///
 /// </para>
 /// </summary>
 /// <param name="yearMonth">  the year-month to use to select the future </param>
 /// <param name="convention">  the future convention </param>
 /// <returns> the template </returns>
 public static AbsoluteIborFutureTemplate of(YearMonth yearMonth, IborFutureConvention convention)
 {
     return(new AbsoluteIborFutureTemplate(yearMonth, convention));
 }
Ejemplo n.º 16
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains a template based on the specified convention.
 /// <para>
 /// The specific future is defined by two date-related inputs, the minimum period and the 1-based future number.
 /// For example, the 2nd future of the series where the 1st future is at least 1 week after the value date
 /// would be represented by a minimum period of 1 week and future number 2.
 ///
 /// </para>
 /// </summary>
 /// <param name="minimumPeriod">  the minimum period between the base date and the first future </param>
 /// <param name="sequenceNumber">  the 1-based index of the future after the minimum period, must be 1 or greater </param>
 /// <param name="convention">  the future convention </param>
 /// <returns> the template </returns>
 public static RelativeIborFutureTemplate of(Period minimumPeriod, int sequenceNumber, IborFutureConvention convention)
 {
     return(new RelativeIborFutureTemplate(minimumPeriod, sequenceNumber, convention));
 }