How to Create an Android Stocks App?
I know there are already tons of stocks apps out in the Play Store for Android users and also App store for iOS users. But, don’t you wanted to know where or how they are getting their information from for a given stock?
If you looked closely on an Stock app disclaimer, most of them said their source is either from Yahoo! Finance or Google Finance website.
Here is a list of URLs for a stock app that I have used to capture stock data: Results are returned in JSON format.
– Return a list of symbols.
http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=” + query + “&callback=YAHOO.Finance.SymbolSuggest.ssCallback
*Where “query” is the string variable that the user is passing to it
I have used this on my Search function. When the user punched in a stock symbol, it will return all symbols and company names that contain the query text.
– Get detailed stock information.
I wrote a function to get detailed stock information from two different sources. My stock app will gather the stock details from the Google site first since their quote is close to real time. If that fail or timeout, it will try to get it from Yahoo.
From Google, I used the following URL to gather stock details information
http://www.google.com/finance/info?infotype=infoquoteall&q=” + symbols;
From Yahoo
http://finance.yahoo.com/d/quotes.csv?s=”+query+”&f=snxl1d1t1c1p2pobat8mwva2j1reyghjk
This will return the name, last traded price, last traded date, open, bid, ask, volume, etc… back to the app.
Here is a list of all the available parameters that I have passed with the Yahoo URL:
0 sSymbol = s
1 sName = n
2 sExchange = x
3 sLastTradePrice = l1
4 sLastTradeDate = d1
5 sLastTradeTime = t1
6 sChange = c1
7 sPercentChange = p2
8 sPreviousClose = p
9 sOpen = o
10 sBid = b
11 sAsk = a
12 s1yTargetEst = t8
13 sDayRange = m
14 s52WeekRange = w
15 sVolume = v
16 sAverageDailyVolume = a2
17 sMarketCap = j1
18 sPEratio = r
19 sEPS = e
20 sDivYield = r1
21 sDayLow = g
22 sDayHigh = h
23 s52weekLow = j
24 s52weekHigh = k
– Get Stock price history.
http://ichart.finance.yahoo.com/table.csv?s=”+symbol+”&a=”+fromMonth+”&b=”+fromDay+”&c=”+fromYear+”&d=”+toMonth+”&e=”+toDay+”&f=”+toYear;
This URL will gather all the closing prices for a stock. You can set the time frame of data to be returned back to you. You can use this information to make some kind of calculation. E.g. SMA, EMA, etc… of a given stock.
– Get Chart information
http://chart.finance.yahoo.com/c/bb/m/{query}
This will return a one year chart bitmap of a stock. There are others.
http://ichart.finance.yahoo.com/v?s=query
http://ichart.finance.yahoo.com/t?s=query
Now you know where to get the information. The next step is to code your Android or iOS app to capture and display it.