@Override public CurveName getName() { return underlyingCurve.getName(); }
/** * Returns a map containing all the curves, keyed by curve name. * <p> * No checks are performed to see if one curve name is mapped to two different curves. * * @return the map of curves */ public Map<CurveName, Curve> getCurves() { // use a HashMap to avoid errors due to duplicates Map<CurveName, Curve> curves = new HashMap<>(); discountCurves.values().forEach(curve -> curves.put(curve.getName(), curve)); indexCurves.values().forEach(curve -> curves.put(curve.getName(), curve)); return curves; }
@Override public <T> Optional<T> findData(MarketDataName<T> name) { if (curve.getName().equals(name)) { return Optional.of(name.getMarketDataType().cast(curve)); } return Optional.empty(); }
@Override public <T> Optional<T> findData(MarketDataName<T> name) { if (curve.getName().equals(name)) { return Optional.of(name.getMarketDataType().cast(curve)); } return Optional.empty(); }
@Override public DoubleArray apply(DoubleArray t) { Curve newCurve = replaceParameters(curve, t); ImmutableRatesProvider newRates = ratesProviderFn.apply(newCurve); CurrencyParameterSensitivities sensiMulti = sensitivitiesFn.apply(newRates); return sensiMulti.getSensitivity(newCurve.getName(), sensitivityCurrency).getSensitivity(); } };
@Override public <T> Optional<T> findData(MarketDataName<T> name) { if (curve.getName().equals(name)) { return Optional.of(name.getMarketDataType().cast(curve)); } return Optional.empty(); }
@Override public <T> Optional<T> findData(MarketDataName<T> name) { if (curve.getName().equals(name)) { return Optional.of(name.getMarketDataType().cast(curve)); } return Optional.empty(); }
@Override public <T> Optional<T> findData(MarketDataName<T> name) { if (curve.getName().equals(name)) { return Optional.of(name.getMarketDataType().cast(curve)); } return Optional.empty(); }
@Override public <T> Optional<T> findData(MarketDataName<T> name) { if (name instanceof CurveName) { return Stream.concat(discountCurves.values().stream(), indexCurves.values().stream()) .filter(c -> c.getName().equals(name)) .map(v -> name.getMarketDataType().cast(v)) .findFirst(); } return Optional.empty(); }
/** * Finds the curve with the specified name. * <p> * If the curve cannot be found, empty is returned. * * @param name the curve name * @return the curve, empty if not found */ @Override public Optional<Curve> findCurve(CurveName name) { return Stream.concat(discountCurves.values().stream(), forwardCurves.values().stream()) .filter(c -> c.getName().equals(name)) .findFirst(); }
private Curve applyShift(Curve curve, int scenarioIndex) { double shiftAmount = shiftAmounts.get(scenarioIndex); log.debug("Applying {} parallel shift of {} to curve '{}'", shiftType, shiftAmount, curve.getName()); return ParallelShiftedCurve.of(curve, shiftType, shiftAmount); }
/** * Finds the curve with the specified name. * <p> * If the curve cannot be found, empty is returned. * * @param name the curve name * @return the curve, empty if not found */ @Override public Optional<Curve> findCurve(CurveName name) { return Stream.concat(repoCurves.values().stream(), issuerCurves.values().stream()) .filter(c -> c.getName().equals(name)) .findFirst(); }
@Override public FxOptionVolatilitiesName getName() { return FxOptionVolatilitiesName.of(curve.getName().getName()); }
@Override public <T> Optional<T> findData(MarketDataName<T> name) { if (surface.getName().equals(name)) { return Optional.of(name.getMarketDataType().cast(surface)); } if (shiftCurve.getName().equals(name)) { return Optional.of(name.getMarketDataType().cast(shiftCurve)); } return Optional.empty(); }
private static List<String> curveSettings(Curve curve) { ArgChecker.isTrue(curve instanceof InterpolatedNodalCurve, "Curve must be an InterpolatedNodalCurve"); if (!VALUE_TYPE_MAP.inverse().containsKey(curve.getMetadata().getYValueType())) { throw new IllegalArgumentException( Messages.format("Unsupported ValueType in curve settings: {}", curve.getMetadata().getYValueType())); } InterpolatedNodalCurve interpolatedCurve = (InterpolatedNodalCurve) curve; List<String> line = new ArrayList<>(); line.add(curve.getName().getName()); line.add(VALUE_TYPE_MAP.inverse().get(curve.getMetadata().getYValueType())); line.add(curve.getMetadata().getInfo(CurveInfoType.DAY_COUNT).toString()); line.add(interpolatedCurve.getInterpolator().toString()); line.add(interpolatedCurve.getExtrapolatorLeft().toString()); line.add(interpolatedCurve.getExtrapolatorRight().toString()); return line; }
public void test_getCurves() { ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE) .discountCurve(GBP, DISCOUNT_CURVE_GBP) .discountCurve(USD, DISCOUNT_CURVE_USD) .build(); assertEquals(test.getCurves().size(), 2); assertEquals(test.getCurves().get(DISCOUNT_CURVE_GBP.getName()), DISCOUNT_CURVE_GBP); assertEquals(test.getCurves().get(DISCOUNT_CURVE_USD.getName()), DISCOUNT_CURVE_USD); }
public void test_findData() { SabrParametersIborCapletFloorletVolatilities test = SabrParametersIborCapletFloorletVolatilities.of(NAME, EUR_EURIBOR_3M, DATE_TIME, PARAM); assertEquals(test.findData(PARAM.getAlphaCurve().getName()), Optional.of(PARAM.getAlphaCurve())); assertEquals(test.findData(PARAM.getBetaCurve().getName()), Optional.of(PARAM.getBetaCurve())); assertEquals(test.findData(PARAM.getRhoCurve().getName()), Optional.of(PARAM.getRhoCurve())); assertEquals(test.findData(PARAM.getNuCurve().getName()), Optional.of(PARAM.getNuCurve())); assertEquals(test.findData(PARAM.getShiftCurve().getName()), Optional.of(PARAM.getShiftCurve())); assertEquals(test.findData(SurfaceName.of("Rubbish")), Optional.empty()); }
public void test_getCurves_withGroup() { ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE) .discountCurve(GBP, DISCOUNT_CURVE_GBP) .discountCurve(USD, DISCOUNT_CURVE_USD) .build(); CurveGroupName group = CurveGroupName.of("GRP"); assertEquals(test.getCurves(group).size(), 2); assertEquals(test.getCurves(group).get(CurveId.of(group, DISCOUNT_CURVE_GBP.getName())), DISCOUNT_CURVE_GBP); assertEquals(test.getCurves(group).get(CurveId.of(group, DISCOUNT_CURVE_USD.getName())), DISCOUNT_CURVE_USD); }
public void test_of() { Curve test = ParallelShiftedCurve.of(CONSTANT_CURVE, ShiftType.RELATIVE, 0.1d); assertThat(test.yValue(0)).isEqualTo(3.3d, offset(1e-10)); assertThat(test.yValue(1)).isEqualTo(3.3d, offset(1e-10)); assertThat(test.getName()).isEqualTo(METADATA.getCurveName()); assertThat(test.getParameterCount()).isEqualTo(2); assertThat(test.getParameter(0)).isEqualTo(3d); assertThat(test.getParameter(1)).isEqualTo(0.1d); assertThat(test.getParameterMetadata(0)).isEqualTo(ParameterMetadata.empty()); assertThat(test.getParameterMetadata(1)).isEqualTo(LabelParameterMetadata.of("RelativeShift")); assertThat(test.getMetadata()).isEqualTo(METADATA); }
public void test_findData() { ImmutableLegalEntityDiscountingProvider test = ImmutableLegalEntityDiscountingProvider.builder() .issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)) .issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)) .repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_ISSUER, GBP), DSC_FACTORS_REPO)) .repoCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_REPO_ISSUER)) .valuationDate(DATE) .build(); assertEquals(test.findData(DSC_FACTORS_ISSUER.getCurve().getName()), Optional.of(DSC_FACTORS_ISSUER.getCurve())); assertEquals(test.findData(DSC_FACTORS_REPO.getCurve().getName()), Optional.of(DSC_FACTORS_REPO.getCurve())); assertEquals(test.findData(CurveName.of("Rubbish")), Optional.empty()); }