Пример #1
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            FxIndexSensitivity @base = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            PointSensitivities test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
        public virtual void test_ratePointSensitivity_afterValuation()
        {
            ForwardFxIndexRates test = ForwardFxIndexRates.of(GBP_USD_WM, FWD_RATES, SERIES);

            assertEquals(test.ratePointSensitivity(OBS_AFTER, GBP), FxIndexSensitivity.of(OBS_AFTER, GBP, 1d));
            assertEquals(test.ratePointSensitivity(OBS_AFTER, USD), FxIndexSensitivity.of(OBS_AFTER, USD, 1d));
        }
        public virtual void test_ratePointSensitivity_onValuation_noFixing()
        {
            ForwardFxIndexRates test = ForwardFxIndexRates.of(GBP_USD_WM, FWD_RATES, SERIES_EMPTY);

            assertEquals(test.ratePointSensitivity(OBS_VAL, GBP), FxIndexSensitivity.of(OBS_VAL, GBP, 1d));
            assertEquals(test.ratePointSensitivity(OBS_VAL, USD), FxIndexSensitivity.of(OBS_VAL, USD, 1d));
        }
Пример #4
0
        //-------------------------------------------------------------------------
        public virtual void test_normalize()
        {
            FxIndexSensitivity @base = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            FxIndexSensitivity test  = @base.normalize();

            assertEquals(test, test);
        }
Пример #5
0
        //-------------------------------------------------------------------------
        public virtual void test_cloned()
        {
            FxIndexSensitivity @base = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            FxIndexSensitivity test  = @base.cloned();

            assertSame(test, @base);
        }
Пример #6
0
        //-------------------------------------------------------------------------
        public virtual void test_withSensitivity()
        {
            FxIndexSensitivity @base    = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            FxIndexSensitivity test     = @base.withSensitivity(2.5d);
            FxIndexSensitivity expected = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, 2.5d);

            assertEquals(test, expected);
        }
Пример #7
0
        //-------------------------------------------------------------------------
        public virtual void test_mapSensitivity()
        {
            FxIndexSensitivity @base    = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            FxIndexSensitivity test     = @base.mapSensitivity(s => 1d / s);
            FxIndexSensitivity expected = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, 1d / SENSITIVITY_VALUE);

            assertEquals(test, expected);
        }
Пример #8
0
        //-------------------------------------------------------------------------
        public virtual void test_multipliedBy()
        {
            FxIndexSensitivity @base    = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            FxIndexSensitivity test     = @base.multipliedBy(2.4d);
            FxIndexSensitivity expected = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE * 2.4d);

            assertEquals(test, expected);
        }
Пример #9
0
        //-------------------------------------------------------------------------
        public virtual void test_toFxForwardSensitivity()
        {
            FxIndexSensitivity   test         = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, USD, SENSITIVITY_VALUE);
            LocalDate            maturityDate = GBP_USD_WM.calculateMaturityFromFixing(FIXING_DATE, REF_DATA);
            FxForwardSensitivity expected     = FxForwardSensitivity.of(CurrencyPair.of(GBP, USD), GBP, maturityDate, USD, SENSITIVITY_VALUE);

            assertEquals(test.toFxForwardSensitivity(), expected);
        }
Пример #10
0
        //-------------------------------------------------------------------------
        public virtual void test_buildInto()
        {
            FxIndexSensitivity        @base = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            MutablePointSensitivities combo = new MutablePointSensitivities();
            MutablePointSensitivities test  = @base.buildInto(combo);

            assertSame(test, combo);
            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
Пример #11
0
 public int compareKey(PointSensitivity other)
 {
     if (other is FxIndexSensitivity)
     {
         FxIndexSensitivity otherFx = (FxIndexSensitivity)other;
         return(ComparisonChain.start().compare(Index.ToString(), otherFx.Index.ToString()).compare(currency, otherFx.currency).compare(referenceCurrency, otherFx.referenceCurrency).compare(observation.FixingDate, otherFx.observation.FixingDate).result());
     }
     return(this.GetType().Name.CompareTo(other.GetType().Name));
 }
Пример #12
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxIndexSensitivity test1 = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);

            coverImmutableBean(test1);
            FxIndexSensitivity test2 = FxIndexSensitivity.of(EUR_GBP_ECB_OBS, GBP, 4.25d);

            coverBeanEquals(test1, test2);
        }
Пример #13
0
        public virtual void test_of_noCurrency()
        {
            FxIndexSensitivity test = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, SENSITIVITY_VALUE);

            assertEquals(test.ReferenceCurrency, GBP);
            assertEquals(test.Currency, USD);
            assertEquals(test.Index, GBP_USD_WM);
            assertEquals(test.Sensitivity, SENSITIVITY_VALUE);
        }
Пример #14
0
        public virtual void test_combinedWith_mutable()
        {
            FxIndexSensitivity        @base    = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            MutablePointSensitivities expected = new MutablePointSensitivities();

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

            assertEquals(test, expected);
        }
        //-------------------------------------------------------------------------
        //proper end-to-end tests are elsewhere
        public virtual void test_parameterSensitivity()
        {
            ForwardFxIndexRates test  = ForwardFxIndexRates.of(GBP_USD_WM, FWD_RATES, SERIES);
            FxIndexSensitivity  point = FxIndexSensitivity.of(OBS_VAL, GBP, 1d);

            assertEquals(test.parameterSensitivity(point).size(), 2);
            FxIndexSensitivity point2 = FxIndexSensitivity.of(OBS_VAL, USD, 1d);

            assertEquals(test.parameterSensitivity(point2).size(), 2);
        }
Пример #16
0
        //-------------------------------------------------------------------------
        public virtual void test_combinedWith()
        {
            FxIndexSensitivity        base1    = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            FxIndexSensitivity        base2    = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, 4.25d);
            MutablePointSensitivities expected = new MutablePointSensitivities();

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

            assertEquals(test, expected);
        }
Пример #17
0
        //-------------------------------------------------------------------------
        public virtual void test_withCurrency()
        {
            FxIndexSensitivity @base = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);

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

            FxIndexSensitivity test     = @base.withCurrency(JPY);
            FxIndexSensitivity expected = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, JPY, SENSITIVITY_VALUE);

            assertEquals(test, expected);
        }
        //-------------------------------------------------------------------------
        public PointSensitivityBuilder ratePointSensitivity(FxIndexObservation observation, Currency baseCurrency)
        {
            ArgChecker.isTrue(index.CurrencyPair.contains(baseCurrency), "Currency {} invalid for FxIndex {}", baseCurrency, index);

            LocalDate fixingDate = observation.FixingDate;

            if (fixingDate.isBefore(ValuationDate) || (fixingDate.Equals(ValuationDate) && fixings.get(fixingDate).HasValue))
            {
                return(PointSensitivityBuilder.none());
            }
            return(FxIndexSensitivity.of(observation, baseCurrency, 1d));
        }
Пример #19
0
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            FxIndexSensitivity @base    = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, SENSITIVITY_VALUE);
            double             rate     = 1.35d;
            FxMatrix           matrix   = FxMatrix.of(CurrencyPair.of(EUR, USD), rate);
            FxIndexSensitivity test1    = (FxIndexSensitivity)@base.convertedTo(EUR, matrix);
            FxIndexSensitivity expected = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, EUR, SENSITIVITY_VALUE / rate);

            assertEquals(test1, expected);
            FxIndexSensitivity test2 = (FxIndexSensitivity)@base.convertedTo(USD, matrix);

            assertEquals(test2, @base);
        }
Пример #20
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FxIndexSensitivity other = (FxIndexSensitivity)obj;
         return(JodaBeanUtils.equal(observation, other.observation) && JodaBeanUtils.equal(referenceCurrency, other.referenceCurrency) && JodaBeanUtils.equal(currency, other.currency) && JodaBeanUtils.equal(sensitivity, other.sensitivity));
     }
     return(false);
 }
Пример #21
0
        //-------------------------------------------------------------------------
        public virtual void test_compareKey()
        {
            FxIndexSensitivity  a1    = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, USD, SENSITIVITY_VALUE);
            FxIndexSensitivity  a2    = FxIndexSensitivity.of(GBP_USD_WM_OBS, GBP, USD, SENSITIVITY_VALUE);
            FxIndexSensitivity  b     = FxIndexSensitivity.of(EUR_GBP_ECB_OBS, USD, SENSITIVITY_VALUE);
            FxIndexSensitivity  c     = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            FxIndexSensitivity  d     = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, JPY, SENSITIVITY_VALUE);
            FxIndexSensitivity  e     = FxIndexSensitivity.of(GBP_USD_WM_OBS2, USD, SENSITIVITY_VALUE);
            ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, SENSITIVITY_VALUE);

            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(e) > 0, true);
            assertEquals(e.compareKey(a1) < 0, true);
            assertEquals(a1.compareKey(other) < 0, true);
            assertEquals(other.compareKey(a1) > 0, true);
        }
 //-------------------------------------------------------------------------
 public CurrencyParameterSensitivities parameterSensitivity(FxIndexSensitivity pointSensitivity)
 {
     return(fxForwardRates.parameterSensitivity(pointSensitivity.toFxForwardSensitivity()));
 }
 public MultiCurrencyAmount currencyExposure(FxIndexSensitivity pointSensitivity)
 {
     return(fxForwardRates.currencyExposure(pointSensitivity.toFxForwardSensitivity()));
 }
Пример #24
0
        public virtual void test_serialization()
        {
            FxIndexSensitivity test = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);

            assertSerialization(test);
        }