コード例 #1
0
        private static CurveNode curveIborFixingDepositCurveNode(string conventionStr, string label, QuoteId quoteId, double spread, CurveNodeDate date, CurveNodeDateOrder order)
        {
            IborFixingDepositConvention convention = IborFixingDepositConvention.of(conventionStr);
            IborFixingDepositTemplate   template   = IborFixingDepositTemplate.of(convention.Index.Tenor.Period, convention);

            return(IborFixingDepositCurveNode.builder().template(template).rateId(quoteId).additionalSpread(spread).label(label).date(date).dateOrder(order).build());
        }
コード例 #2
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(IborFixingDepositConvention convention, String name)
        public virtual void test_extendedEnum(IborFixingDepositConvention convention, string name)
        {
            IborFixingDepositConvention.of(name);     // ensures map is populated
            ImmutableMap <string, IborFixingDepositConvention> map = IborFixingDepositConvention.extendedEnum().lookupAll();

            assertEquals(map.get(name), convention);
        }
コード例 #3
0
 private IborFixingDepositTemplate(Period depositPeriod, IborFixingDepositConvention convention)
 {
     JodaBeanUtils.notNull(depositPeriod, "depositPeriod");
     JodaBeanUtils.notNull(convention, "convention");
     this.depositPeriod = depositPeriod;
     this.convention    = convention;
     validate();
 }
コード例 #4
0
        //-------------------------------------------------------------------------
        public virtual void test_toTrade()
        {
            IborFixingDepositConvention convention = ImmutableIborFixingDepositConvention.builder().businessDayAdjustment(BDA_MOD_FOLLOW).currency(EUR).dayCount(ACT_365F).fixingDateOffset(FIXING_ADJ).index(EUR_LIBOR_3M).spotDateOffset(SPOT_ADJ).build();
            LocalDate tradeDate                 = LocalDate.of(2015, 1, 22);
            Period    depositPeriod             = Period.ofMonths(3);
            double    notional                  = 1d;
            double    fixedRate                 = 0.045;
            IborFixingDepositTrade trade        = convention.createTrade(tradeDate, depositPeriod, BUY, notional, fixedRate, REF_DATA);
            LocalDate         startExpected     = SPOT_ADJ.adjust(tradeDate, REF_DATA);
            LocalDate         endExpected       = startExpected.plus(depositPeriod);
            IborFixingDeposit productExpected   = IborFixingDeposit.builder().businessDayAdjustment(BDA_MOD_FOLLOW).buySell(BUY).currency(EUR).dayCount(ACT_365F).startDate(startExpected).endDate(endExpected).fixedRate(fixedRate).fixingDateOffset(FIXING_ADJ).index(EUR_LIBOR_3M).notional(notional).build();
            TradeInfo         tradeInfoExpected = TradeInfo.builder().tradeDate(tradeDate).build();

            assertEquals(trade.Product, productExpected);
            assertEquals(trade.Info, tradeInfoExpected);
        }
コード例 #5
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 14649855:         // depositPeriod
                    this.depositPeriod_Renamed = (Period)newValue;
                    break;

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

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        /// <summary>
        /// Calibrate a single curve to 4 points. Use the resulting calibrated curves as starting point of the computation
        /// of a Jacobian. Compare the direct Jacobian and the one reconstructed from trades.
        /// </summary>
        public virtual void direct_two_curves()
        {
            JacobianCalibrationMatrix          jiObject = MULTICURVE_EUR_2_CALIBRATED.findData(EUR_DSCON_OIS).get().Metadata.findInfo(CurveInfoType.JACOBIAN).get();
            ImmutableList <CurveParameterSize> order    = jiObject.Order; // To obtain the order of the curves in the jacobian

            /* Create trades */
            IList <ResolvedTrade> tradesDsc = new List <ResolvedTrade>();

            for (int looptenor = 0; looptenor < TENORS_STD_2_OIS.Length; looptenor++)
            {
                ResolvedSwapTrade t0   = EUR_FIXED_1Y_EONIA_OIS.createTrade(VALUATION_DATE, TENORS_STD_2_OIS[looptenor], BuySell.BUY, 1.0, 0.0, REF_DATA).resolve(REF_DATA);
                double            rate = MARKET_QUOTE.value(t0, MULTICURVE_EUR_2_CALIBRATED);
                ResolvedSwapTrade t    = EUR_FIXED_1Y_EONIA_OIS.createTrade(VALUATION_DATE, TENORS_STD_2_OIS[looptenor], BuySell.BUY, 1.0, rate, REF_DATA).resolve(REF_DATA);
                tradesDsc.Add(t);
            }
            IList <ResolvedTrade> tradesE3 = new List <ResolvedTrade>();
            // Fixing
            IborFixingDepositConvention    c    = IborFixingDepositConvention.of(EUR_EURIBOR_6M);
            ResolvedIborFixingDepositTrade fix0 = c.createTrade(VALUATION_DATE, EUR_EURIBOR_6M.Tenor.Period, BuySell.BUY, 1.0, 0.0, REF_DATA).resolve(REF_DATA);
            double rateFixing = MARKET_QUOTE.value(fix0, MULTICURVE_EUR_2_CALIBRATED);
            ResolvedIborFixingDepositTrade fix = c.createTrade(VALUATION_DATE, EUR_EURIBOR_6M.Tenor.Period, BuySell.BUY, 1.0, rateFixing, REF_DATA).resolve(REF_DATA);

            tradesE3.Add(fix);
            // IRS
            for (int looptenor = 0; looptenor < TENORS_STD_2_IRS.Length; looptenor++)
            {
                ResolvedSwapTrade t0   = EUR_FIXED_1Y_EURIBOR_6M.createTrade(VALUATION_DATE, TENORS_STD_2_IRS[looptenor], BuySell.BUY, 1.0, 0.0, REF_DATA).resolve(REF_DATA);
                double            rate = MARKET_QUOTE.value(t0, MULTICURVE_EUR_2_CALIBRATED);
                ResolvedSwapTrade t    = EUR_FIXED_1Y_EURIBOR_6M.createTrade(VALUATION_DATE, TENORS_STD_2_IRS[looptenor], BuySell.BUY, 1.0, rate, REF_DATA).resolve(REF_DATA);
                tradesE3.Add(t);
            }
            IList <ResolvedTrade> trades = new List <ResolvedTrade>();

            if (order.get(0).Name.Equals(EUR_DSCON_OIS))
            {
                ((IList <ResolvedTrade>)trades).AddRange(tradesDsc);
                ((IList <ResolvedTrade>)trades).AddRange(tradesE3);
            }
            else
            {
                ((IList <ResolvedTrade>)trades).AddRange(tradesE3);
                ((IList <ResolvedTrade>)trades).AddRange(tradesDsc);
            }
            /* Par rate sensitivity */
            System.Func <ResolvedTrade, CurrencyParameterSensitivities> sensitivityFunction = (t) => MULTICURVE_EUR_2_CALIBRATED.parameterSensitivity((t is ResolvedSwapTrade) ? PRICER_SWAP_PRODUCT.parRateSensitivity(((ResolvedSwapTrade)t).Product, MULTICURVE_EUR_2_CALIBRATED).build() : PRICER_IBORFIX_PRODUCT.parRateSensitivity(((ResolvedIborFixingDepositTrade)t).Product, MULTICURVE_EUR_2_CALIBRATED));
            DoubleMatrix jiComputed    = CurveSensitivityUtils.jacobianFromMarketQuoteSensitivities(order, trades, sensitivityFunction);
            DoubleMatrix jiExpectedDsc = MULTICURVE_EUR_2_CALIBRATED.findData(EUR_DSCON_OIS).get().Metadata.getInfo(CurveInfoType.JACOBIAN).JacobianMatrix;
            DoubleMatrix jiExpectedE3  = MULTICURVE_EUR_2_CALIBRATED.findData(EUR_EURIBOR6M_IRS).get().Metadata.getInfo(CurveInfoType.JACOBIAN).JacobianMatrix;

            /* Comparison */
            assertEquals(jiComputed.rowCount(), jiExpectedDsc.rowCount() + jiExpectedE3.rowCount());
            assertEquals(jiComputed.columnCount(), jiExpectedDsc.columnCount());
            assertEquals(jiComputed.columnCount(), jiExpectedE3.columnCount());
            int shiftDsc = order.get(0).Name.Equals(EUR_DSCON_OIS) ? 0 : jiExpectedE3.rowCount();

            for (int i = 0; i < jiExpectedDsc.rowCount(); i++)
            {
                for (int j = 0; j < jiExpectedDsc.columnCount(); j++)
                {
                    assertEquals(jiComputed.get(i + shiftDsc, j), jiExpectedDsc.get(i, j), TOLERANCE_JAC);
                }
            }
            int shiftE3 = order.get(0).Name.Equals(EUR_DSCON_OIS) ? jiExpectedDsc.rowCount() : 0;

            for (int i = 0; i < jiExpectedE3.rowCount(); i++)
            {
                for (int j = 0; j < jiExpectedDsc.columnCount(); j++)
                {
                    assertEquals(jiComputed.get(i + shiftE3, j), jiExpectedE3.get(i, j), TOLERANCE_JAC);
                }
            }
        }
コード例 #7
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains a template based on the specified index.
 /// <para>
 /// The period from the start date to the end date will be the tenor of the index.
 /// The convention will be created based on the index.
 ///
 /// </para>
 /// </summary>
 /// <param name="index">  the index that defines the market convention </param>
 /// <returns> the template </returns>
 public static IborFixingDepositTemplate of(IborIndex index)
 {
     return(of(index.Tenor.Period, IborFixingDepositConvention.of(index)));
 }
コード例 #8
0
 /// <summary>
 /// Sets the underlying Ibor fixing deposit convention.
 /// <para>
 /// This specifies the standard convention of the Ibor fixing deposit to be created.
 /// </para>
 /// </summary>
 /// <param name="convention">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder convention(IborFixingDepositConvention convention)
 {
     JodaBeanUtils.notNull(convention, "convention");
     this.convention_Renamed = convention;
     return(this);
 }
コード例 #9
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(IborFixingDepositTemplate beanToCopy)
 {
     this.depositPeriod_Renamed = beanToCopy.DepositPeriod;
     this.convention_Renamed    = beanToCopy.Convention;
 }
コード例 #10
0
 /// <summary>
 /// Obtains a template based on the specified periods and convention.
 /// </summary>
 /// <param name="depositPeriod">  the period between the start date and the end date </param>
 /// <param name="convention">  the market convention </param>
 /// <returns> the template </returns>
 public static IborFixingDepositTemplate of(Period depositPeriod, IborFixingDepositConvention convention)
 {
     ArgChecker.notNull(depositPeriod, "depositPeriod");
     ArgChecker.notNull(convention, "convention");
     return(IborFixingDepositTemplate.builder().depositPeriod(depositPeriod).convention(convention).build());
 }
コード例 #11
0
 public virtual void test_of_lookup_null()
 {
     assertThrowsIllegalArg(() => IborFixingDepositConvention.of((string)null));
 }
コード例 #12
0
 public virtual void test_of_lookup_notFound()
 {
     assertThrowsIllegalArg(() => IborFixingDepositConvention.of("Rubbish"));
 }
コード例 #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_of_lookup(IborFixingDepositConvention convention, String name)
        public virtual void test_of_lookup(IborFixingDepositConvention convention, string name)
        {
            assertEquals(IborFixingDepositConvention.of(name), convention);
        }
コード例 #14
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(IborFixingDepositConvention convention, String name)
        public virtual void test_toString(IborFixingDepositConvention convention, string name)
        {
            assertEquals(convention.ToString(), name);
        }
コード例 #15
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(IborFixingDepositConvention convention, String name)
        public virtual void test_name(IborFixingDepositConvention convention, string name)
        {
            assertEquals(convention.Name, name);
        }