/** * Returns a key identifying the market data with the specified ID and field name. * * @param id the ID of the quote * @param fieldName the field name of the market data record containing the quote data * @return a key identifying the market data with the specified ID and field name */ public static QuoteScenarioArrayId of(StandardId id, FieldName fieldName) { return new QuoteScenarioArrayId(QuoteId.of(id, fieldName)); }
public void test_of_1arg() { QuoteId test = QuoteId.of(ID1); assertEquals(test.getStandardId(), ID1); assertEquals(test.getFieldName(), FieldName.MARKET_VALUE); assertEquals(test.getObservableSource(), ObservableSource.NONE); assertEquals(test.getMarketDataType(), Double.class); assertEquals(test.toString(), "QuoteId:OG-Ticker~1/MarketValue"); }
/** * Obtains an instance used to obtain an observable value. * <p> * The market data source is {@link ObservableSource#NONE}. * * @param standardId the standard identifier of the data in the underlying data provider * @param fieldName the name of the field in the market data record holding the data * @return the identifier */ public static QuoteId of(StandardId standardId, FieldName fieldName) { return new QuoteId(standardId, fieldName, ObservableSource.NONE); }
private LocalDate calculateLastFixingDate(LocalDate valuationDate, ReferenceData refData) { SecurityId secId = SecurityId.of(rateId.getStandardId()); // quote must also be security IborFutureTrade trade = template.createTrade(valuationDate, secId, 1, 1, 1, refData); return trade.getProduct().getFixingDate(); }
@Override public IborFutureTrade trade(double quantity, MarketData marketData, ReferenceData refData) { LocalDate valuationDate = marketData.getValuationDate(); double price = marketPrice(marketData) + additionalSpread; SecurityId secId = SecurityId.of(rateId.getStandardId()); // quote must also be security return template.createTrade(valuationDate, secId, quantity, 1d, price, refData); }
public void test_of_2args() { QuoteId test = QuoteId.of(ID1, FIELD2); assertEquals(test.getStandardId(), ID1); assertEquals(test.getFieldName(), FIELD2); assertEquals(test.getObservableSource(), ObservableSource.NONE); assertEquals(test.getMarketDataType(), Double.class); assertEquals(test.toString(), "QuoteId:OG-Ticker~1/Field2"); }
/** * Obtains an instance used to obtain an observable value, * specifying the source of observable market data. * * @param standardId the standard identifier of the data in the underlying data provider * @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 QuoteId of(StandardId standardId, FieldName fieldName, ObservableSource obsSource) { return new QuoteId(standardId, fieldName, obsSource); }
public void test_serialization() { QuoteId test = QuoteId.of(ID1); assertSerialization(test); }
public void test_of_3args() { QuoteId test = QuoteId.of(ID1, FIELD2, OBS_SOURCE2); assertEquals(test.getStandardId(), ID1); assertEquals(test.getFieldName(), FIELD2); assertEquals(test.getObservableSource(), OBS_SOURCE2); assertEquals(test.getMarketDataType(), Double.class); assertEquals(test.toString(), "QuoteId:OG-Ticker~1/Field2/Vendor2"); }
/** * Obtains an instance used to obtain an observable value. * <p> * The field name containing the data is {@link FieldName#MARKET_VALUE} and the market * data source is {@link ObservableSource#NONE}. * * @param standardId the standard identifier of the data in the underlying data provider * @return the identifier */ public static QuoteId of(StandardId standardId) { return new QuoteId(standardId, FieldName.MARKET_VALUE, ObservableSource.NONE); }
private static void parseSingle( Predicate<LocalDate> datePredicate, CharSource resource, Map<LocalDate, ImmutableMap.Builder<QuoteId, Double>> mutableMap) { try { CsvFile csv = CsvFile.of(resource, true); for (CsvRow row : csv.rows()) { String dateText = row.getField(DATE_FIELD); LocalDate date = LoaderUtils.parseDate(dateText); if (datePredicate.test(date)) { String symbologyStr = row.getField(SYMBOLOGY_FIELD); String tickerStr = row.getField(TICKER_FIELD); String fieldNameStr = row.getField(FIELD_NAME_FIELD); String valueStr = row.getField(VALUE_FIELD); double value = Double.valueOf(valueStr); StandardId id = StandardId.of(symbologyStr, tickerStr); FieldName fieldName = fieldNameStr.isEmpty() ? FieldName.MARKET_VALUE : FieldName.of(fieldNameStr); ImmutableMap.Builder<QuoteId, Double> builderForDate = mutableMap.computeIfAbsent(date, k -> ImmutableMap.builder()); builderForDate.put(QuoteId.of(id, fieldName), value); } } } catch (RuntimeException ex) { throw new IllegalArgumentException( Messages.format("Error processing resource as CSV file: {}", resource), ex); } }
@Override public QuoteId withObservableSource(ObservableSource obsSource) { return new QuoteId(standardId, fieldName, obsSource); }
public void getMarketDataKey() { QuoteId quoteId = QuoteId.of(StandardId.of("test", "1"), FieldName.of("fieldName"), ObservableSource.NONE); assertThat(KEY.getMarketDataId()).isEqualTo(quoteId); assertThat(QuoteScenarioArrayId.of(quoteId)).isEqualTo(KEY); }
private static List<CurveDefinition> parseSingle( CharSource resource, Map<CurveName, LoadedCurveSettings> settingsMap) { CsvFile csv = CsvFile.of(resource, true); Map<CurveName, List<CurveNode>> allNodes = new HashMap<>(); for (CsvRow row : csv.rows()) { String curveNameStr = row.getField(CURVE_NAME); String label = row.getField(CURVE_LABEL); String symbologyQuoteStr = row.getField(CURVE_SYMBOLOGY_QUOTE); String tickerQuoteStr = row.getField(CURVE_TICKER_QUOTE); String fieldQuoteStr = row.getField(CURVE_FIELD_QUOTE); String typeStr = row.getField(CURVE_TYPE); String conventionStr = row.getField(CURVE_CONVENTION); String timeStr = row.getField(CURVE_TIME); String dateStr = row.findField(CURVE_DATE).orElse(""); String minGapStr = row.findField(CURVE_MIN_GAP).orElse(""); String clashActionStr = row.findField(CURVE_CLASH_ACTION).orElse(""); String spreadStr = row.findField(CURVE_SPREAD).orElse(""); CurveName curveName = CurveName.of(curveNameStr); StandardId quoteStandardId = StandardId.of(symbologyQuoteStr, tickerQuoteStr); FieldName quoteField = fieldQuoteStr.isEmpty() ? FieldName.MARKET_VALUE : FieldName.of(fieldQuoteStr); QuoteId quoteId = QuoteId.of(quoteStandardId, quoteField); double spread = spreadStr.isEmpty() ? 0d : Double.parseDouble(spreadStr); CurveNodeDate date = parseDate(dateStr); CurveNodeDateOrder order = parseDateOrder(minGapStr, clashActionStr); List<CurveNode> curveNodes = allNodes.computeIfAbsent(curveName, k -> new ArrayList<>()); curveNodes.add(createCurveNode(typeStr, conventionStr, timeStr, label, quoteId, spread, date, order)); } return buildCurveDefinition(settingsMap, allNodes); }
private List<IsdaCreditCurveNode> createsNode( DaysAdjustment spotDateOffset, BusinessDayAdjustment businessDayAdjustment, DayCount depositDayCount, DayCount swapDayCount, Frequency paymentFrequency, int[] termMonths, int[] swapYears, String[] idValues) { int nInstruments = idValues.length; int nTerms = termMonths.length; List<IsdaCreditCurveNode> nodes = new ArrayList<>(nInstruments); for (int i = 0; i < nTerms; i++) { Tenor tenor = Tenor.ofMonths(termMonths[i]); nodes.add(DepositIsdaCreditCurveNode.of( QuoteId.of(StandardId.of("OG", idValues[i])), spotDateOffset, businessDayAdjustment, tenor, depositDayCount)); } for (int i = nTerms; i < nInstruments; i++) { Tenor tenor = Tenor.ofYears(swapYears[i - nTerms]); nodes.add(SwapIsdaCreditCurveNode.of( QuoteId.of(StandardId.of("OG", idValues[i])), spotDateOffset, businessDayAdjustment, tenor, swapDayCount, paymentFrequency)); } return nodes; }
public static MarketData allQuotes( LocalDate valuationDate, double[] dscOisQuotes, String[] dscIdValues, double[] fwd3MarketQuotes, String[] fwd3IdValue, double[] fwd6MarketQuotes, String[] fwd6IdValue) { /* All quotes for the curve calibration */ ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(valuationDate); for (int i = 0; i < dscOisQuotes.length; i++) { builder.addValue(QuoteId.of(StandardId.of(SCHEME, dscIdValues[i])), dscOisQuotes[i]); } for (int i = 0; i < fwd3MarketQuotes.length; i++) { builder.addValue(QuoteId.of(StandardId.of(SCHEME, fwd3IdValue[i])), fwd3MarketQuotes[i]); } for (int i = 0; i < fwd6MarketQuotes.length; i++) { builder.addValue(QuoteId.of(StandardId.of(SCHEME, fwd6IdValue[i])), fwd6MarketQuotes[i]); } return builder.build(); }
public void coverage() { CdsIsdaCreditCurveNode test1 = CdsIsdaCreditCurveNode.ofQuotedSpread(TEMPLATE, QUOTE_ID, LEGAL_ENTITY, 0.01); coverImmutableBean(test1); CdsIsdaCreditCurveNode test2 = CdsIsdaCreditCurveNode.ofPointsUpfront( TenorCdsTemplate.of(TENOR_10Y, CdsConventions.EUR_GB_STANDARD), QuoteId.of(StandardId.of("OG-Ticker", "Cds2")), StandardId.of("OG", "DEF"), 0.01); QuoteId.of(StandardId.of("OG-Ticker", "Deposit2")); coverBeanEquals(test1, test2); }
public void coverage() { CdsIndexIsdaCreditCurveNode test1 = CdsIndexIsdaCreditCurveNode.ofQuotedSpread(TEMPLATE, QUOTE_ID, INDEX_ID, LEGAL_ENTITIES, 0.01); coverImmutableBean(test1); CdsIndexIsdaCreditCurveNode test2 = CdsIndexIsdaCreditCurveNode.ofPointsUpfront( TenorCdsTemplate.of(TENOR_10Y, CdsConventions.EUR_GB_STANDARD), QuoteId.of(StandardId.of("OG-Ticker", "Cdx2")), StandardId.of("OG", "DEF"), ImmutableList.of(StandardId.of("OG", "DEF1"), StandardId.of("OG", "DEF2")), 0.01); QuoteId.of(StandardId.of("OG-Ticker", "Deposit2")); coverBeanEquals(test1, test2); }
for (int i = 0; i < nMoneyMarket; i++) { Tenor tenor = Tenor.ofMonths(mmMonths[i]); nodes.add(DepositIsdaCreditCurveNode.of(QuoteId.of(StandardId.of("OG", idValues[i])), ADJ_3D, BUS_ADJ, tenor, ACT_360)); QuoteId.of(StandardId.of("OG", idValues[i])), ADJ_3D, BUS_ADJ, tenor, THIRTY_U_360, Frequency.P6M)); QuoteId.of(StandardId.of("OG", idValues[nInstruments])), ADJ_3D, BUS_ADJ, Tenor.ofMonths(18), ACT_360)); ImmutableMarketDataBuilder builder = ImmutableMarketData.builder(snapDate); for (int i = 0; i < rates.length; i++) { builder.addValue(QuoteId.of(StandardId.of("OG", idValues[i])), rates[i]); builder.addValue(QuoteId.of(StandardId.of("OG", idValues[nInstruments])), rates[nInstruments]); ImmutableMarketData quotes = builder.build(); IsdaCreditCurveDefinition curveDefinition = IsdaCreditCurveDefinition.of(