コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_cloned()
        {
            IborRateSensitivity @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity test  = @base.cloned();

            assertSame(test, @base);
        }
コード例 #2
0
        public virtual void test_rateIgnoringFixingsPointSensitivity_onValuation()
        {
            DiscountIborIndexRates test     = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES);
            IborRateSensitivity    expected = IborRateSensitivity.of(GBP_LIBOR_3M_VAL, 1d);

            assertEquals(test.rateIgnoringFixingsPointSensitivity(GBP_LIBOR_3M_VAL), expected);
        }
コード例 #3
0
        public virtual void test_ratePointSensitivity_afterValuation()
        {
            DiscountIborIndexRates test     = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES);
            IborRateSensitivity    expected = IborRateSensitivity.of(GBP_LIBOR_3M_AFTER, 1d);

            assertEquals(test.ratePointSensitivity(GBP_LIBOR_3M_AFTER), expected);
        }
コード例 #4
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            IborRateSensitivity @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            PointSensitivities  test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
コード例 #5
0
        //-------------------------------------------------------------------------
        // proper end-to-end tests are elsewhere
        public virtual void test_parameterSensitivity()
        {
            DiscountIborIndexRates test  = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES);
            IborRateSensitivity    point = IborRateSensitivity.of(GBP_LIBOR_3M_AFTER, GBP, 1d);

            assertEquals(test.parameterSensitivity(point).size(), 1);
        }
コード例 #6
0
        //-------------------------------------------------------------------------
        public virtual void test_mapSensitivity()
        {
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 1 / 32d);
            IborRateSensitivity test     = @base.mapSensitivity(s => 1 / s);

            assertEquals(test, expected);
        }
コード例 #7
0
        //-------------------------------------------------------------------------
        public virtual void test_multipliedBy()
        {
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d * 3.5d);
            IborRateSensitivity test     = @base.multipliedBy(3.5d);

            assertEquals(test, expected);
        }
コード例 #8
0
        public virtual void test_ratePointSensitivity_onValuation_noFixing()
        {
            SimpleIborIndexRates test     = SimpleIborIndexRates.of(GBP_LIBOR_3M, DATE_VAL, CURVE, SERIES_EMPTY);
            IborRateSensitivity  expected = IborRateSensitivity.of(GBP_LIBOR_3M_VAL, 1d);

            assertEquals(test.ratePointSensitivity(GBP_LIBOR_3M_VAL), expected);
            assertEquals(test.rateIgnoringFixingsPointSensitivity(GBP_LIBOR_3M_VAL), expected);
        }
コード例 #9
0
        //-------------------------------------------------------------------------
        public virtual void test_withSensitivity()
        {
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 20d);
            IborRateSensitivity test     = @base.withSensitivity(20d);

            assertEquals(test, expected);
        }
コード例 #10
0
        //-------------------------------------------------------------------------
        public CurrencyParameterSensitivities parameterSensitivity(IborRateSensitivity pointSensitivity)
        {
            LocalDate maturityDate         = pointSensitivity.Observation.MaturityDate;
            double    relativeYearFraction = this.relativeYearFraction(maturityDate);
            UnitParameterSensitivity     unitSensitivity = curve.yValueParameterSensitivity(relativeYearFraction);
            CurrencyParameterSensitivity sensitivity     = unitSensitivity.multipliedBy(pointSensitivity.Currency, pointSensitivity.Sensitivity);

            return(CurrencyParameterSensitivities.of(sensitivity));
        }
コード例 #11
0
        //-------------------------------------------------------------------------
        public virtual void test_buildInto()
        {
            IborRateSensitivity       @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            MutablePointSensitivities combo = new MutablePointSensitivities();
            MutablePointSensitivities test  = @base.buildInto(combo);

            assertSame(test, combo);
            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
コード例 #12
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborRateSensitivity test = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);

            coverImmutableBean(test);
            IborRateSensitivity test2 = IborRateSensitivity.of(IborIndexObservation.of(USD_LIBOR_3M, DATE2, REF_DATA), USD, 16d);

            coverBeanEquals(test, test2);
        }
コード例 #13
0
 public int compareKey(PointSensitivity other)
 {
     if (other is IborRateSensitivity)
     {
         IborRateSensitivity otherIbor = (IborRateSensitivity)other;
         return(ComparisonChain.start().compare(Index.ToString(), otherIbor.Index.ToString()).compare(currency, otherIbor.currency).compare(observation.FixingDate, otherIbor.observation.FixingDate).result());
     }
     return(this.GetType().Name.CompareTo(other.GetType().Name));
 }
コード例 #14
0
        public virtual void test_of_withCurrency()
        {
            IborRateSensitivity test = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, GBP, 32d);

            assertEquals(test.Index, GBP_LIBOR_3M);
            assertEquals(test.Currency, GBP);
            assertEquals(test.Sensitivity, 32d);
            assertEquals(test.Index, GBP_LIBOR_3M);
        }
コード例 #15
0
        public virtual void test_combinedWith_mutable()
        {
            IborRateSensitivity       @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            MutablePointSensitivities expected = new MutablePointSensitivities();

            expected.add(@base);
            PointSensitivityBuilder test = @base.combinedWith(new MutablePointSensitivities());

            assertEquals(test, expected);
        }
コード例 #16
0
        //-------------------------------------------------------------------------
        public PointSensitivityBuilder ratePointSensitivity(IborIndexObservation observation)
        {
            LocalDate fixingDate    = observation.FixingDate;
            LocalDate valuationDate = ValuationDate;

            if (fixingDate.isBefore(valuationDate) || (fixingDate.Equals(valuationDate) && fixings.get(fixingDate).HasValue))
            {
                return(PointSensitivityBuilder.none());
            }
            return(IborRateSensitivity.of(observation, 1d));
        }
コード例 #17
0
        //-------------------------------------------------------------------------
        public virtual void test_withCurrency()
        {
            IborRateSensitivity @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);

            assertSame(@base.withCurrency(GBP), @base);

            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, 32d);
            IborRateSensitivity test     = @base.withCurrency(USD);

            assertEquals(test, expected);
        }
コード例 #18
0
        //-------------------------------------------------------------------------
        public virtual void test_combinedWith()
        {
            IborRateSensitivity       base1    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity       base2    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION2, 22d);
            MutablePointSensitivities expected = new MutablePointSensitivities();

            expected.add(base1).add(base2);
            PointSensitivityBuilder test = base1.combinedWith(base2);

            assertEquals(test, expected);
        }
コード例 #19
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         IborRateSensitivity other = (IborRateSensitivity)obj;
         return(JodaBeanUtils.equal(observation, other.observation) && JodaBeanUtils.equal(currency, other.currency) && JodaBeanUtils.equal(sensitivity, other.sensitivity));
     }
     return(false);
 }
コード例 #20
0
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            double sensi = 32d;
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, sensi);
            double              rate     = 1.5d;
            FxMatrix            matrix   = FxMatrix.of(CurrencyPair.of(GBP, USD), rate);
            IborRateSensitivity test1    = (IborRateSensitivity)@base.convertedTo(USD, matrix);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, sensi * rate);

            assertEquals(test1, expected);
            IborRateSensitivity test2 = (IborRateSensitivity)@base.convertedTo(GBP, matrix);

            assertEquals(test2, @base);
        }
コード例 #21
0
        //-------------------------------------------------------------------------
        public CurrencyParameterSensitivities parameterSensitivity(IborRateSensitivity pointSensitivity)
        {
            LocalDate                      fixingStartDate = pointSensitivity.Observation.EffectiveDate;
            LocalDate                      fixingEndDate   = pointSensitivity.Observation.MaturityDate;
            double                         accrualFactor   = pointSensitivity.Observation.YearFraction;
            double                         forwardBar      = pointSensitivity.Sensitivity;
            double                         dfForwardStart  = discountFactors.discountFactor(fixingStartDate);
            double                         dfForwardEnd    = discountFactors.discountFactor(fixingEndDate);
            double                         dfStartBar      = forwardBar / (accrualFactor * dfForwardEnd);
            double                         dfEndBar        = -forwardBar * dfForwardStart / (accrualFactor * dfForwardEnd * dfForwardEnd);
            ZeroRateSensitivity            zrsStart        = discountFactors.zeroRatePointSensitivity(fixingStartDate, pointSensitivity.Currency);
            ZeroRateSensitivity            zrsEnd          = discountFactors.zeroRatePointSensitivity(fixingEndDate, pointSensitivity.Currency);
            CurrencyParameterSensitivities psStart         = discountFactors.parameterSensitivity(zrsStart).multipliedBy(dfStartBar);
            CurrencyParameterSensitivities psEnd           = discountFactors.parameterSensitivity(zrsEnd).multipliedBy(dfEndBar);

            return(psStart.combinedWith(psEnd));
        }
コード例 #22
0
        //-------------------------------------------------------------------------
        public virtual void test_compareKey()
        {
            IborRateSensitivity a1    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity a2    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity b     = IborRateSensitivity.of(IborIndexObservation.of(USD_LIBOR_3M, DATE2, REF_DATA), 32d);
            IborRateSensitivity c     = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, 32d);
            IborRateSensitivity d     = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION2, 32d);
            ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d);

            assertEquals(a1.compareKey(a2), 0);
            assertEquals(a1.compareKey(b) < 0, true);
            assertEquals(b.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(c) < 0, true);
            assertEquals(c.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(d) < 0, true);
            assertEquals(d.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(other) < 0, true);
            assertEquals(other.compareKey(a1) > 0, true);
        }
コード例 #23
0
 public PointSensitivityBuilder rateIgnoringFixingsPointSensitivity(IborIndexObservation observation)
 {
     return(IborRateSensitivity.of(observation, 1d));
 }
コード例 #24
0
        public virtual void test_serialization()
        {
            IborRateSensitivity test = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);

            assertSerialization(test);
        }