示例#1
0
        private void addStatistics(List <ClientTradeSummary> tradeStatistics_, ISheet tab_, HSSFWorkbook wb_)
        {
            HSSFCellStyle leftColStyle = CellStyle.headingStyle(wb_);
            HSSFCellStyle contentStyle = CellStyle.contentStyle(wb_);

            foreach (ClientTradeSummary summary in tradeStatistics_)
            {
                IRow    row   = tab_.CreateRow(currentLine++);
                ICell[] cells = new ICell[columeNb];
                cells[0] = row.CreateCell(0, CellType.String);
                cells[0].SetCellValue(summary.getAccountId());
                cells[0].CellStyle = leftColStyle;

                cells[1] = row.CreateCell(1, CellType.String);
                cells[1].SetCellValue(summary.getAbbrName());
                cells[1].CellStyle = leftColStyle;

                cells[2] = row.CreateCell(2, CellType.Numeric);
                cells[2].SetCellValue((double)MathUtil.round(summary.getTotalTurnover(), 2));
                cells[2].CellStyle = leftColStyle;

                cells[3] = row.CreateCell(3, CellType.Numeric);
                cells[3].SetCellValue((double)MathUtil.round(summary.getFillRate(), 4));
                cells[3].CellStyle = leftColStyle;

                cells[4] = row.CreateCell(4, CellType.Numeric);
                cells[4].SetCellValue((double)MathUtil.round(summary.getCancelRate(), 4));
                cells[4].CellStyle = leftColStyle;

                int firstPosition = FIRST_NUMERIC_COLUME;
                int offset        = 0;
                int algoNb        = 0;

                foreach (OrderAlgo algo in sortedAlgos)
                {
                    StrategyStatistics algoStrategy = summary.getByAlgo(algo);
                    offset = columeEachAlgo * algoNb + firstPosition;

                    cells[offset + 0] = row.CreateCell(offset + 0, CellType.Numeric);
                    cells[offset + 0].SetCellValue((double)MathUtil.round(algoStrategy.getOrderCount(), 2));
                    cells[offset + 0].CellStyle = contentStyle;

                    cells[offset + 1] = row.CreateCell(offset + 1, CellType.Numeric);
                    cells[offset + 1].SetCellValue((double)MathUtil.round(algoStrategy.getSliceCount(), 2));
                    cells[offset + 1].CellStyle = contentStyle;

                    cells[offset + 2] = row.CreateCell(offset + 2, CellType.Numeric);
                    cells[offset + 2].SetCellValue((double)MathUtil.round(algoStrategy.getSlipage(), 2));
                    cells[offset + 2].CellStyle = contentStyle;

                    cells[offset + 3] = row.CreateCell(offset + 3, CellType.Numeric);
                    cells[offset + 3].SetCellValue((double)MathUtil.round(algoStrategy.getTurnover(), 2));
                    cells[offset + 3].CellStyle = contentStyle;

                    algoNb++;
                }
            }
        }
示例#2
0
        public ClientTradeSummary createTradeTab(List <SavedClientOrder> orders_, Client client_, HSSFWorkbook wb_, string tabName)
        {
            this.columeName = Colume_Headers;
            ISheet tb = wb_.CreateSheet(tabName);

            createSheetHeader(tb, wb_);
            int columeNb = this.columeName.Length;

            List <LineContent> lines        = this.buildExcelLines(orders_, client_);
            List <decimal>     slipList     = new List <decimal>();
            List <decimal>     turnoverList = new List <decimal>();

            HSSFCellStyle style = CellStyle.contentStyle(wb_);

            foreach (LineContent line in lines)
            {
                IRow    row   = tb.CreateRow(currentLine++);
                ICell[] cells = new ICell[columeNb];
                for (int j = 0; j < columeNb; j++)
                {
                    cells[j]           = row.CreateCell(j);
                    cells[j].CellStyle = style;
                }

                cells[0].SetCellValue(line.symbol);
                cells[1].SetCellValue(line.stockName);
                cells[2].SetCellValue(line.effectiveTime);
                cells[3].SetCellValue(line.expireTime);
                cells[4].SetCellValue(line.side);
                cells[5].SetCellValue(Double.Parse(MathUtil.round(line.avgPrice).ToString()));
                cells[6].SetCellValue(Double.Parse(line.volume.ToString()));
                cells[7].SetCellValue(Double.Parse(MathUtil.round(line.slipage).ToString()));

                slipList.Add(line.slipage);
                turnoverList.Add(line.turnover);
            }

            ClientTradeSummary tradeSummary = new ClientTradeSummary(client_, orders_);

            this.addFootLine(wb_, tb, turnoverList, slipList, tradeSummary.getTotalTurnover(), tradeSummary.getCancelRate(), tradeSummary.getFillRate());
            this.setAutoSizeColumn(tb, columeNb);
            currentLine = 0;
            return(tradeSummary);
        }