示例#1
0
        public Report runReport(ReportCalculationResults calculationResults, CashFlowReportTemplate reportTemplate)
        {
            int tradeCount = calculationResults.CalculationResults.RowCount;

            if (tradeCount == 0)
            {
                throw new System.ArgumentException("Calculation results is empty");
            }
            if (tradeCount > 1)
            {
                throw new System.ArgumentException(Messages.format("Unable to show cashflow report for {} trades at once. " + "Please filter the portfolio to a single trade.", tradeCount));
            }

            int columnIdx = calculationResults.Columns.IndexOf(Column.of(Measures.EXPLAIN_PRESENT_VALUE));

            if (columnIdx == -1)
            {
                throw new System.ArgumentException(Messages.format("Unable to find column for required measure '{}' in calculation results", Measures.EXPLAIN_PRESENT_VALUE));
            }

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result = calculationResults.getCalculationResults().get(0, columnIdx);
            Result <object> result = calculationResults.CalculationResults.get(0, columnIdx);

            if (result.Failure)
            {
                throw new System.ArgumentException(Messages.format("Failure result found for required measure '{}': {}", Measures.EXPLAIN_PRESENT_VALUE, result.Failure.Message));
            }
            ExplainMap explainMap = (ExplainMap)result.Value;

            return(runReport(explainMap, calculationResults.ValuationDate));
        }
        // obtains the data and calculates the grid of results
        private static void calculate(CalculationRunner runner)
        {
            // the trades that will have measures calculated
            IList <Trade> trades = createSwapTrades();

            // the columns, specifying the measures to be calculated
            IList <Column> columns = ImmutableList.of(Column.of(Measures.LEG_INITIAL_NOTIONAL), Column.of(Measures.PRESENT_VALUE), Column.of(Measures.LEG_PRESENT_VALUE), Column.of(Measures.PV01_CALIBRATED_SUM), Column.of(Measures.PAR_RATE), Column.of(Measures.ACCRUED_INTEREST), Column.of(Measures.PV01_CALIBRATED_BUCKETED), Column.of(AdvancedMeasures.PV01_SEMI_PARALLEL_GAMMA_BUCKETED));

            // use the built-in example market data
            LocalDate valuationDate = LocalDate.of(2014, 1, 22);
            ExampleMarketDataBuilder marketDataBuilder = ExampleMarketData.builder();
            MarketData marketData = marketDataBuilder.buildSnapshot(valuationDate);

            // the complete set of rules for calculating measures
            CalculationFunctions functions = StandardComponents.calculationFunctions();
            CalculationRules     rules     = CalculationRules.of(functions, marketDataBuilder.ratesLookup(valuationDate));

            // the reference data, such as holidays and securities
            ReferenceData refData = ReferenceData.standard();

            // calculate the results
            Results results = runner.calculate(rules, trades, columns, marketData, refData);

            // use the report runner to transform the engine results into a trade report
            ReportCalculationResults calculationResults = ReportCalculationResults.of(valuationDate, trades, columns, results, functions, refData);

            TradeReportTemplate reportTemplate = ExampleData.loadTradeReportTemplate("swap-report-template");
            TradeReport         tradeReport    = TradeReport.of(calculationResults, reportTemplate);

            tradeReport.writeAsciiTable(System.out);
        }
        /// <summary>
        /// Tests the full set of results against a golden copy.
        /// </summary>
        public virtual void testResults()
        {
            IList <Trade> trades = ImmutableList.of(createTrade1());

            IList <Column> columns = ImmutableList.of(Column.of(Measures.LEG_INITIAL_NOTIONAL), Column.of(Measures.PRESENT_VALUE), Column.of(Measures.LEG_PRESENT_VALUE), Column.of(Measures.PV01_CALIBRATED_SUM), Column.of(Measures.ACCRUED_INTEREST));

            ExampleMarketDataBuilder marketDataBuilder = ExampleMarketData.builder();

            LocalDate        valuationDate = LocalDate.of(2009, 7, 31);
            CalculationRules rules         = CalculationRules.of(StandardComponents.calculationFunctions(), Currency.USD, marketDataBuilder.ratesLookup(valuationDate));

            MarketData marketData = marketDataBuilder.buildSnapshot(valuationDate);

            // using the direct executor means there is no need to close/shutdown the runner
            CalculationTasks       tasks = CalculationTasks.of(rules, trades, columns, REF_DATA);
            MarketDataRequirements reqs  = tasks.requirements(REF_DATA);
            MarketData             calibratedMarketData = marketDataFactory().create(reqs, MarketDataConfig.empty(), marketData, REF_DATA);
            CalculationTaskRunner  runner = CalculationTaskRunner.of(MoreExecutors.newDirectExecutorService());
            Results results = runner.calculate(tasks, calibratedMarketData, REF_DATA);

            ReportCalculationResults calculationResults = ReportCalculationResults.of(valuationDate, trades, columns, results);

            TradeReportTemplate reportTemplate = ExampleData.loadTradeReportTemplate("swap-report-regression-test-template");
            TradeReport         tradeReport    = TradeReport.of(calculationResults, reportTemplate);

            string expectedResults = ExampleData.loadExpectedResults("swap-report");

            TradeReportRegressionTestUtils.assertAsciiTableEquals(tradeReport.toAsciiTableString(), expectedResults);
        }
        public TradeReport runReport(ReportCalculationResults results, TradeReportTemplate reportTemplate)
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableTable.Builder<int, int, com.opengamma.strata.collect.result.Result<?>> resultTable = com.google.common.collect.ImmutableTable.builder();
            ImmutableTable.Builder <int, int, Result <object> > resultTable = ImmutableTable.builder();

            for (int reportColumnIdx = 0; reportColumnIdx < reportTemplate.Columns.Count; reportColumnIdx++)
            {
                TradeReportColumn reportColumn = reportTemplate.Columns[reportColumnIdx];
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> columnResults;
                IList <Result <object> > columnResults;

                if (reportColumn.Value.Present)
                {
                    columnResults = ValuePathEvaluator.evaluate(reportColumn.Value.get(), results);
                }
                else
                {
                    columnResults = IntStream.range(0, results.Targets.Count).mapToObj(i => Result.failure(FailureReason.INVALID, "No value specified in report template")).collect(toImmutableList());
                }
                int rowCount = results.CalculationResults.RowCount;

                for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
                {
                    resultTable.put(rowIdx, reportColumnIdx, columnResults[rowIdx]);
                }
            }

            return(TradeReport.builder().runInstant(Instant.now()).valuationDate(results.ValuationDate).columns(reportTemplate.Columns).data(resultTable.build()).build());
        }
示例#5
0
        // obtains the data and calculates the grid of results
        private static void calculate(CalculationRunner runner)
        {
            // the trades that will have measures calculated
            IList <Trade> trades = ImmutableList.of(createFutureTrade1(), createFutureTrade2(), createOptionTrade1(), createOptionTrade2());

            // the columns, specifying the measures to be calculated
            IList <Column> columns = ImmutableList.of(Column.of(Measures.PRESENT_VALUE));

            // use the built-in example market data
            LocalDate valuationDate = LocalDate.of(2014, 1, 22);
            ExampleMarketDataBuilder marketDataBuilder = ExampleMarketData.builder();
            MarketData marketData = marketDataBuilder.buildSnapshot(valuationDate);

            // the complete set of rules for calculating measures
            CalculationFunctions functions = StandardComponents.calculationFunctions();
            CalculationRules     rules     = CalculationRules.of(functions);

            // the reference data, such as holidays and securities
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.basics.ReferenceData refData = com.opengamma.strata.basics.ImmutableReferenceData.of(com.google.common.collect.ImmutableMap.of<com.opengamma.strata.basics.ReferenceDataId<?>, Object>(FGBL_MAR14_ID, FGBL_MAR14, OGBL_MAR14_C150_ID, OGBL_MAR14_C150, ED_MAR14_ID, ED_MAR14));
            ReferenceData refData = ImmutableReferenceData.of(ImmutableMap.of <ReferenceDataId <object>, object>(FGBL_MAR14_ID, FGBL_MAR14, OGBL_MAR14_C150_ID, OGBL_MAR14_C150, ED_MAR14_ID, ED_MAR14));

            // calculate the results
            Results results = runner.calculate(rules, trades, columns, marketData, refData);

            // use the report runner to transform the engine results into a trade report
            ReportCalculationResults calculationResults = ReportCalculationResults.of(valuationDate, trades, columns, results, functions, refData);

            TradeReportTemplate reportTemplate = ExampleData.loadTradeReportTemplate("security-report-template");
            TradeReport         tradeReport    = TradeReport.of(calculationResults, reportTemplate);

            tradeReport.writeAsciiTable(System.out);
        }
        /// <summary>
        /// Evaluates a value path against a set of results, returning the resolved result for each trade.
        /// </summary>
        /// <param name="valuePath">  the value path </param>
        /// <param name="results">  the calculation results </param>
        /// <returns> the list of resolved results for each trade </returns>
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public static java.util.List<com.opengamma.strata.collect.result.Result<?>> evaluate(String valuePath, com.opengamma.strata.report.ReportCalculationResults results)
        public static IList <Result <object> > evaluate(string valuePath, ReportCalculationResults results)
        {
            IList <string> tokens = tokenize(valuePath);

            if (tokens.Count < 1)
            {
                return(Collections.nCopies(results.Targets.Count, Result.failure(FailureReason.INVALID, "Column expressions must not be empty")));
            }
            CalculationFunctions functions = results.CalculationFunctions;
            int rowCount = results.CalculationResults.RowCount;

            return(IntStream.range(0, rowCount).mapToObj(rowIndex => evaluate(functions, tokens, RootEvaluator.INSTANCE, new ResultsRow(results, rowIndex))).collect(toImmutableList()));
        }
示例#7
0
        //--------------------------------------------------------------------------------------------------

        private static ReportCalculationResults reportResults()
        {
            Measure        measure = Measure.of("PresentValue");
            Column         column  = Column.of(measure);
            IList <Column> columns = ImmutableList.of(column);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<? extends com.opengamma.strata.collect.result.Result<?>> resultValues = com.google.common.collect.ImmutableList.of(com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.CurrencyAmount.of(com.opengamma.strata.basics.currency.Currency.CAD, 2d)), com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.CurrencyAmount.of(com.opengamma.strata.basics.currency.Currency.AUD, 3d)), com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.CurrencyAmount.of(com.opengamma.strata.basics.currency.Currency.CHF, 4d)));
            IList <Result <object> > resultValues = ImmutableList.of(Result.success(CurrencyAmount.of(Currency.CAD, 2d)), Result.success(CurrencyAmount.of(Currency.AUD, 3d)), Result.success(CurrencyAmount.of(Currency.CHF, 4d)));
            IList <Trade>            trades       = ImmutableList.of(trade("cpty1", 1_000_000), trade("cpty2", 10_000_000), trade("cpty3", 100_000_000));
            Results results = Results.of(ImmutableList.of(column.toHeader()), resultValues);

            return(ReportCalculationResults.of(LocalDate.now(ZoneOffset.UTC), trades, columns, results));
        }
示例#8
0
        public virtual void productPath()
        {
            ReportCalculationResults reportResults = ValuePathEvaluatorTest.reportResults();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> counterpartyResults = ValuePathEvaluator.evaluate("Trade.Product.Notional", reportResults);
            IList <Result <object> > counterpartyResults = ValuePathEvaluator.evaluate("Trade.Product.Notional", reportResults);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> expectedCounterparties = com.google.common.collect.ImmutableList.of(com.opengamma.strata.collect.result.Result.success(1_000_000d), com.opengamma.strata.collect.result.Result.success(10_000_000d), com.opengamma.strata.collect.result.Result.success(100_000_000d));
            IList <Result <object> > expectedCounterparties = ImmutableList.of(Result.success(1_000_000d), Result.success(10_000_000d), Result.success(100_000_000d));

            assertThat(counterpartyResults).isEqualTo(expectedCounterparties);
        }
        // obtains the data and calculates the grid of results
        private static void calculate(CalculationRunner runner)
        {
            // the trades that will have measures calculated
            IList <Trade> trades = createSwapTrades();

            // the columns, specifying the measures to be calculated
            IList <Column> columns = ImmutableList.of(Column.of(Measures.PRESENT_VALUE), Column.of(Measures.PAR_RATE), Column.of(Measures.PV01_MARKET_QUOTE_BUCKETED), Column.of(Measures.PV01_CALIBRATED_BUCKETED));

            // load quotes
            ImmutableMap <QuoteId, double> quotesCcp1 = QuotesCsvLoader.load(VAL_DATE, QUOTES_RESOURCE_CCP1);
            ImmutableMap <QuoteId, double> quotesCcp2 = QuotesCsvLoader.load(VAL_DATE, QUOTES_RESOURCE_CCP2);

            // load fixings
            ImmutableMap <ObservableId, LocalDateDoubleTimeSeries> fixings = FixingSeriesCsvLoader.load(FIXINGS_RESOURCE);

            // create the market data
            MarketData marketData = ImmutableMarketData.builder(VAL_DATE).addValueMap(quotesCcp1).addValueMap(quotesCcp2).addTimeSeriesMap(fixings).build();

            // the reference data, such as holidays and securities
            ReferenceData refData = ReferenceData.standard();

            // load the curve definition
            IDictionary <CurveGroupName, RatesCurveGroupDefinition> defnsCcp1 = RatesCalibrationCsvLoader.load(GROUPS_RESOURCE_CCP1, SETTINGS_RESOURCE_CCP1, CALIBRATION_RESOURCE_CCP1);
            IDictionary <CurveGroupName, RatesCurveGroupDefinition> defnsCcp2 = RatesCalibrationCsvLoader.load(GROUPS_RESOURCE_CCP2, SETTINGS_RESOURCE_CCP2, CALIBRATION_RESOURCE_CCP2);
            RatesCurveGroupDefinition curveGroupDefinitionCcp1 = defnsCcp1[CURVE_GROUP_NAME_CCP1].filtered(VAL_DATE, refData);
            RatesCurveGroupDefinition curveGroupDefinitionCcp2 = defnsCcp2[CURVE_GROUP_NAME_CCP2].filtered(VAL_DATE, refData);

            // the configuration that defines how to create the curves when a curve group is requested
            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(CURVE_GROUP_NAME_CCP1, curveGroupDefinitionCcp1).add(CURVE_GROUP_NAME_CCP2, curveGroupDefinitionCcp2).build();

            // the complete set of rules for calculating measures
            CalculationFunctions  functions       = StandardComponents.calculationFunctions();
            RatesMarketDataLookup ratesLookupCcp1 = RatesMarketDataLookup.of(curveGroupDefinitionCcp1);
            RatesMarketDataLookup ratesLookupCcp2 = RatesMarketDataLookup.of(curveGroupDefinitionCcp2);
            // choose RatesMarketDataLookup instance based on counterparty
            TradeCounterpartyCalculationParameter perCounterparty = TradeCounterpartyCalculationParameter.of(ImmutableMap.of(CCP1_ID, ratesLookupCcp1, CCP2_ID, ratesLookupCcp2), ratesLookupCcp1);
            CalculationRules rules = CalculationRules.of(functions, perCounterparty);

            // calibrate the curves and calculate the results
            MarketDataRequirements reqs = MarketDataRequirements.of(rules, trades, columns, refData);
            MarketData             calibratedMarketData = marketDataFactory().create(reqs, marketDataConfig, marketData, refData);
            Results results = runner.calculate(rules, trades, columns, calibratedMarketData, refData);

            // use the report runner to transform the engine results into a trade report
            ReportCalculationResults calculationResults = ReportCalculationResults.of(VAL_DATE, trades, columns, results, functions, refData);
            TradeReportTemplate      reportTemplate     = ExampleData.loadTradeReportTemplate("swap-report-template2");
            TradeReport tradeReport = TradeReport.of(calculationResults, reportTemplate);

            tradeReport.writeAsciiTable(System.out);
        }
示例#10
0
        public virtual void measurePath_failure_noMeasureName()
        {
            ReportCalculationResults reportResults = ValuePathEvaluatorTest.reportResults();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> results = ValuePathEvaluator.evaluate("Measures.", reportResults);
            IList <Result <object> > results = ValuePathEvaluator.evaluate("Measures.", reportResults);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result = results.get(0);
            Result <object> result = results[0];

            assertThat(result.Failure).True;
            assertThat(result.Failure.Message).contains("PresentValue");
            assertThat(result.Failure.Message).contains("ParRate");
        }
        // obtains the data and calculates the grid of results
        private static void calculate(CalculationRunner runner)
        {
            // the trades that will have measures calculated
            IList <Trade> trades = createSwapTrades();

            // the columns, specifying the measures to be calculated
            IList <Column> columns = ImmutableList.of(Column.of(Measures.LEG_INITIAL_NOTIONAL), Column.of(Measures.PRESENT_VALUE), Column.of(Measures.LEG_PRESENT_VALUE), Column.of(Measures.PV01_CALIBRATED_SUM), Column.of(Measures.PAR_RATE), Column.of(Measures.ACCRUED_INTEREST), Column.of(Measures.PV01_CALIBRATED_BUCKETED), Column.of(AdvancedMeasures.PV01_SEMI_PARALLEL_GAMMA_BUCKETED));

            // load quotes
            ImmutableMap <QuoteId, double> quotes = QuotesCsvLoader.load(VAL_DATE, QUOTES_RESOURCE);

            // load fixings
            ImmutableMap <ObservableId, LocalDateDoubleTimeSeries> fixings = FixingSeriesCsvLoader.load(FIXINGS_RESOURCE);

            // create the market data
            MarketData marketData = MarketData.of(VAL_DATE, quotes, fixings);

            // the reference data, such as holidays and securities
            ReferenceData refData = ReferenceData.standard();

            // load the curve definition
            IDictionary <CurveGroupName, RatesCurveGroupDefinition> defns = RatesCalibrationCsvLoader.load(GROUPS_RESOURCE, SETTINGS_RESOURCE, CALIBRATION_RESOURCE);
            RatesCurveGroupDefinition curveGroupDefinition = defns[CURVE_GROUP_NAME].filtered(VAL_DATE, refData);

            // the configuration that defines how to create the curves when a curve group is requested
            MarketDataConfig marketDataConfig = MarketDataConfig.builder().add(CURVE_GROUP_NAME, curveGroupDefinition).build();

            // the complete set of rules for calculating measures
            CalculationFunctions  functions   = StandardComponents.calculationFunctions();
            RatesMarketDataLookup ratesLookup = RatesMarketDataLookup.of(curveGroupDefinition);
            CalculationRules      rules       = CalculationRules.of(functions, ratesLookup);

            // calibrate the curves and calculate the results
            MarketDataRequirements reqs = MarketDataRequirements.of(rules, trades, columns, refData);
            MarketData             calibratedMarketData = marketDataFactory().create(reqs, marketDataConfig, marketData, refData);
            Results results = runner.calculate(rules, trades, columns, calibratedMarketData, refData);

            // use the report runner to transform the engine results into a trade report
            ReportCalculationResults calculationResults = ReportCalculationResults.of(VAL_DATE, trades, columns, results, functions, refData);
            TradeReportTemplate      reportTemplate     = ExampleData.loadTradeReportTemplate("swap-report-template");
            TradeReport tradeReport = TradeReport.of(calculationResults, reportTemplate);

            tradeReport.writeAsciiTable(System.out);
        }
示例#12
0
        private ReportCalculationResults runCalculationRequirements(ReportRequirements requirements)
        {
            IList <Column> columns = requirements.TradeMeasureRequirements;

            ExampleMarketDataBuilder marketDataBuilder = marketDataRoot == null?ExampleMarketData.builder() : ExampleMarketDataBuilder.ofPath(marketDataRoot.toPath());

            CalculationFunctions  functions   = StandardComponents.calculationFunctions();
            RatesMarketDataLookup ratesLookup = marketDataBuilder.ratesLookup(valuationDate);
            CalculationRules      rules       = CalculationRules.of(functions, ratesLookup);

            MarketData marketData = marketDataBuilder.buildSnapshot(valuationDate);

            IList <Trade> trades;

            if (Strings.nullToEmpty(idSearch).Trim().Empty)
            {
                trades = tradeList.Trades;
            }
            else
            {
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
                trades = tradeList.Trades.Where(t => t.Info.Id.Present).Where(t => t.Info.Id.get().Value.Equals(idSearch)).collect(toImmutableList());
                if (trades.Count > 1)
                {
                    throw new System.ArgumentException(Messages.format("More than one trade found matching ID: '{}'", idSearch));
                }
            }
            if (trades.Count == 0)
            {
                throw new System.ArgumentException("No trades found. Please check the input portfolio or trade ID filter.");
            }

            // the reference data, such as holidays and securities
            ReferenceData refData = ReferenceData.standard();

            // calculate the results
            CalculationTasks       tasks = CalculationTasks.of(rules, trades, columns, refData);
            MarketDataRequirements reqs  = tasks.requirements(refData);
            MarketData             calibratedMarketData = marketDataFactory().create(reqs, MarketDataConfig.empty(), marketData, refData);
            Results results = runner.TaskRunner.calculate(tasks, calibratedMarketData, refData);

            return(ReportCalculationResults.of(valuationDate, trades, requirements.TradeMeasureRequirements, results, functions, refData));
        }
示例#13
0
        //-------------------------------------------------------------------------
        private void run()
        {
            ReportRunner <ReportTemplate> reportRunner       = getReportRunner(template);
            ReportRequirements            requirements       = reportRunner.requirements(template);
            ReportCalculationResults      calculationResults = runCalculationRequirements(requirements);

            Report report = reportRunner.runReport(calculationResults, template);

            switch (format)
            {
            case ReportOutputFormat.ASCII_TABLE:
                report.writeAsciiTable(System.out);
                break;

            case ReportOutputFormat.CSV:
                report.writeCsv(System.out);
                break;
            }
        }
示例#14
0
        public virtual void measurePath()
        {
            ReportCalculationResults reportResults = ValuePathEvaluatorTest.reportResults();

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> currencyResults = ValuePathEvaluator.evaluate("Measures.PresentValue.Currency", reportResults);
            IList <Result <object> > currencyResults = ValuePathEvaluator.evaluate("Measures.PresentValue.Currency", reportResults);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> expectedCurrencies = com.google.common.collect.ImmutableList.of(com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.Currency.CAD), com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.Currency.AUD), com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.Currency.CHF));
            IList <Result <object> > expectedCurrencies = ImmutableList.of(Result.success(Currency.CAD), Result.success(Currency.AUD), Result.success(Currency.CHF));

            assertThat(currencyResults).isEqualTo(expectedCurrencies);

            // Amount returns the CurrencyAmount which is slightly unexpected
            // It's required in order to be able to format the amount to the correct number of decimal places
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> amountResults = ValuePathEvaluator.evaluate("Measures.PresentValue.Amount", reportResults);
            IList <Result <object> > amountResults = ValuePathEvaluator.evaluate("Measures.PresentValue.Amount", reportResults);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<com.opengamma.strata.collect.result.Result<?>> expectedAmounts = com.google.common.collect.ImmutableList.of(com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.CurrencyAmount.of(com.opengamma.strata.basics.currency.Currency.CAD, 2d)), com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.CurrencyAmount.of(com.opengamma.strata.basics.currency.Currency.AUD, 3d)), com.opengamma.strata.collect.result.Result.success(com.opengamma.strata.basics.currency.CurrencyAmount.of(com.opengamma.strata.basics.currency.Currency.CHF, 4d)));
            IList <Result <object> > expectedAmounts = ImmutableList.of(Result.success(CurrencyAmount.of(Currency.CAD, 2d)), Result.success(CurrencyAmount.of(Currency.AUD, 3d)), Result.success(CurrencyAmount.of(Currency.CHF, 4d)));

            assertThat(amountResults).isEqualTo(expectedAmounts);
        }
示例#15
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Returns a new trade report.
 /// </summary>
 /// <param name="calculationResults">  the results of the calculations </param>
 /// <param name="reportTemplate">  the template used to generate the report </param>
 /// <returns> a new trade report </returns>
 public static TradeReport of(ReportCalculationResults calculationResults, TradeReportTemplate reportTemplate)
 {
     return(TradeReportRunner.INSTANCE.runReport(calculationResults, reportTemplate));
 }
示例#16
0
 /// <summary>
 /// Returns a new instance exposing the data from a single row in the results.
 /// </summary>
 /// <param name="results">  the results used to generate a report </param>
 /// <param name="rowIndex">  the index of the row in the result whose data is exposed by this object </param>
 internal ResultsRow(ReportCalculationResults results, int rowIndex)
 {
     this.results  = results;
     this.rowIndex = rowIndex;
 }