// for historical compatibility, we determine known format by looking for these specific things // the new approach is to require either the 'Reference' or the 'Sensitivity Type' column private static bool knownReference(string refStr) { try { Optional <IborIndex> ibor = IborIndex.extendedEnum().find(refStr); if (ibor.Present) { return(true); } else { Optional <FloatingRateName> frName = FloatingRateName.extendedEnum().find(refStr); if (frName.Present) { return(true); } else if (refStr.Length == 3) { Currency.of(refStr); // this may throw an exception validating the string return(true); } else { return(false); } } } catch (Exception) { return(false); } }
public virtual void test_getFloatingRateName() { foreach (IborIndex index in IborIndex.extendedEnum().lookupAll().values()) { string name = index.Name.Substring(0, index.Name.LastIndexOf('-')); assertEquals(index.FloatingRateName, FloatingRateName.of(name)); } }
//------------------------------------------------------------------------- // parses the currency as a column or from the reference private static Currency parseCurrency(CsvRow row, CurveName reference) { Optional <string> currencyStr = row.findValue(CURRENCY_HEADER); if (currencyStr.Present) { return(LoaderUtils.parseCurrency(currencyStr.get())); } string referenceStr = reference.Name.ToUpper(Locale.ENGLISH); try { Optional <IborIndex> ibor = IborIndex.extendedEnum().find(referenceStr); if (ibor.Present) { return(ibor.get().Currency); } else { Optional <FloatingRateName> frName = FloatingRateName.extendedEnum().find(referenceStr); if (frName.Present) { return(frName.get().Currency); } else if (referenceStr.Length == 3) { return(Currency.of(referenceStr)); } else if (referenceStr.Length > 3 && referenceStr[3] == '-' || referenceStr[3] == '_') { return(LoaderUtils.parseCurrency(referenceStr.Substring(0, 3))); } else { // drop out to exception } } } catch (Exception) { // drop out to exception } throw new System.ArgumentException("Unable to parse currency from reference, consider adding a 'Currency' column"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(dataProvider = "name") public void test_extendedEnum(IborIndex convention, String name) public virtual void test_extendedEnum(IborIndex convention, string name) { ImmutableMap <string, IborIndex> map = IborIndex.extendedEnum().lookupAll(); assertEquals(map.get(name), convention); }
private static FraConvention createByName(string name) { return(IborIndex.extendedEnum().find(name).map(index => ImmutableFraConvention.of(index)).orElse(null)); }