News for hackers. Stuff that matters.
Re:Quote Stream - Push real-time stock quotes in JSON over w... by corry on Thursday April 19, 2012 @09:02AM (#3862731)
A quick note for anyone thinking that this could help you build that finance app you've been putting off - getting actual real-time stock quotes legitimately is actually fairly expensive/involved.

Screen scraping Google / Yahoo finance and using that data in an app is (I believe) explicitly against their TOS. Whether or not they ever enforce that is another story...

The actual real-time data streams are highly controlled and regulated by a few big players.

(Just my $0.02 after having looked into it about a year ago for a social investing app I was building)

Re:Quote Stream - Push real-time stock quotes in JSON over w... by getsat on Thursday April 19, 2012 @09:21AM (#3862821)
That data is also 15 minutes old (or older!) from what I recall. Probably not your best choice for anything remotely "realtime".

As parent said, you're better off getting a real market stream which will probably use FIX: http://en.wikipedia.org/wiki/Financial_Information_eXchange

Re:Quote Stream - Push real-time stock quotes in JSON over w... by nodesocket on Thursday April 19, 2012 @09:22AM (#3862830)
It should be realtime (not delayed 20 minutes), we will find out in 8 minutes if this is true. :)
Re:Quote Stream - Push real-time stock quotes in JSON over w... by nodesocket on Thursday April 19, 2012 @09:30AM (#3862870)
Confirmed real-time, just streamed in:

    {
	"ticker": "AAPL",
	"exchange": "NASDAQ",
	"price": "598.86",
	"change": "-9.48",
	"change_percent": "-1.56",
	"last_trade_time": "Apr 19, 9:30AM EDT"
    }
Re:Quote Stream - Push real-time stock quotes in JSON over w... by getsat on Thursday April 19, 2012 @06:14PM (#3865429)
I was referring to scraping Google/Yahoo. They have disclaimers on their sites that the information is N minutes old at best.

EDIT: I guess a few of them are actually realtime now. Here's the list: http://www.google.com/intl/en/googlefinance/disclaimer/

Re:Quote Stream - Push real-time stock quotes in JSON over w... by rpledge on Thursday April 19, 2012 @10:31AM (#3863156)
Yeah, while this is cool I'm sure it's a violation of Googles TOS. I'm sure they'd enforce it if this gets traction.
Re:Quote Stream - Push real-time stock quotes in JSON over w... by neiled on Thursday April 19, 2012 @08:00AM (#3862509)
But, and correct me if I'm wrong obviously, this isn't sending quotes to the client real time, it's just sending them in 5 second batches?

I guess I'm struggling to see how:

"Stock quotes are pulled from Google Finance and are real-time."

and

"By default stock quotes are fetched every 5 seconds, and pushed to the client."

Work together...

Great work on sharing the code though, thanks.

Re:Quote Stream - Push real-time stock quotes in JSON over w... by nodesocket on Thursday April 19, 2012 @08:02AM (#3862513)
In finance, real-time quotes means not delayed by 20 minutes. The price returned should be real-time in those terms.
Re:Quote Stream - Push real-time stock quotes in JSON over w... by jrockway on Thursday April 19, 2012 @11:48AM (#3863542)
In finance, real-time means receiving each tick or trade record. Aggregating prices over 5 seconds and sending that data every 5 seconds is "aggregated data over 5 seconds".
Re:Quote Stream - Push real-time stock quotes in JSON over w... by nlz1 on Thursday April 19, 2012 @09:54AM (#3862980)
Upvoted.

"Real time. You keep using that phrase. I do not think it means what you think it means."

Re:Quote Stream - Push real-time stock quotes in JSON over w... by ruffyen on Thursday April 19, 2012 @10:19AM (#3863091)
I caught the stream changing things up right in the middle? What is the deal with this? -- ie this was on the main page where it is looking for AAPL and not MSFT

{ "ticker": "MSFT", "exchange": "NASDAQ", "price": "31.26", "change": "+0.12", "change_percent": "0.38", "last_trade_time": "Apr 19, 10:17AM EDT" } { "ticker": "AAPL", "exchange": "NASDAQ", "price": "598.27", "change": "-10.07", "change_percent": "-1.66", "last_trade_time": "Apr 19, 10:17AM EDT" }

Re:Quote Stream - Push real-time stock quotes in JSON over w... by ananthrk on Thursday April 19, 2012 @11:33AM (#3863478)
Came here to say the same thing (including trying MSFT) :)

Also, the URL "http://xhv51cz0.nodesocket.com/quote-stream/MSFT/ works but "http://xhv51cz0.nodesocket.com/quote-stream/MSFT does not (without "/" in the end)

Re:Quote Stream - Push real-time stock quotes in JSON over w... by nodesocket on Thursday April 19, 2012 @10:24AM (#3863113)
Yeah, too tired to figure it out now, its a bug. Basically, clients are listening for a WebSocket event, and the server is broadcasting everything. If you can fix it up, would be amazing.
Re:Quote Stream - Push real-time stock quotes in JSON over w... by anonhacker on Thursday April 19, 2012 @08:27AM (#3862601)
This would be neat if it was secure, unfortunately anyone can look up your server from source and message it anything they please.
Re:Quote Stream - Push real-time stock quotes in JSON over w... by wowfat on Thursday April 19, 2012 @10:44AM (#3863222)
On a related note we put out a tech demo showing nodejs and socketio recently. http://www.webdigi.co.uk/fun/space/

It uses iPhone accelerometer to control the ship on your browser game!

Re:Quote Stream - Push real-time stock quotes in JSON over w... by manuscreationis on Thursday April 19, 2012 @07:49AM (#3862467)
Weeeeeeeell damn...

I had exactly this idea a few weeks ago, and never put any time into it.

Just goes to show you...

This is pretty cool, good work

Re:Quote Stream - Push real-time stock quotes in JSON over w... by nodesocket on Thursday April 19, 2012 @07:59AM (#3862506)
Yeah it's was a fun little project, hopefully useful for somebody. ;)
Re:Quote Stream - Push real-time stock quotes in JSON over w... by dodoflying on Thursday April 19, 2012 @09:46AM (#3862934)
I guess this data can only for personal use but not public. Am I right?
Re:Quote Stream - Push real-time stock quotes in JSON over w... by julien_p on Thursday April 19, 2012 @02:21PM (#3864366)
It's taking the data from google.com, for example http://www.google.com/finance/info?client=ig&q=AAPL which AFAIK isn't a public Google API. As noted in other comments, real time quote APIs tend to be subscription services that are somewhat expensive ...
Re:Quote Stream - Push real-time stock quotes in JSON over w... by jsavimbi on Thursday April 19, 2012 @10:12AM (#3863045)
Cool demo, but a real-time quote is measured in the ~20msec range. A real-time trade would be <50msec round trip.

A real-time quote provider is someone who's server is physically connected to a direct exchange feed, as in you have a 5' wire running from your box to one of the CME's servers, not someone who's obtaining web-based delayed quotes.

Re:Quote Stream - Push real-time stock quotes in JSON over w... by anonDataUser on Thursday April 19, 2012 @11:18AM (#3863397)
To expand on this a bit:

Within the US there are a number of ECNs/exchanges. Each one publishes there own order book including prices and sizes on each side of the book. To get the most accurate information possible on market prices, you need to have a direct connection to each exchange and usually, you want to be co-located within the same data center as them. Unless you're a market maker, high-frequency trader, or run an institutional electronic trading platform, this level of data is not necessary.

For most human traders, a consolidated feed is sufficient; that data comes from an authority called the CTA. From wikipedia: "Since the late 1970s, all SEC-registered exchanges and market centers that trade NYSE or AMEX-listed securities send their trades and quotes to a central consolidator where the Consolidated Tape System (CTS) and Consolidated Quotation System (CQS) data streams are produced and distributed worldwide." The consolidation process delays the data by ~100 ms. This is still considered real-time by many people including professional traders.

Most HN readers are getting a conflated version of the consolidated feed. Google's "real-time" feed falls into this category and adding 5 seconds doesn't really matter at this point.

Re:Quote Stream - Push real-time stock quotes in JSON over w... by jsavimbi on Thursday April 19, 2012 @01:24PM (#3864109)
> For most human traders

You're living in the past.

> The consolidation process delays the data by ~100 ms. This is still considered real-time by many people including professional traders.

A couple of months ago we achieved round-trip [cleared] trades between Tokyo and New York of under 50ms. That's your barrier to entry.

You're not in business if you're looking at an average of 100ms.

Re:Quote Stream - Push real-time stock quotes in JSON over w... by cluda01 on Thursday April 19, 2012 @03:58PM (#3864802)
I'm not sure if this is possible. According to Wolfram Alpha the distance between NYC and Tokyo is ~10879 Kilometers (as the crow flies, not as the cable lies). The speed of light in Kilometers per second is 299,792.458

If we evaluate (10879 / 299792.458) * 1000 = 36.28. This is for a single leg. So we get 72.57 milliseconds just for as the crow flies transport. This does not include other factors that contribute to latency (network, processing, etc.)

For "round trip" as you say then this number should be multiplied by 2 as it has to go NYC -> Tokyo, Tokyo -> NYC.

Have you developed some sort of faster than the speed of light communication mechanism we haven't heard of? Inquiring minds demand to know.

Edit: One possible explanation is that you are using multiple time sources that are not synchronized. E.g. if you send a FIX message to an ECN and use the clock available on your machine and then use the ECN's timestamps somewhere in your calculation this renders the measurement invalid because you can't ensure that your clocks are synchronized.

Re:Quote Stream - Push real-time stock quotes in JSON over w... by anonDataUser on Thursday April 19, 2012 @03:42PM (#3864742)
Human traders = past? You should see the floor that I work on. There are plenty, and they're doing very well. No algo has ivy league connections.

> You're not in business if you're looking at an average of 100ms.

You're not in business if your business is latency arb. Buffett doesn't care about your 50 ms.

Re:Quote Stream - Push real-time stock quotes in JSON over w... by nodesocket on Thursday April 19, 2012 @10:20AM (#3863095)
Everybody seems to be confusing the definition of real-time quotes in the context of consumer trading. When eTrade or Scottrade says they have real-time quotes, its the same as Google Finance (which this is pulling) in that, its not delayed 20 minutes. Beyond that, expecting a 5' or less connection to an exchange feed is just absurd.
Re:Quote Stream - Push real-time stock quotes in JSON over w... by rpledge on Thursday April 19, 2012 @10:41AM (#3863209)
You can get those feeds, but they're very expensive. High frequency trading is done using actual real time data at millisecond resolution. The barrier to entry is very high, which is why I think flash trading gives an unfair advantage to the wealthy. Of course, thats really the story of modern economics.....