Are there any simple HTTP APIs out there which will let me get the stock price for a symbol (such as GOOG) at a specific date and time?
Something like...
http://somewebsite.com/?
symbol=GOOG&
year=2010&
month=7&
day=30&
hour=4&
minute=00
Giving a response of $484.85
I'm hoping to have an end result of a haskell function whose type signature looks something like...
getQuote :: Symbol -> Date -> Time -> Price
I believe YQL with Yahoo finance can complete this task, they have data going back to 1996 looking on some stocks.
http://www.yqlblog.net/blog/2009/06/02/getting-stock-information-with-yql-and-open-data-tables/
http://www.gummy-stuff.org/Yahoo-data.htm
Here is an example on how to get the data in JSON-format from 2014-01-01 to 2015-01-01 for Apple stock (AAPL) via Yahoo Finance API using YQL.
The YQL query is URL-encoded:
select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%3D%22AAPL%22%20and%20startDate%3D%222014-01-01%22%20and%20endDate%3D%222015-01-01%22
So, if you decode it, you'll get:
select * from yahoo.finance.historicaldata where symbol="AAPL" and startDate="2014-01-01" and endDate="2015-01-01"
Just change the date values to ones you want and decode the whole thing back, for example using this URL-encoder: http://meyerweb.com/eric/tools/dencoder/
Then, put the whole thing together by adding the encoded query into the request URL:
http://query.yahooapis.com/v1/public/yql?q={ENTER_QUERY_HERE}&env=http://datatables.org/alltables.env&format=json
So, you end up with something like this:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%3D%22AAPL%22%20and%20startDate%3D%222014-01-01%22%20and%20endDate%3D%222015-01-01%22&env=http://datatables.org/alltables.env&format=json
Which will return you some fine JSON-formated data for the time period you've set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With