I would like开发者_JAVA百科 to write a java program or method that simple gets the current price of a given stock symbol. I have scoured through the Google and Yahoo finance APIs and do not think these have what I am looking for. Does anyone know how I can accomplish this or a good place to look?
It looks like Yahoo has an API to export stock data in CSV format: Downloading Yahoo Data.
For example, the following URL:
http://finance.yahoo.com/d/quotes.csv?s=GOOG+MSFT&f=snd1l1yr
Produces the following CSV file:
"GOOG","Google Inc.","9/22/2011",520.66,N/A,19.45
"MSFT","Microsoft Corpora","9/22/2011",25.06,2.46,9.66
No idea about delay, presumably it doesn't fit your needs. I would imagine you'd have to pay for a service that provides stock price information in a timely manner.
this should be comment but
@Mike are you meaning price or another Securities indicators ???,
there are lots of Boerses, Public Contributors and Market Makers, and by default are required to be distributed on a daily basis these values, some of them on 10 minutes average
you have five choises, sure depends of your Whatever requirents
1) buy contract with some of Market Makers
2) buy contract with Bloomberg or Reuters (altogether covered whole Market)
3) buy B*S** for cent, but with same * prices,
4) download (by default free) prices from lots of Boerses, Public Contributors, Market Makers, but those prices are averages (for example on Hour'Wool),
5) lots of Banks, Funds and Insurancies (own market and quotations) distribute these indicators but again only their last/opening/ close price or some averages price
This certainly brings back price (and lots more besides):
http://www.google.com/finance?q=NYSE:UTX
You just might have to work harder than you imagined in order to get it. What you're looking for is a spoon that fits your mouth, but it's not fair to say that Google and Yahoo won't give you stock price for a given symbol.
Since you say you're looking for real-time data, I'd look at online brokerages, such as Interactive Brokers. You'll need to open an account and in all likelihood you won't be able to republish the data (but you haven't stated that you were going to).
If you are looking for something closer to real time, you could scrape the data from the HTML returned by http://www.google.com/finance?q=NYSE:UTX using something like Tag Soup
I've tried doing this for a school project, you can't do real time unless you pay for using a server that pulls data from the NYSE. What we did was pull it from the yahoo using their api, but there's a slight delay and there were many instances where we got temp banned.
Generally speaking, you won't be able to escape the 20 minute delay without an account of some sort. There are vendors (e.g., TC 2000 from Worden) but no public free API. [I have no relationship to Worden or any other service.]
精彩评论