// calculate one measure //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: private com.opengamma.strata.collect.result.Result<?> calculate(com.opengamma.strata.calc.Measure measure, com.opengamma.strata.product.cms.ResolvedCmsTrade trade, CmsMeasureCalculations calculations, com.opengamma.strata.measure.rate.RatesScenarioMarketData ratesMarketData, com.opengamma.strata.measure.swaption.SwaptionScenarioMarketData swaptionMarketData) private Result <object> calculate(Measure measure, ResolvedCmsTrade trade, CmsMeasureCalculations calculations, RatesScenarioMarketData ratesMarketData, SwaptionScenarioMarketData swaptionMarketData) { SingleMeasureCalculation calculator = CALCULATORS.get(measure); if (calculator == null) { return(Result.failure(FailureReason.UNSUPPORTED, "Unsupported measure for SwaptionTrade: {}", measure)); } return(Result.of(() => calculator(calculations, trade, ratesMarketData, swaptionMarketData))); }
public virtual void test_simpleMeasures() { CmsTradeCalculationFunction function = new CmsTradeCalculationFunction(); ScenarioMarketData md = marketData(); RatesProvider provider = RATES_LOOKUP.ratesProvider(md.scenario(0)); SabrExtrapolationReplicationCmsTradePricer pricer = new SabrExtrapolationReplicationCmsTradePricer(new SabrExtrapolationReplicationCmsProductPricer(new SabrExtrapolationReplicationCmsLegPricer(SabrExtrapolationReplicationCmsPeriodPricer.of(CUT_OFF_STRIKE, MU)))); ResolvedCmsTrade resolved = TRADE.resolve(REF_DATA); MultiCurrencyAmount expectedPv = pricer.presentValue(resolved, provider, VOLS); ISet <Measure> measures = ImmutableSet.of(Measures.PRESENT_VALUE, Measures.RESOLVED_TARGET); assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PRESENT_VALUE, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)))).containsEntry(Measures.RESOLVED_TARGET, Result.success(TRADE.resolve(REF_DATA))); }
//------------------------------------------------------------------------- //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(com.opengamma.strata.product.cms.CmsTrade trade, java.util.Set<com.opengamma.strata.calc.Measure> measures, com.opengamma.strata.calc.runner.CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData scenarioMarketData, com.opengamma.strata.basics.ReferenceData refData) public virtual IDictionary <Measure, Result <object> > calculate(CmsTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData) { // expand the trade once for all measures and all scenarios ResolvedCmsTrade resolved = trade.resolve(refData); RatesMarketDataLookup ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup)); RatesScenarioMarketData ratesMarketData = ratesLookup.marketDataView(scenarioMarketData); SwaptionMarketDataLookup swaptionLookup = parameters.getParameter(typeof(SwaptionMarketDataLookup)); SwaptionScenarioMarketData swaptionMarketData = swaptionLookup.marketDataView(scenarioMarketData); CmsSabrExtrapolationParams cmsParams = parameters.getParameter(typeof(CmsSabrExtrapolationParams)); CmsMeasureCalculations calculations = new CmsMeasureCalculations(cmsParams); // loop around measures, calculating all scenarios for one measure //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> results = new java.util.HashMap<>(); IDictionary <Measure, Result <object> > results = new Dictionary <Measure, Result <object> >(); foreach (Measure measure in measures) { results[measure] = calculate(measure, resolved, calculations, ratesMarketData, swaptionMarketData); } return(results); }