For Cognistreet - a virtual stock market game organized for Cognizance, I wrote a script for accelerated updating of stock prices for a list of symbols from Google Finance. This script is in Perl, and with a basic 3G connection I achieved price refresh times of less than 1 second for a list of about 5000 symbols, which I think is as good as realtime.
This script will be basically updaing stock quotes from google finance with the following URL:
The Idea is to have a list of symbols in a database (this script works with MySQL), then use forked processes to query google finance, parse the returned JSON and update the database. The forked processes are run in parallel to accelerate the process.
Being in Perl, you'll need to install the following dependencies for this script: DBI, Parallel::ForkManager, HTTP::Tiny & Time::HiRes. HighRes is optional, I used it only to monitor to refresh times. The following script is the exactly the same one that I used for CogniStreet, and it updated the database for NSE and NYSE stocks. This was run as a every-minute CRON job, and hence there is a alarm to timeout and kill this script before another instance of this was run.
View the gist on GitHub here.