/** * Creates curve metadata for SABR parameters. * * @return the curve metadata */ public ImmutableList<CurveMetadata> createSabrParameterMetadata() { CurveMetadata alphaMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Alpha", dayCount, SABR_ALPHA); CurveMetadata betaMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Beta", dayCount, SABR_BETA); CurveMetadata rhoMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Rho", dayCount, SABR_RHO); CurveMetadata nuMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Nu", dayCount, SABR_NU); return ImmutableList.of(alphaMetadata, betaMetadata, rhoMetadata, nuMetadata); }
/** * Creates curve metadata for a curve providing zero rates. * <p> * The x-values represent year fractions relative to an unspecified base date * as defined by the specified day count. * * @param name the curve name * @param dayCount the day count * @return the curve metadata */ public static CurveMetadata zeroRates(String name, DayCount dayCount) { return zeroRates(CurveName.of(name), dayCount); }
/** * Creates curve metadata for a curve providing discount factors. * <p> * The x-values represent year fractions relative to an unspecified base date * as defined by the specified day count. * * @param name the curve name * @param dayCount the day count * @return the curve metadata */ public static CurveMetadata discountFactors(String name, DayCount dayCount) { return discountFactors(CurveName.of(name), dayCount); }
/** * Creates curve metadata for a curve providing monthly prices, typically used in inflation. * <p> * The x-values represent months relative to an unspecified base month. * * @param name the curve name * @return the curve metadata */ public static CurveMetadata prices(String name) { return prices(CurveName.of(name)); }
public void test_of_badCurve() { InterpolatedNodalCurve notYearFraction = InterpolatedNodalCurve.of( Curves.prices(NAME), DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); InterpolatedNodalCurve notZeroRate = InterpolatedNodalCurve.of( Curves.discountFactors(NAME, ACT_365F), DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); CurveMetadata noDayCountMetadata = DefaultCurveMetadata.builder() .curveName(NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.ZERO_RATE) .build(); InterpolatedNodalCurve notDayCount = InterpolatedNodalCurve.of( noDayCountMetadata, DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); assertThrowsIllegalArg(() -> ZeroRateDiscountFactors.of(GBP, DATE_VAL, notYearFraction)); assertThrowsIllegalArg(() -> ZeroRateDiscountFactors.of(GBP, DATE_VAL, notZeroRate)); assertThrowsIllegalArg(() -> ZeroRateDiscountFactors.of(GBP, DATE_VAL, notDayCount)); }
private SimpleRatesProvider createProvider(ResolvedFra fraExp) { DiscountFactors mockDf = SimpleDiscountFactors.of( GBP, VAL_DATE, ConstantCurve.of(Curves.discountFactors("DSC", DAY_COUNT), DISCOUNT_FACTOR)); LocalDateDoubleTimeSeries timeSeries = LocalDateDoubleTimeSeries.of(VAL_DATE, FORWARD_RATE); IborIndexRates mockIbor = SimpleIborIndexRates.of( GBP_LIBOR_3M, VAL_DATE, ConstantCurve.of(Curves.forwardRates("L3M", DAY_COUNT), FORWARD_RATE), timeSeries); SimpleRatesProvider prov = new SimpleRatesProvider(VAL_DATE, mockDf); prov.setIborRates(mockIbor); return prov; }
public void test_of_badCurve() { InterpolatedNodalCurve notYearFraction = InterpolatedNodalCurve.of( Curves.prices(NAME), DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); InterpolatedNodalCurve notDiscountFactor = InterpolatedNodalCurve.of( Curves.zeroRates(NAME, ACT_365F), DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); CurveMetadata noDayCountMetadata = DefaultCurveMetadata.builder() .curveName(NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.DISCOUNT_FACTOR) .build(); InterpolatedNodalCurve notDayCount = InterpolatedNodalCurve.of( noDayCountMetadata, DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); assertThrowsIllegalArg(() -> SimpleDiscountFactors.of(GBP, DATE_VAL, notYearFraction)); assertThrowsIllegalArg(() -> SimpleDiscountFactors.of(GBP, DATE_VAL, notDiscountFactor)); assertThrowsIllegalArg(() -> SimpleDiscountFactors.of(GBP, DATE_VAL, notDayCount)); }
/** * Creates curve metadata for a curve providing forward rates. * <p> * The x-values represent year fractions relative to an unspecified base date * as defined by the specified day count. * * @param name the curve name * @param dayCount the day count * @return the curve metadata */ public static CurveMetadata forwardRates(String name, DayCount dayCount) { return forwardRates(CurveName.of(name), dayCount); }
/** * Creates curve metadata for a curve providing Black volatility by expiry. * <p> * The x-values represent year fractions relative to an unspecified base date * as defined by the specified day count. * * @param name the curve name * @param dayCount the day count * @return the curve metadata */ public static CurveMetadata blackVolatilityByExpiry(String name, DayCount dayCount) { return blackVolatilityByExpiry(CurveName.of(name), dayCount); }
/** * Creates curve metadata for a curve providing recovery rates. * <p> * The x-values represent year fractions relative to an unspecified base date * as defined by the specified day count. * * @param name the curve name * @param dayCount the day count * @return the curve metadata */ public static CurveMetadata recoveryRates(String name, DayCount dayCount) { return recoveryRates(CurveName.of(name), dayCount); }
public void prices_curveName() { CurveMetadata test = Curves.prices(CURVE_NAME); CurveMetadata expected = DefaultCurveMetadata.builder() .curveName(CURVE_NAME) .xValueType(ValueType.MONTHS) .yValueType(ValueType.PRICE_INDEX) .build(); assertEquals(test, expected); }
public void test_of_badCurve() { InterpolatedNodalCurve notYearFraction = InterpolatedNodalCurve.of( Curves.prices(NAME), DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); InterpolatedNodalCurve notZeroRate = InterpolatedNodalCurve.of( Curves.discountFactors(NAME, ACT_365F), DoubleArray.of(0, 10), DoubleArray.of(1, 2), INTERPOLATOR); CurveMetadata noDayCountMetadata = DefaultCurveMetadata.builder() .curveName(NAME)
public void forwardRates_string() { CurveMetadata test = Curves.forwardRates(NAME, ACT_360); CurveMetadata expected = DefaultCurveMetadata.builder() .curveName(CURVE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.FORWARD_RATE) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
public void blackVolatilityByExpiry_string() { CurveMetadata test = Curves.blackVolatilityByExpiry(NAME, ACT_360); CurveMetadata expected = DefaultCurveMetadata.builder() .curveName(CURVE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.BLACK_VOLATILITY) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
public void recoveryRates_string() { CurveMetadata test = Curves.recoveryRates(NAME, ACT_360); CurveMetadata expected = DefaultCurveMetadata.builder() .curveName(CURVE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.RECOVERY_RATE) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
/** * Creates curve metadata for SABR parameters. * <p> * The metadata in the list are ordered as alpha, beta, rho, then nu. * * @return the curve metadata */ public ImmutableList<CurveMetadata> createSabrParameterMetadata() { CurveMetadata alphaMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Alpha", dayCount, SABR_ALPHA); CurveMetadata betaMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Beta", dayCount, SABR_BETA); CurveMetadata rhoMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Rho", dayCount, SABR_RHO); CurveMetadata nuMetadata = Curves.sabrParameterByExpiry(name.getName() + "-Nu", dayCount, SABR_NU); return ImmutableList.of(alphaMetadata, betaMetadata, rhoMetadata, nuMetadata); }
public ConstantDiscountFactorCurve(String name, double discountFactor) { this.metadata = Curves.zeroRates(name, DAY_COUNT); this.discountFactor = discountFactor; }
public void prices_string() { CurveMetadata test = Curves.prices(NAME); CurveMetadata expected = DefaultCurveMetadata.builder() .curveName(CURVE_NAME) .xValueType(ValueType.MONTHS) .yValueType(ValueType.PRICE_INDEX) .build(); assertEquals(test, expected); }
public void discountFactors_string() { CurveMetadata test = Curves.discountFactors(NAME, ACT_360); CurveMetadata expected = DefaultCurveMetadata.builder() .curveName(CURVE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.DISCOUNT_FACTOR) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
public void forwardRates_curveName() { CurveMetadata test = Curves.forwardRates(CURVE_NAME, ACT_360); CurveMetadata expected = DefaultCurveMetadata.builder() .curveName(CURVE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.FORWARD_RATE) .dayCount(ACT_360) .build(); assertEquals(test, expected); }