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());
        }
Exemple #2
0
        public virtual void test_path()
        {
            TradeReportTemplate template = parseIni("trade-report-test-path.ini");

            TradeReportColumn payLegCcyColumn = TradeReportColumn.builder().value("Measures.LegInitialNotional.pay.currency").header("Pay Leg Ccy").build();

            assertEquals(template.Columns.Count, 1);
            assertEquals(template.Columns[0], payLegCcyColumn);
        }
Exemple #3
0
        public virtual void test_ignore_failures()
        {
            TradeReportTemplate template = parseIni("trade-report-test-ignore-failures.ini");

            TradeReportColumn payLegCcyColumn = TradeReportColumn.builder().value("Measures.LegInitialNotional.pay.currency").header("Pay Leg Ccy").build();

            TradeReportColumn pvColumn = TradeReportColumn.builder().value("Measures.PresentValue").header("Present Value").ignoreFailures(true).build();

            assertEquals(template.Columns.Count, 2);
            assertEquals(template.Columns[0], payLegCcyColumn);
            assertEquals(template.Columns[1], pvColumn);
        }
Exemple #4
0
        public virtual void test_simple_values()
        {
            TradeReportTemplate template = parseIni("trade-report-test-simple.ini");

            TradeReportColumn productColumn = TradeReportColumn.builder().value("Product").header("Product").build();

            TradeReportColumn pvColumn = TradeReportColumn.builder().value("Measures.PresentValue").header("Present Value").build();

            assertEquals(template.Columns.Count, 2);
            assertEquals(template.Columns[0], productColumn);
            assertEquals(template.Columns[1], pvColumn);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         TradeReportColumn other = (TradeReportColumn)obj;
         return(JodaBeanUtils.equal(header, other.header) && JodaBeanUtils.equal(value, other.value) && (ignoreFailures == other.ignoreFailures));
     }
     return(false);
 }
Exemple #6
0
        protected internal override string formatData(TradeReport report, int rowIdx, int colIdx, ReportOutputFormat format)
        {
            TradeReportColumn templateColumn = report.Columns.get(colIdx);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.collect.result.Result<?> result = report.getData().get(rowIdx, colIdx);
            Result <object> result = report.Data.get(rowIdx, colIdx);

            if (result.Failure)
            {
                return(templateColumn.IgnoreFailures ? "" : Messages.format("FAIL: {}", result.Failure.Message));
            }
            object value = result.Value;

            return(formatValue(value, format));
        }
        private TradeReportColumn parseColumn(string columnName, PropertySet properties)
        {
            TradeReportColumn.Builder columnBuilder = TradeReportColumn.builder();
            columnBuilder.header(columnName);

            if (properties.contains(VALUE_PROPERTY))
            {
                columnBuilder.value(properties.value(VALUE_PROPERTY));
            }
            if (properties.contains(IGNORE_FAILURES_PROPERTY))
            {
                string ignoreFailuresValue = properties.value(IGNORE_FAILURES_PROPERTY);
                bool   ignoresFailure      = Convert.ToBoolean(ignoreFailuresValue);
                columnBuilder.ignoreFailures(ignoresFailure);
            }
            return(columnBuilder.build());
        }
Exemple #8
0
 private TradeReport report <T1>(ArrayTable <T1> table)
 {
     return(TradeReport.builder().columns(TradeReportColumn.builder().header("col0").build(), TradeReportColumn.builder().header("col1").build()).data(table).valuationDate(LocalDate.now(ZoneOffset.UTC)).runInstant(Instant.now()).build());
 }