Getting a stock's price history
Asked Answered
H

4

7

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
Heckle answered 31/7, 2010 at 21:38 Comment(0)
R
11

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

Roth answered 31/7, 2010 at 22:9 Comment(1)
That article uses XML. If you want JSON, just add &format=json to the end of the request.Autostability
A
1

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.

Autostability answered 28/9, 2015 at 15:2 Comment(0)
T
0

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...

Teniers answered 19/10, 2010 at 6:25 Comment(0)
F
0

You can find historic intraday data at http://www.myinvestorshub.com/historic_intraday_data.php ( for all countries)

Frightened answered 5/2, 2013 at 17:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.