public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case -1321546630:         // template
                    this.template_Renamed = (IborFutureTemplate)newValue;
                    break;

                case -938107365:         // rateId
                    this.rateId_Renamed = (QuoteId)newValue;
                    break;

                case 291232890:         // additionalSpread
                    this.additionalSpread_Renamed = (double?)newValue.Value;
                    break;

                case 102727412:         // label
                    this.label_Renamed = (string)newValue;
                    break;

                case 3076014:         // date
                    this.date_Renamed = (CurveNodeDate)newValue;
                    break;

                case -263699392:         // dateOrder
                    this.dateOrder_Renamed = (CurveNodeDateOrder)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        public virtual void test_calculateReferenceDateFromTradeDate()
        {
            IborFutureTemplate @base    = IborFutureTemplate.of(YEAR_MONTH, CONVENTION);
            LocalDate          date     = LocalDate.of(2015, 10, 20);
            LocalDate          expected = LocalDate.of(2016, 6, 15);

            assertEquals(@base.calculateReferenceDateFromTradeDate(date, REF_DATA), expected);
        }
Exemplo n.º 3
0
        public virtual void test_calculateReferenceDateFromTradeDate()
        {
            IborFutureTemplate @base    = IborFutureTemplate.of(MIN_PERIOD, NUMBER, CONVENTION);
            LocalDate          date     = LocalDate.of(2015, 10, 20); // 2nd Quarterly IMM at least 2 months later from this date
            LocalDate          expected = LocalDate.of(2016, 6, 15);  // 1st is March 2016, 2nd is Jun 2016

            assertEquals(@base.calculateReferenceDateFromTradeDate(date, REF_DATA), expected);
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborFutureCurveNode test = IborFutureCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD);

            coverImmutableBean(test);
            IborFutureCurveNode test2 = IborFutureCurveNode.of(IborFutureTemplate.of(PERIOD_TO_START, NUMBER, CONVENTION), QuoteId.of(StandardId.of("OG-Ticker", "Unknown")));

            coverBeanEquals(test, test2);
        }
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(IborFutureCurveNode beanToCopy)
 {
     this.template_Renamed         = beanToCopy.Template;
     this.rateId_Renamed           = beanToCopy.RateId;
     this.additionalSpread_Renamed = beanToCopy.AdditionalSpread;
     this.label_Renamed            = beanToCopy.Label;
     this.date_Renamed             = beanToCopy.Date;
     this.dateOrder_Renamed        = beanToCopy.DateOrder;
 }
        //-------------------------------------------------------------------------
        public virtual void test_createTrade()
        {
            IborFutureTemplate @base    = IborFutureTemplate.of(YEAR_MONTH, CONVENTION);
            LocalDate          date     = LocalDate.of(2015, 10, 20);
            double             quantity = 3;
            double             price    = 0.99;
            double             notional = 100.0;
            SecurityId         secId    = SecurityId.of("OG-Future", "GBP-LIBOR-3M-Jun16");
            IborFutureTrade    trade    = @base.createTrade(date, secId, quantity, notional, price, REF_DATA);
            IborFutureTrade    expected = CONVENTION.createTrade(date, secId, YEAR_MONTH, quantity, notional, price, REF_DATA);

            assertEquals(trade, expected);
        }
 private IborFutureCurveNode(IborFutureTemplate template, QuoteId rateId, double additionalSpread, string label, CurveNodeDate date, CurveNodeDateOrder dateOrder)
 {
     JodaBeanUtils.notNull(template, "template");
     JodaBeanUtils.notNull(rateId, "rateId");
     JodaBeanUtils.notNull(label, "label");
     JodaBeanUtils.notNull(dateOrder, "dateOrder");
     this.template         = template;
     this.rateId           = rateId;
     this.additionalSpread = additionalSpread;
     this.label            = label;
     this.date_Renamed     = date;
     this.dateOrder        = dateOrder;
 }
Exemplo n.º 8
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));
        }
        public virtual void test_approximateMaturity()
        {
            IborFutureTemplate @base = IborFutureTemplate.of(YEAR_MONTH, CONVENTION);

            assertEquals(@base.approximateMaturity(LocalDate.of(2015, 10, 20)), 8d / 12d, 0.1d);
        }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains a curve node for an Ibor Future using the specified template and rate key.
 /// </summary>
 /// <param name="template">  the template used for building the instrument for the node </param>
 /// <param name="rateId">  the identifier of the market rate for the security </param>
 /// <returns> a node whose instrument is built from the template using a market rate </returns>
 public static IborFutureCurveNode of(IborFutureTemplate template, QuoteId rateId)
 {
     return(of(template, rateId, 0d));
 }
 //-----------------------------------------------------------------------
 /// <summary>
 /// Sets the template for the Ibor Futures associated with this node. </summary>
 /// <param name="template">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder template(IborFutureTemplate template)
 {
     JodaBeanUtils.notNull(template, "template");
     this.template_Renamed = template;
     return(this);
 }
 /// <summary>
 /// Obtains a curve node for an Ibor Future using the specified template, rate key, spread and label.
 /// </summary>
 /// <param name="template">  the template defining the node instrument </param>
 /// <param name="rateId">  the identifier of the market rate for the security </param>
 /// <param name="additionalSpread">  the additional spread amount added to the rate </param>
 /// <param name="label">  the label to use for the node, if empty an appropriate default label will be generated </param>
 /// <returns> a node whose instrument is built from the template using a market rate </returns>
 public static IborFutureCurveNode of(IborFutureTemplate template, QuoteId rateId, double additionalSpread, string label)
 {
     return(new IborFutureCurveNode(template, rateId, additionalSpread, label, CurveNodeDate.END, CurveNodeDateOrder.DEFAULT));
 }
 /// <summary>
 /// Obtains a curve node for an Ibor Future using the specified template, rate key and spread.
 /// </summary>
 /// <param name="template">  the template defining the node instrument </param>
 /// <param name="rateId">  the identifier of the market rate for the security </param>
 /// <param name="additionalSpread">  the additional spread amount added to the rate </param>
 /// <returns> a node whose instrument is built from the template using a market rate </returns>
 public static IborFutureCurveNode of(IborFutureTemplate template, QuoteId rateId, double additionalSpread)
 {
     return(of(template, rateId, additionalSpread, ""));
 }
        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);
        }
Exemplo n.º 15
0
        public virtual void test_approximateMaturity()
        {
            IborFutureTemplate @base = IborFutureTemplate.of(MIN_PERIOD, NUMBER, CONVENTION);

            assertEquals(@base.approximateMaturity(LocalDate.of(2015, 10, 20)), 0.5d, 0.1d);
        }