public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 1303639584: // curveCurrency this.curveCurrency = (Currency)newValue; break; case -1731780257: // yearFraction this.yearFraction = (double?)newValue.Value; break; case 575402001: // currency this.currency = (Currency)newValue; break; case -393084371: // repoGroup this.repoGroup = (RepoGroup)newValue; break; case 564403871: // sensitivity this.sensitivity = (double?)newValue.Value; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
//------------------------------------------------------------------------- public FunctionRequirements requirements(SecurityId securityId, LegalEntityId issuerId, Currency currency) { // repo RepoGroup repoKey = repoCurveSecurityGroups.get(securityId); if (repoKey == null) { repoKey = repoCurveGroups.get(issuerId); } if (repoKey == null) { throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no repo curve defined for '{}' and '{}'", securityId, issuerId)); } CurveId repoCurveId = repoCurves.get(Pair.of(repoKey, currency)); if (repoCurveId == null) { throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no repo curve defined for '{}' and '{}'", securityId, issuerId)); } // issuer LegalEntityGroup issuerKey = issuerCurveGroups.get(issuerId); if (issuerKey == null) { throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no issuer curve defined for '{}'", issuerId)); } CurveId issuerCurveId = issuerCurves.get(Pair.of(issuerKey, currency)); if (issuerCurveId == null) { throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no issuer curve defined for '{}'", issuerId)); } // result return(FunctionRequirements.builder().valueRequirements(ImmutableSet.of(repoCurveId, issuerCurveId)).outputCurrencies(currency).observableSource(observableSource).build()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @ImmutableValidator private void validate() private void validate() { foreach (KeyValuePair <Pair <RepoGroup, Currency>, DiscountFactors> entry in repoCurves.entrySet()) { if (!entry.Value.ValuationDate.isEqual(valuationDate)) { throw new System.ArgumentException("Invalid valuation date for the repo curve: " + entry.Value); } RepoGroup group = entry.Key.First; if (!repoCurveGroups.containsValue(group) && !repoCurveSecurityGroups.containsValue(group)) { throw new System.ArgumentException("No map to the repo group from ID: " + group); } } foreach (KeyValuePair <Pair <LegalEntityGroup, Currency>, DiscountFactors> entry in issuerCurves.entrySet()) { if (!entry.Value.ValuationDate.isEqual(valuationDate)) { throw new System.ArgumentException("Invalid valuation date for the issuer curve: " + entry.Value); } if (!issuerCurveGroups.containsValue(entry.Key.First)) { throw new System.ArgumentException("No map to the legal entity group from ID: " + entry.Key.First); } } }
private RepoCurveDiscountFactors(DiscountFactors discountFactors, RepoGroup repoGroup) { JodaBeanUtils.notNull(discountFactors, "discountFactors"); JodaBeanUtils.notNull(repoGroup, "repoGroup"); this.discountFactors = discountFactors; this.repoGroup = repoGroup; }
public RepoCurveDiscountFactors repoCurveDiscountFactors(LegalEntityId issuerId, Currency currency) { RepoGroup repoGroup = lookup.RepoCurveGroups.get(issuerId); if (repoGroup == null) { throw new MarketDataNotFoundException("Unable to find repo curve mapping for ID: " + issuerId); } return(repoCurveDiscountFactors(repoGroup, currency)); }
// lookup the discount factors for the repo group private RepoCurveDiscountFactors repoCurveDiscountFactors(RepoGroup repoGroup, Currency currency) { DiscountFactors discountFactors = repoCurves.get(Pair.of(repoGroup, currency)); if (discountFactors == null) { throw new System.ArgumentException("Unable to find repo curve: " + repoGroup + ", " + currency); } return(RepoCurveDiscountFactors.of(discountFactors, repoGroup)); }
public RepoCurveDiscountFactors repoCurveDiscountFactors(LegalEntityId issuerId, Currency currency) { RepoGroup repoGroup = repoCurveGroups.get(issuerId); if (repoGroup == null) { throw new System.ArgumentException("Unable to find map for ID: " + issuerId); } return(repoCurveDiscountFactors(repoGroup, currency)); }
public virtual void test_loadAllDates() { LocalDate sampleDate = ALL_DATES[3]; // 2017-04-21 ImmutableList <LocalDate> expDates = ImmutableList.of(LocalDate.of(2017, 0x7, 21), LocalDate.of(2017, 10, 0x7), LocalDate.of(2018, 4, 13), LocalDate.of(2019, 4, 12), LocalDate.of(2020, 3, 20), LocalDate.of(2021, 3, 19), LocalDate.of(2022, 3, 19), LocalDate.of(2023, 3, 17), LocalDate.of(2024, 6, 17), LocalDate.of(2025, 3, 18), LocalDate.of(2026, 3, 20), LocalDate.of(2027, 3, 20), LocalDate.of(2031, 12, 19), LocalDate.of(2037, 3, 17), LocalDate.of(2047, 3, 17), LocalDate.of(2056, 3, 17)); ImmutableList <string> expTenors = ImmutableList.of("3M", "6M", "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "15Y", "20Y", "30Y", "40Y"); RepoGroup repoGroup = RepoGroup.of("JP-REPO"); DoubleArray expRepoXValues = DoubleArray.of(3, n => ACT_365F.relativeYearFraction(sampleDate, expDates.get(n))); DoubleArray expRepoYValues = DoubleArray.of(-0.0019521, -0.0016021, -0.0022521); ImmutableList <LabelDateParameterMetadata> expRepoMetadata = IntStream.range(0, 3).mapToObj(n => LabelDateParameterMetadata.of(expDates.get(n), expTenors.get(n))).collect(Guavate.toImmutableList()); LegalEntityGroup legalEntityGroup = LegalEntityGroup.of("JP-GOVT"); DoubleArray expIssuerXValues = DoubleArray.of(expDates.size(), n => ACT_365F.relativeYearFraction(sampleDate, expDates.get(n))); DoubleArray expIssuerYValues = DoubleArray.of(-0.0019511690511744527, -0.001497422302092893, -0.0021798583657932176, -0.002215700360912938, -0.0021722324679574866, -0.001922059591219172, -0.0015461646763548528, -0.0014835851245462084, -0.001118669580570464, -5.476767138782941E-4, -2.2155596172855965E-4, 2.0333291172821893E-5, 0.00284500423293463, 0.005876533417933958, 0.007957581583531789, 0.009134630405512047); ImmutableList <LabelDateParameterMetadata> expIssuerMetadata = IntStream.range(0, expDates.size()).mapToObj(n => LabelDateParameterMetadata.of(expDates.get(n), expTenors.get(n))).collect(Guavate.toImmutableList()); ImmutableListMultimap <LocalDate, LegalEntityCurveGroup> allCurves = LegalEntityRatesCurvesCsvLoader.loadAllDates(ResourceLocator.of(GROUPS), ResourceLocator.of(SETTINGS), ImmutableList.of(ResourceLocator.of(CURVES_1), ResourceLocator.of(CURVES_2))); //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method: assertTrue(allCurves.Keys.containsAll(ALL_DATES)); ImmutableList <LegalEntityCurveGroup> groups = allCurves.get(sampleDate); assertEquals(groups.size(), 2); // group 0 LegalEntityCurveGroup group0 = groups.get(0); assertEquals(group0.Name, CurveGroupName.of("Default1")); // repo assertEquals(group0.RepoCurves.size(), 1); Curve repoCurve = group0.RepoCurves.get(Pair.of(repoGroup, JPY)); InterpolatedNodalCurve expectedRepoCurve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("JP-REPO-1"), ACT_365F, expRepoMetadata), expRepoXValues, expRepoYValues, CurveInterpolators.LINEAR, CurveExtrapolators.FLAT, CurveExtrapolators.FLAT); assertEquals(repoCurve, expectedRepoCurve); // issuer assertEquals(group0.IssuerCurves.size(), 2); Curve issuerCurve = group0.IssuerCurves.get(Pair.of(legalEntityGroup, JPY)); InterpolatedNodalCurve expectedIssuerCurve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("JP-GOVT-1"), ACT_365F, expIssuerMetadata), expIssuerXValues, expIssuerYValues, CurveInterpolators.LINEAR, CurveExtrapolators.FLAT, CurveExtrapolators.FLAT); assertEquals(issuerCurve, expectedIssuerCurve); Curve usIssuerCurve = group0.IssuerCurves.get(Pair.of(LegalEntityGroup.of("US-GOVT"), USD)); expectedIssuerCurve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("US-GOVT"), ACT_360, expIssuerMetadata), DoubleArray.of(expDates.size(), n => ACT_360.relativeYearFraction(sampleDate, expDates.get(n))), expIssuerYValues, CurveInterpolators.NATURAL_SPLINE, CurveExtrapolators.FLAT, CurveExtrapolators.FLAT); assertEquals(usIssuerCurve, expectedIssuerCurve); // group 1 LegalEntityCurveGroup group1 = groups.get(1); assertEquals(group1.Name, CurveGroupName.of("Default2")); // repo repoCurve = group1.RepoCurves.get(Pair.of(repoGroup, JPY)); expectedRepoCurve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("JP-REPO-2"), ACT_365F, expRepoMetadata), expRepoXValues, expRepoYValues, CurveInterpolators.DOUBLE_QUADRATIC, CurveExtrapolators.LINEAR, CurveExtrapolators.LINEAR); assertEquals(repoCurve, expectedRepoCurve); // issuer assertEquals(group1.IssuerCurves.size(), 1); issuerCurve = group1.IssuerCurves.get(Pair.of(legalEntityGroup, JPY)); expectedIssuerCurve = InterpolatedNodalCurve.of(Curves.zeroRates(CurveName.of("JP-GOVT-2"), ACT_365F, expIssuerMetadata), expIssuerXValues, expIssuerYValues, CurveInterpolators.DOUBLE_QUADRATIC, CurveExtrapolators.LINEAR, CurveExtrapolators.LINEAR); assertEquals(issuerCurve, expectedIssuerCurve); }
private RepoCurveZeroRateSensitivity(Currency curveCurrency, double yearFraction, Currency currency, RepoGroup repoGroup, double sensitivity) { JodaBeanUtils.notNull(curveCurrency, "curveCurrency"); JodaBeanUtils.notNull(currency, "currency"); JodaBeanUtils.notNull(repoGroup, "repoGroup"); this.curveCurrency = curveCurrency; this.yearFraction = yearFraction; this.currency = currency; this.repoGroup = repoGroup; this.sensitivity = sensitivity; }
// lookup the discount factors for the repo group private RepoCurveDiscountFactors repoCurveDiscountFactors(RepoGroup repoGroup, Currency currency) { CurveId curveId = lookup.RepoCurves.get(Pair.of(repoGroup, currency)); if (curveId == null) { throw new MarketDataNotFoundException("Unable to find repo curve: " + repoGroup + ", " + currency); } Curve curve = marketData.getValue(curveId); DiscountFactors df = DiscountFactors.of(currency, ValuationDate, curve); return(RepoCurveDiscountFactors.of(df, repoGroup)); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case -91613053: // discountFactors this.discountFactors = (DiscountFactors)newValue; break; case -393084371: // repoGroup this.repoGroup = (RepoGroup)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
private static void createKey(CurveName curveName, CurveGroupName curveGroup, string curveTypeStr, string referenceStr, string currencyStr, IDictionary <CurveGroupName, IDictionary <Pair <RepoGroup, Currency>, CurveName> > repoGroups, IDictionary <CurveGroupName, IDictionary <Pair <LegalEntityGroup, Currency>, CurveName> > legalEntityGroups) { Currency currency = Currency.of(currencyStr); if (REPO.Equals(curveTypeStr.ToLower(Locale.ENGLISH), StringComparison.OrdinalIgnoreCase)) { RepoGroup repoGroup = RepoGroup.of(referenceStr); repoGroups.computeIfAbsent(curveGroup, k => new LinkedHashMap <>()).put(Pair.of(repoGroup, currency), curveName); } else if (ISSUER.Equals(curveTypeStr.ToLower(Locale.ENGLISH), StringComparison.OrdinalIgnoreCase)) { LegalEntityGroup legalEntiryGroup = LegalEntityGroup.of(referenceStr); legalEntityGroups.computeIfAbsent(curveGroup, k => new LinkedHashMap <>()).put(Pair.of(legalEntiryGroup, currency), curveName); } else { throw new System.ArgumentException(Messages.format("Unsupported curve type: {}", curveTypeStr)); } }
/// <summary> /// Obtains an instance from zero rate sensitivity and group. /// </summary> /// <param name="zeroRateSensitivity"> the zero rate sensitivity </param> /// <param name="repoGroup"> the group </param> /// <returns> the point sensitivity object </returns> public static RepoCurveZeroRateSensitivity of(ZeroRateSensitivity zeroRateSensitivity, RepoGroup repoGroup) { return(of(zeroRateSensitivity.CurveCurrency, zeroRateSensitivity.YearFraction, zeroRateSensitivity.Currency, repoGroup, zeroRateSensitivity.Sensitivity)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance from the curve currency, date, group and value. /// <para> /// The currency representing the curve is used also for the sensitivity currency. /// /// </para> /// </summary> /// <param name="currency"> the currency of the curve and sensitivity </param> /// <param name="yearFraction"> the year fraction that was looked up on the curve </param> /// <param name="repoGroup"> the group </param> /// <param name="sensitivity"> the value of the sensitivity </param> /// <returns> the point sensitivity object </returns> public static RepoCurveZeroRateSensitivity of(Currency currency, double yearFraction, RepoGroup repoGroup, double sensitivity) { return(of(currency, yearFraction, currency, repoGroup, sensitivity)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance based on discount factors and group. /// </summary> /// <param name="discountFactors"> the discount factors </param> /// <param name="group"> the group </param> /// <returns> the repo curve discount factors </returns> public static RepoCurveDiscountFactors of(DiscountFactors discountFactors, RepoGroup group) { return(new RepoCurveDiscountFactors(discountFactors, group)); }