/** * Obtains an instance used to obtain an observable value of the index. * <p> * The field name containing the data is {@link FieldName#MARKET_VALUE} and the market * data source is {@link ObservableSource#NONE}. * * @param index the index * @return the identifier */ public static IndexQuoteId of(Index index) { return new IndexQuoteId(index, FieldName.MARKET_VALUE, ObservableSource.NONE); }
public void test_of_1arg() { IndexQuoteId test = IndexQuoteId.of(GBP_SONIA); assertEquals(test.getIndex(), GBP_SONIA); assertEquals(test.getFieldName(), FieldName.MARKET_VALUE); assertEquals(test.getObservableSource(), ObservableSource.NONE); assertEquals(test.getStandardId(), StandardId.of("OG-Index", GBP_SONIA.getName())); assertEquals(test.getMarketDataType(), Double.class); assertEquals(test.toString(), "IndexQuoteId:GBP-SONIA/MarketValue"); }
/** * Calibrates a single curve group, containing one or more curves. * <p> * The calibration is defined using {@link RatesCurveGroupDefinition}. * Observable market data, time-series and FX are also needed to complete the calibration. * The valuation date is defined by the market data. * <p> * The Jacobian matrices are computed and stored in curve metadata. * * @param curveGroupDefn the curve group definition * @param marketData the market data required to build a trade for the instrument, including time-series * @param refData the reference data, used to resolve the trades * @return the rates provider resulting from the calibration */ public ImmutableRatesProvider calibrate( RatesCurveGroupDefinition curveGroupDefn, MarketData marketData, ReferenceData refData) { Map<Index, LocalDateDoubleTimeSeries> timeSeries = marketData.getTimeSeriesIds().stream() .flatMap(filtering(IndexQuoteId.class)) .collect(toImmutableMap(id -> id.getIndex(), id -> marketData.getTimeSeries(id))); ImmutableRatesProvider knownData = ImmutableRatesProvider.builder(marketData.getValuationDate()) .fxRateProvider(MarketDataFxRateProvider.of(marketData)) .timeSeries(timeSeries) .build(); return calibrate(ImmutableList.of(curveGroupDefn), knownData, marketData, refData); }
public void test_of_2args() { IndexQuoteId test = IndexQuoteId.of(GBP_SONIA, FIELD); assertEquals(test.getIndex(), GBP_SONIA); assertEquals(test.getFieldName(), FIELD); assertEquals(test.getObservableSource(), ObservableSource.NONE); assertEquals(test.getStandardId(), StandardId.of("OG-Index", GBP_SONIA.getName())); assertEquals(test.getMarketDataType(), Double.class); assertEquals(test.toString(), "IndexQuoteId:GBP-SONIA/Field"); }
public void test_serialization() { IndexQuoteId test = IndexQuoteId.of(GBP_SONIA); assertSerialization(test); }
public void test_of_3args() { IndexQuoteId test = IndexQuoteId.of(GBP_SONIA, FIELD, OBS_SOURCE); assertEquals(test.getIndex(), GBP_SONIA); assertEquals(test.getFieldName(), FIELD); assertEquals(test.getObservableSource(), OBS_SOURCE); assertEquals(test.getStandardId(), StandardId.of("OG-Index", GBP_SONIA.getName())); assertEquals(test.getMarketDataType(), Double.class); assertEquals(test.toString(), "IndexQuoteId:GBP-SONIA/Field/Vendor"); }
ts.put(IndexQuoteId.of(idx), inputProvider.timeSeries(idx));
/** * Obtains an instance used to obtain an observable value of the index, * specifying the source of observable market data. * * @param index the index * @param fieldName the name of the field in the market data record holding the data * @param obsSource the source of observable market data * @return the identifier */ public static IndexQuoteId of(Index index, FieldName fieldName, ObservableSource obsSource) { return new IndexQuoteId(index, fieldName, obsSource); }
@Override public double initialGuess(MarketData marketData, ValueType valueType) { if (ValueType.PRICE_INDEX.equals(valueType)) { PriceIndex index = template.getConvention().getFloatingLeg().getIndex(); LocalDateDoubleTimeSeries ts = marketData.getTimeSeries(IndexQuoteId.of(index)); double latestIndex = ts.getLatestValue(); double rate = marketData.getValue(rateId); double year = template.getTenor().getPeriod().getYears(); return latestIndex * Math.pow(1.0 + rate, year); } if (ValueType.ZERO_RATE.equals(valueType)) { return marketData.getValue(rateId); } throw new IllegalArgumentException("No default initial guess when value type is not 'PriceIndex' or 'ZeroRate'."); }
/** * Obtains an instance used to obtain an observable value of the index. * <p> * The market data source is {@link ObservableSource#NONE}. * * @param index the index * @param fieldName the name of the field in the market data record holding the data * @return the identifier */ public static IndexQuoteId of(Index index, FieldName fieldName) { return new IndexQuoteId(index, fieldName, ObservableSource.NONE); }
public void test_initialGuess() { FixedInflationSwapCurveNode node = FixedInflationSwapCurveNode.of(TEMPLATE, QUOTE_ID, SPREAD); LocalDate valuationDate = LocalDate.of(2015, 1, 22); double rate = 0.035; double lastPriceIndex = 123.4; LocalDateDoubleTimeSeries ts = LocalDateDoubleTimeSeries.builder() .put(LocalDate.of(2024, 10, 31), lastPriceIndex).build(); MarketData marketData = ImmutableMarketData.builder(valuationDate).addValue(QUOTE_ID, rate) .addTimeSeries(IndexQuoteId.of(PriceIndices.EU_EXT_CPI), ts).build(); assertEquals(node.initialGuess(marketData, ValueType.ZERO_RATE), rate); double priceIndexGuess = lastPriceIndex * Math.pow(1.0d + rate, TENOR_10Y.get(ChronoUnit.YEARS)); assertEquals(node.initialGuess(marketData, ValueType.PRICE_INDEX), priceIndexGuess, TOLERANCE_GUESS); }
@Override public IndexQuoteId withObservableSource(ObservableSource obsSource) { return new IndexQuoteId(index, fieldName, obsSource); }
public void market_data() { RatesCurveGroupDefinition group = GROUPS_SYN_EUR; RatesProvider multicurveTsLarge = MULTICURVE_INPUT_EUR_TSEMPTY.toBuilder().timeSeries(TS_LARGE).build(); MarketData madTsEmpty = CALIBRATOR_SYNTHETIC.marketData(group, MULTICURVE_INPUT_EUR_TSEMPTY, REF_DATA); MarketData madTsLarge = CALIBRATOR_SYNTHETIC.marketData(group, multicurveTsLarge, REF_DATA); assertEquals(madTsEmpty.getValuationDate(), VALUATION_DATE); for (CurveDefinition entry : group.getCurveDefinitions()) { ImmutableList<CurveNode> nodes = entry.getNodes(); for (CurveNode node : nodes) { ResolvedTrade tradeTsEmpty = node.resolvedTrade(1d, madTsEmpty, REF_DATA); double mqTsEmpty = MQ_MEASURES.value(tradeTsEmpty, MULTICURVE_INPUT_EUR_TSEMPTY); assertEquals(mqTsEmpty, (Double) madTsEmpty.getValue(node.requirements().iterator().next()), TOLERANCE_MQ); ResolvedTrade tradeTsLarge = node.resolvedTrade(1d, madTsLarge, REF_DATA); double mqTsLarge = MQ_MEASURES.value(tradeTsLarge, multicurveTsLarge); assertEquals(mqTsLarge, (Double) madTsLarge.getValue(node.requirements().iterator().next()), TOLERANCE_MQ); // Market Quote for Fixed v ibor swaps should have changed with the fixing if ((tradeTsLarge instanceof ResolvedSwapTrade) && // Swap Fixed v Ibor (((ResolvedSwapTrade) tradeTsLarge)).getProduct().getLegs(SwapLegType.IBOR).size() == 1) { assertTrue(Math.abs(mqTsEmpty - mqTsLarge) > TOLERANCE_MQ); } } } assertEquals(madTsEmpty.getTimeSeriesIds(), ImmutableSet.of()); assertEquals( madTsLarge.getTimeSeriesIds(), ImmutableSet.of(IndexQuoteId.of(EUR_EURIBOR_3M), IndexQuoteId.of(EUR_EURIBOR_6M))); }
ObservableId id = IndexQuoteId.of(index); double value = Double.parseDouble(valueStr); LocalDate date;