/** * Gets the currency of the Ibor index. * * @return the currency of the index */ public Currency getCurrency() { return index.getCurrency(); }
@Override public PriceIndex toPriceIndex() { if (!type.isPrice()) { throw new IllegalStateException("Incorrect index type, expected Price: " + externalName); } return PriceIndex.of(indexName); }
public void test_gbpHicp() { PriceIndex test = PriceIndex.of("GB-HICP"); assertEquals(test.getName(), "GB-HICP"); assertEquals(test.getCurrency(), GBP); assertEquals(test.getRegion(), GB); assertEquals(test.isActive(), true); assertEquals(test.getPublicationFrequency(), Frequency.P1M); assertEquals(test.getFloatingRateName(), FloatingRateName.of("GB-HICP")); assertEquals(test.toString(), "GB-HICP"); }
public void test_gb_rpi() { assertEquals(PriceIndices.GB_RPI.getCurrency(), GBP); assertEquals(PriceIndices.GB_RPI.getDayCount(), DayCounts.ONE_ONE); assertEquals(PriceIndices.GB_RPI.getDefaultFixedLegDayCount(), DayCounts.ONE_ONE); }
public void test_getFloatingRateName() { for (PriceIndex index : PriceIndex.extendedEnum().lookupAll().values()) { assertEquals(index.getFloatingRateName(), FloatingRateName.of(index.getName())); } }
private static ImmutableMap<String, PriceIndex> loadFromCsv() { List<ResourceLocator> resources = ResourceConfig.orderedResources("PriceIndexData.csv"); Map<String, PriceIndex> map = new HashMap<>(); // files are ordered lowest priority to highest, thus Map::put is used for (ResourceLocator resource : resources) { try { CsvFile csv = CsvFile.of(resource.getCharSource(), true); for (CsvRow row : csv.rows()) { PriceIndex parsed = parsePriceIndex(row); map.put(parsed.getName(), parsed); map.put(parsed.getName().toUpperCase(Locale.ENGLISH), parsed); } } catch (RuntimeException ex) { log.log(Level.SEVERE, "Error processing resource as Price Index CSV file: " + resource, ex); return ImmutableMap.of(); } } return ImmutableMap.copyOf(map); }
/** * Obtains an instance from the specified unique name. * * @param uniqueName the unique name * @return the index * @throws IllegalArgumentException if the name is not known */ @FromString public static PriceIndex of(String uniqueName) { ArgChecker.notNull(uniqueName, "uniqueName"); return extendedEnum().lookup(uniqueName); }
private PriceIndexValues historicCurve(PriceIndex index) { LocalDateDoubleTimeSeries fixings = timeSeries(index); if (index.isActive() || fixings.isEmpty()) { throw new IllegalArgumentException("Unable to find Price index curve: " + index); } return HistoricPriceIndexValues.of(index, valuationDate, fixings); }
@Test(dataProvider = "name") public void test_name(PriceIndex convention, String name) { assertEquals(convention.getName(), name); }
@Test(dataProvider = "name") public void test_extendedEnum(PriceIndex convention, String name) { ImmutableMap<String, PriceIndex> map = PriceIndex.extendedEnum().lookupAll(); assertEquals(map.get(name), convention); }
/** * Gets the currency of the leg from the index. * * @return the currency */ public Currency getCurrency() { return index.getCurrency(); }
InflationRateCalculation calc = (InflationRateCalculation) calculation; String gearing = calc.getGearing().map(g -> " * " + SummarizerUtils.value(g.getInitialValue())).orElse(""); return calc.getIndex().getName() + gearing;
@Test(dataProvider = "name") public void test_of_lookup(PriceIndex convention, String name) { assertEquals(PriceIndex.of(name), convention); }
return (Optional) overnightOpt; Optional<PriceIndex> priceOpt = PriceIndex.extendedEnum().find(indexStr); if (priceOpt.isPresent()) { return (Optional) priceOpt;
@Override public void collectCurrencies(ImmutableSet.Builder<Currency> builder) { builder.add(index.getCurrency()); }
public void test_of_lookup_notFound() { assertThrowsIllegalArg(() -> PriceIndex.of("Rubbish")); }
private Currency getCurrency(Index index) { if (index instanceof RateIndex) { return ((RateIndex) index).getCurrency(); } else if (index instanceof PriceIndex) { return ((PriceIndex) index).getCurrency(); } throw new IllegalArgumentException("unsupported index"); }
public void test_of_lookup_null() { assertThrowsIllegalArg(() -> PriceIndex.of(null)); }
public void test_of_withoutCurrency() { InflationRateSensitivity test = InflationRateSensitivity.of(GB_HICP_OBS, 1.0); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getCurrency(), GB_HICP.getCurrency()); assertEquals(test.getObservation(), GB_HICP_OBS); assertEquals(test.getSensitivity(), 1.0); }
public void test_of() { PriceIndexObservation test = PriceIndexObservation.of(GB_HICP, FIXING_MONTH); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getFixingMonth(), FIXING_MONTH); assertEquals(test.getCurrency(), GB_HICP.getCurrency()); assertEquals(test.toString(), "PriceIndexObservation[GB-HICP on 2016-02]"); }