Exemple #1
0
        public StockMarketData getMarketData(string stockID)
        {
            String          mdStr = StockDataCollector.queryMarketData(stockID);
            StockMarketData md    = StockDataConvertor.parseMarketData(mdStr);

            return(md);
        }
Exemple #2
0
        public static StockMarketData parseMarketData(String str)
        {
            if (str == null)
            {
                return(null);
            }

            string[] arr = str.Split('~');

            if (arr.Length < 50)
            {
                return(null);
            }
            try
            {
                StockMarketData md = new StockMarketData();
                md.stockName           = arr[1];
                md.stockCode           = arr[2];
                md.latestPrice         = double.Parse(arr[3]);
                md.closePriceYesterday = double.Parse(arr[4]);
                md.openPrice           = double.Parse(arr[5]);
                md.volume = long.Parse(arr[6]);

                int index = 9;
                for (int i = 0; i < 5; i++)
                {
                    md.bidList[i]        = new BidOrderInfo();
                    md.bidList[i].price  = double.Parse(arr[index++]);
                    md.bidList[i].amount = long.Parse(arr[index++]);
                }
                for (int i = 0; i < 5; i++)
                {
                    md.askList[i]        = new BidOrderInfo();
                    md.askList[i].price  = double.Parse(arr[index++]);
                    md.askList[i].amount = long.Parse(arr[index++]);
                }
                // transaction data ignored...
                md.date         = arr[30];
                md.changing     = double.Parse(arr[31]);
                md.chgPercent   = double.Parse(arr[32]);
                md.highestPrice = double.Parse(arr[33]);
                md.lowestPrice  = double.Parse(arr[34]);
                //
                //md.volume = long.Parse(arr[36]);
                md.turnoverAmount = double.Parse(arr[37]);
                if (arr[38].Length > 0)
                {
                    md.exchangeRate = double.Parse(arr[38]);
                }
                else
                {
                    md.exchangeRate = 0;
                }

                md.PE        = double.Parse(arr[39]);
                md.amplitude = double.Parse(arr[43]);
                md.circulateCapitalisation = double.Parse(arr[44]);
                md.totalCapitalisation     = double.Parse(arr[45]);
                md.PB          = double.Parse(arr[46]);
                md.volumeRatio = double.Parse(arr[49]);

                return(md);
            }
            catch (Exception e)
            {
                return(null);
            }
        }