Getting a stock's price history
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 开发者_如何学Pythonwhose 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.
Take a look at the Historical Securities Data API at http://www.mergent.com/servius - I don't think they'll have intraday data though...
You can find historic intraday data at http://www.myinvestorshub.com/historic_intraday_data.php ( for all countries)
精彩评论