Ejemplo n.º 1
0
        public static StockRealTimeData parseRealTimeData(String str)
        {
            if (str == null)
            {
                return(null);
            }

            int    startIndex  = str.IndexOf('\"');
            int    endIndex    = str.LastIndexOf('\"');
            string mainPartStr = str.Substring(startIndex, endIndex - startIndex + 1);

            string[] arr = mainPartStr.Split(new char[] { ',' });

            if (arr.Length < 32)
            {
                return(null);
            }
            try
            {
                StockRealTimeData data = new StockRealTimeData();
                data.stockName           = arr[0];
                data.openPrice           = double.Parse(arr[1]);
                data.closePriceYesterday = double.Parse(arr[2]);
                data.latestPrice         = double.Parse(arr[3]);
                data.highestPrice        = double.Parse(arr[4]);
                data.lowestPrice         = double.Parse(arr[5]);
                data.bidPrice            = double.Parse(arr[6]);
                data.askPrice            = double.Parse(arr[7]);
                data.volume         = long.Parse(arr[8]);
                data.turnoverAmount = double.Parse(arr[9]);

                int index = 10;
                for (int i = 0; i < 5; i++)
                {
                    data.bidList[i]        = new BidOrderInfo();
                    data.bidList[i].amount = long.Parse(arr[index++]);
                    data.bidList[i].price  = double.Parse(arr[index++]);
                }
                for (int i = 0; i < 5; i++)
                {
                    data.askList[i]        = new BidOrderInfo();
                    data.askList[i].amount = long.Parse(arr[index++]);
                    data.askList[i].price  = double.Parse(arr[index++]);
                }

                data.date = arr[30];
                data.time = arr[31];

                return(data);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public StockRealTimeData queryRealTimeData(string stockID)
        {
            String            str = StockDataCollector.queryMarketRealTimeDataSina(stockID);
            StockRealTimeData rd  = StockDataConvertor.parseRealTimeData(str);

            if (rd != null)
            {
                rd.stockCode = StockIDUtil.getPureCode(stockID);
            }
            return(rd);
        }
Ejemplo n.º 3
0
 private void queryMarketRealTimeData()
 {
     try
     {
         StockRealTimeData rd = StockDataCenter.getInstance().queryRealTimeData(m_stockID);
         if (rd != null)
         {
             StockDataCenter.getInstance().assignRealTimeData(m_stockID, rd);
         }
     }
     catch (Exception e)
     {
         //
     }
 }
Ejemplo n.º 4
0
 public void assignRealTimeData(string stockID, StockRealTimeData data)
 {
     m_realTimeData[stockID] = data;
 }