70 likes | 166 Views
QuoteGrabber App. Design Approach. Wanted simple stock quote finder to check stocks. Find and display a certain stock quote on startup. Use simple “Get” command to both get and post data. Grab source code and place it into one giant string to parse.
E N D
Design Approach • Wanted simple stock quote finder to check stocks • Find and display a certain stock quote on startup • Use simple “Get” command to both get and post data • Grab source code and place it into one giant string to parse • Exception handling for invalid stock tickers
Data Retrieval http://research.scottrade.com/public/stocks/snapshot/snapshot.asp?symbol=(Ticker Symbol) utils_.doGet((urlString + ticker), this); String SourceResponse = new String(utils_.responseToString(resp)); Did I get it?!? <link href=\"/public/common/style/stocks.css\” -NO
Data Retrieval Cont’d tickerIndex = SourceResponse .indexOf("<td class=\"info\" valign=\"bottom\">"); tickerIndex += 33; String theQuote = SourceResponse.substring(tickerIndex, tickerIndex + 6); // Clean up the stock quote. if (theQuote.endsWith("<")) finalQuote = theQuote.substring(0, 5); else if (theQuote.endsWith("/")) finalQuote = theQuote.substring(0, 4); else if (theQuote.endsWith("s")) finalQuote = theQuote.substring(0, 3); else finalQuote = theQuote;
Room for Improvement • Have a larger number of quotes provided at startup of app. • Provide predictive text to determine what ticker the user is trying to input • Provide quotes of corporations similar to the provided ticker (AMD & INTC)