// 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.swaption.ResolvedSwaptionTrade trade, com.opengamma.strata.measure.rate.RatesScenarioMarketData ratesMarketData, SwaptionScenarioMarketData swaptionMarketData) private Result <object> calculate(Measure measure, ResolvedSwaptionTrade trade, 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(trade, ratesMarketData, swaptionMarketData))); }
public virtual void test_simpleMeasures() { SwaptionTradeCalculationFunction function = new SwaptionTradeCalculationFunction(); ScenarioMarketData md = marketData(); RatesProvider provider = RATES_LOOKUP.ratesProvider(md.scenario(0)); NormalSwaptionTradePricer pricer = NormalSwaptionTradePricer.DEFAULT; ResolvedSwaptionTrade resolved = TRADE.resolve(REF_DATA); CurrencyAmount expectedPv = pricer.presentValue(resolved, provider, NORMAL_VOL_SWAPTION_PROVIDER_USD); 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(CurrencyScenarioArray.of(ImmutableList.of(expectedPv)))).containsEntry(Measures.RESOLVED_TARGET, Result.success(RTRADE)); }
//------------------------------------------------------------------------- //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.swaption.SwaptionTrade 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(SwaptionTrade trade, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData) { // expand the trade once for all measures and all scenarios ResolvedSwaptionTrade 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); // 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, ratesMarketData, swaptionMarketData); } return(results); }