public BrokerErrorCode GetEquitySpread(string stockCode, out EquitySymbolSpread[] info) { BrokerErrorCode errorCode = BrokerErrorCode.Success; info = new EquitySymbolSpread[2]; string quoteData = null; int retryCount = 0; do { quoteData = HttpHelper.GetWebPageResponse( URL_ICICI_EQT_SPREAD + stockCode.ToUpper(), null, null, mCookieContainer); retryCount++; } while (quoteData == null && retryCount < 5); // web problems, slow connection, server down etc. if (string.IsNullOrEmpty(quoteData) || quoteData.IndexOf("entered is not valid") > -1) { return(BrokerErrorCode.NullResponse); } ParsedTable table = (ParsedTable)HtmlTableParser.ParseHtmlIntoTables(quoteData, true); // NSE price info info[0] = new EquitySymbolSpread(); info[0].Symbol = stockCode; info[0].Exchange = Exchange.NSE; string tempStr = ParsedTable.GetValue(table, new int[] { 0, 3, 0, 1 }); DateTime lastTradeTime = DateTime.Parse(tempStr); tempStr = ParsedTable.GetValue(table, new int[] { 0, 3, 1, 1 }); lastTradeTime += TimeSpan.Parse(tempStr); info[0].QuoteTime = lastTradeTime; info[0].TotalBidQty = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, 7, 1 })); info[0].TotalOfferQty = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, 8, 1 })); for (int i = 0; i < 5; i++) { info[0].BestBidQty[i] = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 0 })); info[0].BestBidPrice[i] = MarketUtils.GetPrice(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 1 })); info[0].BestOfferQty[i] = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 2 })); info[0].BestOfferPrice[i] = MarketUtils.GetPrice(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 3 })); } // BSE price info info[1] = new EquitySymbolSpread(); info[1].Symbol = stockCode; info[1].Exchange = Exchange.BSE; tempStr = ParsedTable.GetValue(table, new int[] { 0, 3, 0, 3 }); lastTradeTime = DateTime.Parse(tempStr); tempStr = ParsedTable.GetValue(table, new int[] { 0, 3, 1, 3 }); lastTradeTime += TimeSpan.Parse(tempStr); info[1].QuoteTime = lastTradeTime; info[1].TotalBidQty = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, 7, 3 })); info[1].TotalOfferQty = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, 8, 3 })); for (int i = 0; i < 5; i++) { info[1].BestBidQty[i] = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 4 })); info[1].BestBidPrice[i] = MarketUtils.GetPrice(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 5 })); info[1].BestOfferQty[i] = MarketUtils.GetVolume(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 6 })); info[1].BestOfferPrice[i] = MarketUtils.GetPrice(ParsedTable.GetValue(table, new int[] { 0, 5, i + 2, 7 })); } return(errorCode); }