Example #1
0
        /// <summary>
        /// 字符串转换成成交对象
        /// </summary>
        /// <param name="tradeResult"></param>
        /// <returns></returns>
        public static SecurityTrade ConvertToStockTrade(String tradeResult)
        {
            if (tradeResult == null || tradeResult.Length == 0)
            {
                return(null);
            }
            String[] tradeFields = tradeResult.Split("	".ToCharArray());
            if (tradeFields == null || tradeFields.Length < 11)
            {
                return(null);
            }
            int           index = 0;
            SecurityTrade trade = new SecurityTrade();

            trade.m_tradeDate     = tradeFields[index++];
            trade.m_stockCode     = tradeFields[index++];
            trade.m_stockName     = tradeFields[index++];
            trade.m_operate       = tradeFields[index++];
            trade.m_tradeVolume   = CStrA.ConvertStrToDouble(tradeFields[index++]);
            trade.m_tradeAvgPrice = CStrA.ConvertStrToDouble(tradeFields[index++]);
            trade.m_tradeAmount   = CStrA.ConvertStrToDouble(tradeFields[index++]);
            trade.m_orderSysID    = tradeFields[index++];
            trade.m_orderTradeID  = tradeFields[index++];
            trade.m_cancelVolume  = CStrA.ConvertStrToDouble(tradeFields[index++]);
            trade.m_stockBalance  = CStrA.ConvertStrToDouble(tradeFields[index++]);
            return(trade);
        }
Example #2
0
        /// <summary>
        /// 设置股票账户成交信息
        /// </summary>
        /// <param name="tradeResult"></param>
        private void SetSecurityTrade(String tradeResult)
        {
            if (tradeResult == null || tradeResult.Length == 0)
            {
                return;
            }
            String[] lines = tradeResult.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (lines == null || lines.Length < 2)
            {
                return;
            }

            m_gridTradeAccount.BeginUpdate();
            m_gridTradeAccount.ClearRows();
            for (int i = 1; i < lines.Length; i++)
            {
                SecurityTrade trade = SecurityTrade.ConvertToStockTrade(lines[i]);
                if (trade != null)
                {
                    GridRow row = new GridRow();
                    m_gridTradeAccount.AddRow(row);
                    GridCell cell = new GridStringCell(trade.m_tradeDate);
                    row.AddCell(0, cell);
                    cell = new GridStringCell(trade.m_stockCode);
                    row.AddCell(1, cell);
                    cell = new GridStringCell(trade.m_stockName);
                    row.AddCell(2, cell);
                    cell = new GridStringCell(trade.m_operate);
                    row.AddCell(3, cell);
                    cell = new GridDoubleCell(trade.m_tradeVolume);
                    row.AddCell(4, cell);
                    cell = new GridDoubleCell(trade.m_tradeAvgPrice);
                    row.AddCell(5, cell);
                    cell = new GridDoubleCell(trade.m_tradeAmount);
                    row.AddCell(6, cell);
                    cell = new GridStringCell(trade.m_orderSysID);
                    row.AddCell(7, cell);
                    cell = new GridStringCell(trade.m_orderTradeID);
                    row.AddCell(8, cell);
                    cell = new GridDoubleCell(trade.m_cancelVolume);
                    row.AddCell(9, cell);
                    cell = new GridDoubleCell(trade.m_stockBalance);
                    row.AddCell(10, cell);
                }
            }
            m_gridTradeAccount.EndUpdate();
            m_gridTradeAccount.Invalidate();
        }