예제 #1
0
        /// <summary>
        /// 设置股票账户持仓信息
        /// </summary>
        /// <param name="stockPositionResult"></param>
        private void SetSecurityPosition(String stockPositionResult)
        {
            m_dictSecurityPositions.Clear();
            if (stockPositionResult == null || stockPositionResult.Length == 0)
            {
                return;
            }
            String[] lines = stockPositionResult.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (lines == null || lines.Length < 2)
            {
                return;
            }

            m_gridPositionAccount.BeginUpdate();
            m_gridPositionAccount.ClearRows();
            for (int i = 1; i < lines.Length; i++)
            {
                SecurityPosition position = SecurityPosition.ConvertToStockPosition(lines[i]);
                if (position != null)
                {
                    m_dictSecurityPositions[position.m_stockCode] = position;

                    GridRow row = new GridRow();
                    m_gridPositionAccount.AddRow(row);
                    GridCell cell = new GridStringCell(position.m_stockCode);
                    row.AddCell(0, cell);
                    cell = new GridStringCell(position.m_stockName);
                    row.AddCell(1, cell);
                    cell = new GridDoubleCell(position.m_stockBalance);
                    row.AddCell(2, cell);
                    cell = new GridDoubleCell(position.m_availableBalance);
                    row.AddCell(3, cell);
                    cell = new GridDoubleCell(position.m_volume);
                    row.AddCell(4, cell);
                    cell = new GridDoubleCell(position.m_frozenVolume);
                    row.AddCell(5, cell);
                    cell = new GridDoubleCell(position.m_positionProfit);
                    row.AddCell(6, cell);
                    cell = new GridDoubleCell(position.m_positionCost);
                    row.AddCell(7, cell);
                    cell = new GridDoubleCell(position.m_positionProfitRatio);
                    row.AddCell(8, cell);
                    cell = new GridDoubleCell(position.m_marketPrice);
                    row.AddCell(9, cell);
                    cell = new GridDoubleCell(position.m_marketValue);
                    row.AddCell(10, cell);
                    cell = new GridDoubleCell(position.m_redemptionVolume);
                    row.AddCell(11, cell);
                    cell = new GridStringCell(position.m_marketName);
                    row.AddCell(12, cell);
                    cell = new GridStringCell(position.m_investorAccount);
                    row.AddCell(13, cell);
                }
            }
            m_gridPositionAccount.EndUpdate();
            m_gridPositionAccount.Invalidate();
        }
예제 #2
0
        /// <summary>
        /// 设置股票账户委托信息
        /// </summary>
        /// <param name="commissionResult"></param>
        private void SetSecurityCommission(String commissionResult)
        {
            if (commissionResult == null || commissionResult.Length == 0)
            {
                return;
            }
            String[] lines = commissionResult.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (lines == null || lines.Length < 2)
            {
                return;
            }

            m_gridCommissionAccount.BeginUpdate();
            m_gridCommissionAccount.ClearRows();
            for (int i = 1; i < lines.Length; i++)
            {
                SecurityCommission commission = SecurityCommission.ConvertToSecurityCommission(lines[i]);
                if (commission != null)
                {
                    GridRow row = new GridRow();
                    m_gridCommissionAccount.AddRow(row);
                    GridCell cell = new GridStringCell(commission.m_orderDate);
                    row.AddCell(0, cell);
                    cell = new GridStringCell(commission.m_stockCode);
                    row.AddCell(1, cell);
                    cell = new GridStringCell(commission.m_stockName);
                    row.AddCell(2, cell);
                    cell = new GridStringCell(commission.m_operate);
                    row.AddCell(3, cell);
                    cell = new GridStringCell(commission.m_remark);
                    row.AddCell(4, cell);
                    cell = new GridDoubleCell(commission.m_orderVolume);
                    row.AddCell(5, cell);
                    cell = new GridDoubleCell(commission.m_tradeVolume);
                    row.AddCell(6, cell);
                    cell = new GridDoubleCell(commission.m_cancelVolume);
                    row.AddCell(7, cell);
                    cell = new GridDoubleCell(commission.m_orderPrice);
                    row.AddCell(8, cell);
                    cell = new GridStringCell(commission.m_orderType);
                    row.AddCell(9, cell);
                    cell = new GridDoubleCell(commission.m_tradeAvgPrice);
                    row.AddCell(10, cell);
                    cell = new GridStringCell(commission.m_orderSysID);
                    row.AddCell(11, cell);
                }
            }
            m_gridCommissionAccount.EndUpdate();
            m_gridCommissionAccount.Invalidate();
        }
예제 #3
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();
        }
예제 #4
0
        /// <summary>
        /// 获取表格
        /// </summary>
        /// <param name="bytes">流</param>
        /// <param name="native">方法库</param>
        /// <returns>表格</returns>
        public GridA GetGrid(byte[] bytes, INativeBase native)
        {
            Binary br = new Binary();

            br.Write(bytes, bytes.Length);
            GridA grid = new GridA();

            grid.Native = native;
            grid.Name   = br.ReadString();
            int columnsSize = br.ReadInt();

            for (int i = 0; i < columnsSize; i++)
            {
                GridColumn column = new GridColumn();
                column.Name       = br.ReadString();
                column.ColumnType = br.ReadString();
                grid.AddColumn(column);
            }
            grid.Update();
            List <GridColumn> columns = grid.GetColumns();
            int rowsCount             = br.ReadInt();

            for (int i = 0; i < rowsCount; i++)
            {
                GridRow row = new GridRow();
                grid.AddRow(row);
                for (int j = 0; j < columnsSize; j++)
                {
                    GridColumn column     = columns[j];
                    string     columnType = column.ColumnType.ToLower();
                    GridCell   cell       = null;
                    if (columnType == "bool")
                    {
                        cell = new GridBoolCell();
                        row.AddCell(j, cell);
                        cell.SetBool(br.ReadBool());
                    }
                    else if (columnType == "double")
                    {
                        cell = new GridDoubleCell();
                        row.AddCell(j, cell);
                        cell.SetDouble(br.ReadDouble());
                    }
                    else if (columnType == "float")
                    {
                        cell = new GridFloatCell();
                        row.AddCell(j, cell);
                        cell.SetFloat(br.ReadFloat());
                    }
                    else if (columnType == "int")
                    {
                        cell = new GridIntCell();
                        row.AddCell(j, cell);
                        cell.SetInt(br.ReadInt());
                    }
                    else if (columnType == "long")
                    {
                        cell = new GridLongCell();
                        row.AddCell(j, cell);
                        cell.SetLong((long)br.ReadDouble());
                    }
                    else if (columnType == "string")
                    {
                        cell = new GridStringCell();
                        row.AddCell(j, cell);
                        cell.SetString(br.ReadString());
                    }
                    else
                    {
                        cell = new GridStringCell();
                        row.AddCell(j, cell);
                        cell.SetString(br.ReadString());
                    }
                }
            }
            br.Close();
            return(grid);
        }
예제 #5
0
 /// <summary>
 /// 单元格双击事件
 /// </summary>
 /// <param name="sender">调用者</param>
 /// <param name="cell">单元格</param>
 /// <param name="mp">坐标</param>
 /// <param name="button">按钮</param>
 /// <param name="clicks">点击次数</param>
 /// <param name="delta">滚轮值</param>
 private void GridCellClick(object sender, GridCell cell, POINT mp, MouseButtonsA button, int clicks, int delta)
 {
     if (cell.Grid == m_tvIndicatorBrowser)
     {
         TreeNodeA tn = cell as TreeNodeA;
         if (tn.m_nodes.Count == 0)
         {
             NodeData nodeData = tn.Tag as NodeData;
             if (nodeData.IsCatalog)
             {
                 IndicatorLeafDataPacket leafPacket = new IndicatorLeafDataPacket(nodeData.Id);
                 ConnectManager.CreateInstance().Request(leafPacket);
                 int tick = 0;
                 while (leafPacket.ReserveFlag == 0 && tick < 50)
                 {
                     Thread.Sleep(100);
                     tick++;
                 }
                 if (leafPacket.LeafNodeList.Count > 0)
                 {
                     List <NodeData> nodes = leafPacket.LeafNodeList;
                     Dictionary <String, TreeNodeA> nodesMap = new Dictionary <String, TreeNodeA>();
                     int nodesSzie = nodes.Count;
                     for (int i = 0; i < nodesSzie; i++)
                     {
                         NodeData  node  = nodes[i];
                         TreeNodeA subTn = new TreeNodeA();
                         subTn.Text            = node.Name;
                         subTn.Style           = new GridCellStyle();
                         subTn.Style.ForeColor = COLOR.ARGB(255, 255, 80);
                         subTn.Style.Font      = new FONT("微软雅黑", 14, true, false, false);
                         subTn.Name            = node.Id;
                         subTn.Tag             = node;
                         if (nodesMap.ContainsKey(node.ParentId))
                         {
                             nodesMap[node.ParentId].AppendNode(subTn);
                             nodesMap[node.Id] = subTn;
                         }
                         else
                         {
                             tn.AppendNode(subTn);
                             nodesMap[node.Id] = subTn;
                         }
                         IndicatorEntityDataPacket entity = new IndicatorEntityDataPacket(node.Id);
                         ConnectManager.CreateInstance().Request(entity);
                     }
                     tn.ExpendAll();
                     m_tvIndicatorBrowser.Update();
                     m_tvIndicatorBrowser.Invalidate();
                 }
             }
             else
             {
                 StringBuilder     sb         = new StringBuilder();
                 CList <GSecurity> securities = SecurityService.FilterCode(m_txtIndicatorCode.Text);
                 int codesSize = securities.size();
                 for (int i = 0; i < codesSize; i++)
                 {
                     sb.Append(securities.get(i).m_code);
                     if (i != codesSize - 1)
                     {
                         sb.Append(",");
                     }
                 }
                 m_gridIndicatorBrowser.ClearRows();
                 IndicatorRootData data = GetIndicatorData(nodeData.Id, "Stock", sb.ToString());
                 m_gridIndicatorBrowser.GetColumn("colN3").Text = data.categoryName;
                 foreach (IndicatorItemData indicatorItem in data.items)
                 {
                     GridRow row = new GridRow();
                     m_gridIndicatorBrowser.AddRow(row);
                     GridStringCell codeCell = new GridStringCell(indicatorItem.code);
                     row.AddCell("colN1", codeCell);
                     GSecurity security = new GSecurity();
                     SecurityService.GetSecurityByCode(indicatorItem.code, ref security);
                     row.AddCell("colN2", new GridStringCell(security.m_name));
                     if (indicatorItem.type == 0)
                     {
                         GridStringCell valueCell = new GridStringCell(indicatorItem.text);
                         row.AddCell("colN3", valueCell);
                     }
                     else if (indicatorItem.type == 1)
                     {
                         GridDoubleCell valueCell = new GridDoubleCell(indicatorItem.num);
                         row.AddCell("colN3", valueCell);
                     }
                     row.GetCell("colN1").Style           = new GridCellStyle();
                     row.GetCell("colN1").Style.ForeColor = COLOR.ARGB(255, 255, 80);
                     row.GetCell("colN1").Style.Font      = new FONT("微软雅黑", 14, true, false, false);
                     row.GetCell("colN1").Style.Font      = new FONT("微软雅黑", 14, true, false, false);
                     row.GetCell("colN2").Style           = new GridCellStyle();
                     row.GetCell("colN2").Style.ForeColor = COLOR.ARGB(255, 80, 80);
                     row.GetCell("colN2").Style.Font      = new FONT("微软雅黑", 14, true, false, false);
                     row.GetCell("colN3").Style           = new GridCellStyle();
                     row.GetCell("colN3").Style.ForeColor = COLOR.ARGB(80, 255, 255);
                     row.GetCell("colN3").Style.Font      = new FONT("微软雅黑", 14, true, false, false);
                 }
                 m_gridIndicatorBrowser.Update();
                 m_gridIndicatorBrowser.Invalidate();
             }
         }
     }
     else if (cell.Grid == m_gridIndicatorBrowser)
     {
         if (clicks == 2)
         {
             m_mainFrame.SearchSecurity(cell.Row.GetCell("colN1").GetString());
         }
     }
 }