Пример #1
0
        public virtual void test_bind_no_seasonality()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).build();
            LocalDate valuationDate        = LocalDate.of(2015, 11, 10);
            LocalDate lastFixingDate       = LocalDate.of(2015, 10, 31);
            LocalDate otherFixingDate      = LocalDate.of(2015, 9, 30);
            double    lastFixingValue      = 234.56;
            IDictionary <Index, LocalDateDoubleTimeSeries> map = ImmutableMap.of(GB_RPI, LocalDateDoubleTimeSeries.builder().put(lastFixingDate, 234.56).put(otherFixingDate, lastFixingValue - 1).build());
            RatesCurveGroupDefinition testBound = test.bindTimeSeries(valuationDate, map);
            IList <CurveDefinition>   list      = testBound.CurveDefinitions;

            assertEquals(list.Count, 2);
            assertTrue(list[0] is InterpolatedNodalCurveDefinition);
            assertTrue(list[1] is InflationNodalCurveDefinition);
            InflationNodalCurveDefinition seasonDef = (InflationNodalCurveDefinition)list[1];

            assertEquals(seasonDef.CurveWithoutFixingDefinition, CURVE_DEFN_I);
            assertEquals(seasonDef.LastFixingMonth, YearMonth.from(lastFixingDate));
            assertEquals(seasonDef.LastFixingValue, lastFixingValue);
            assertEquals(seasonDef.Name, CURVE_NAME_I);
            assertEquals(seasonDef.YValueType, ValueType.PRICE_INDEX);
            // Check the default
            assertTrue(seasonDef.SeasonalityDefinition.SeasonalityMonthOnMonth.equalWithTolerance(DoubleArray.filled(12, 1d), 1.0E-10));
            assertEquals(seasonDef.SeasonalityDefinition.AdjustmentType, ShiftType.SCALED);
        }
	  public virtual void test_builder()
	  {
		InflationNodalCurveDefinition test = new InflationNodalCurveDefinition(UNDERLYING_DEF, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		assertEquals(test.CurveWithoutFixingDefinition, UNDERLYING_DEF);
		assertEquals(test.LastFixingMonth, LAST_FIX_MONTH);
		assertEquals(test.LastFixingValue, LAST_FIX_VALUE);
		assertEquals(test.SeasonalityDefinition, SEASONALITY_DEF);
	  }
	  //-------------------------------------------------------------------------
	  public virtual void coverage()
	  {
		InflationNodalCurveDefinition test = new InflationNodalCurveDefinition(UNDERLYING_DEF, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		coverImmutableBean(test);
		InterpolatedNodalCurveDefinition underlyingDef2 = InterpolatedNodalCurveDefinition.builder().name(CurveName.of("foo")).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).nodes(NODES).interpolator(CurveInterpolators.LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();
		SeasonalityDefinition seasonalityDef2 = SeasonalityDefinition.of(SEASONALITY_ADDITIVE, ShiftType.SCALED);
		InflationNodalCurveDefinition test2 = new InflationNodalCurveDefinition(underlyingDef2, LAST_FIX_MONTH.plus(Period.ofMonths(1)), LAST_FIX_VALUE + 1.0d, seasonalityDef2);
		coverBeanEquals(test, test2);
	  }
	  //-------------------------------------------------------------------------
	  public virtual void test_curve()
	  {
		InflationNodalCurveDefinition test = new InflationNodalCurveDefinition(UNDERLYING_DEF, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		DefaultCurveMetadata metadata = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.PRICE_INDEX).dayCount(ACT_365F).parameterMetadata(NODES.get(0).metadata(VAL_DATE, REF_DATA), NODES.get(1).metadata(VAL_DATE, REF_DATA)).build();
		LocalDate date0 = NODES.get(0).date(VAL_DATE, REF_DATA);
		LocalDate date1 = NODES.get(1).date(VAL_DATE, REF_DATA);
		DoubleArray param = DoubleArray.of(250.0d, 260.0d);
		InterpolatedNodalCurve expectedUnderlying = InterpolatedNodalCurve.builder().metadata(metadata).xValues(DoubleArray.of(ACT_365F.yearFraction(VAL_DATE, date0), ACT_365F.yearFraction(VAL_DATE, date1))).yValues(param).interpolator(CurveInterpolators.LOG_LINEAR).extrapolatorLeft(CurveExtrapolators.FLAT).extrapolatorRight(CurveExtrapolators.FLAT).build();
		InflationNodalCurve expected = InflationNodalCurve.of(expectedUnderlying, VAL_DATE, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		assertEquals(test.curve(VAL_DATE, metadata, param), expected);
	  }
Пример #5
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         InflationNodalCurveDefinition other = (InflationNodalCurveDefinition)obj;
         return(JodaBeanUtils.equal(curveWithoutFixingDefinition, other.curveWithoutFixingDefinition) && JodaBeanUtils.equal(lastFixingMonth, other.lastFixingMonth) && JodaBeanUtils.equal(lastFixingValue, other.lastFixingValue) && JodaBeanUtils.equal(seasonalityDefinition, other.seasonalityDefinition));
     }
     return(false);
 }
Пример #6
0
        //-------------------------------------------------------------------------
        public virtual void test_bind()
        {
            RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addForwardCurve(CURVE_DEFN_I, GB_RPI).addSeasonality(CURVE_NAME_I, SEASONALITY_ADDITIVE_DEF).build();
            LocalDate valuationDate        = LocalDate.of(2015, 11, 10);
            LocalDate lastFixingDate       = LocalDate.of(2015, 10, 31);
            LocalDate otherFixingDate      = LocalDate.of(2015, 9, 30);
            double    lastFixingValue      = 234.56;
            IDictionary <Index, LocalDateDoubleTimeSeries> map = ImmutableMap.of(GB_RPI, LocalDateDoubleTimeSeries.builder().put(lastFixingDate, 234.56).put(otherFixingDate, lastFixingValue - 1).build());
            RatesCurveGroupDefinition testBound = test.bindTimeSeries(valuationDate, map);
            IList <CurveDefinition>   list      = testBound.CurveDefinitions;

            assertEquals(list.Count, 2);
            assertTrue(list[0] is InterpolatedNodalCurveDefinition);
            assertTrue(list[1] is InflationNodalCurveDefinition);
            InflationNodalCurveDefinition seasonDef = (InflationNodalCurveDefinition)list[1];

            assertEquals(seasonDef.CurveWithoutFixingDefinition, CURVE_DEFN_I);
            assertEquals(seasonDef.LastFixingMonth, YearMonth.from(lastFixingDate));
            assertEquals(seasonDef.LastFixingValue, lastFixingValue);
            assertEquals(seasonDef.Name, CURVE_NAME_I);
            assertEquals(seasonDef.SeasonalityDefinition, SEASONALITY_ADDITIVE_DEF);
            assertEquals(seasonDef.YValueType, ValueType.PRICE_INDEX);
        }
	  //-------------------------------------------------------------------------
	  public virtual void test_toCurveParameterSize()
	  {
		InflationNodalCurveDefinition test = new InflationNodalCurveDefinition(UNDERLYING_DEF, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		assertEquals(test.toCurveParameterSize(), CurveParameterSize.of(CURVE_NAME, NODES.size()));
	  }
	  //-------------------------------------------------------------------------
	  public virtual void test_metadata()
	  {
		InflationNodalCurveDefinition test = new InflationNodalCurveDefinition(UNDERLYING_DEF, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		DefaultCurveMetadata expected = DefaultCurveMetadata.builder().curveName(CURVE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.PRICE_INDEX).dayCount(ACT_365F).parameterMetadata(NODES.get(0).metadata(VAL_DATE, REF_DATA), NODES.get(1).metadata(VAL_DATE, REF_DATA)).build();
		assertEquals(test.metadata(VAL_DATE, REF_DATA), expected);
	  }
	  public virtual void test_serialization()
	  {
		InflationNodalCurveDefinition test = new InflationNodalCurveDefinition(UNDERLYING_DEF, LAST_FIX_MONTH, LAST_FIX_VALUE, SEASONALITY_DEF);
		assertSerialization(test);
	  }