The Gateway to Algorithmic and Automated Trading

5 Minute Developer: How to Build a Real-Time Stock Quote Widget in 5 Minutes

Xand : ChasCooper - 1st January 1970

The opinions expressed by this blogger and those providing comments are theirs alone, this does not reflect the opinion of Automated Trader or any employee thereof. Automated Trader is not responsible for the accuracy of any of the information supplied by this article.

In the next 5 minutes, you could get $5 worth of plumbing services, $30 worth of legal advice or $17 worth of psychotherapy. Or, you could just spend your next five minutes building a real-time stock quote widget. Don't think it can be done in 5 minutes? Check out a video showing us doing it in less time.

Here's how you can do the same thing using PHP and Eclipse, although the same basic process can be used for any language and any IDE:

Step 1: Subscribe to XigniteRealTime to get access to real-time, Level I stock quotes. If you're not ready to subscribe yet, you can also sign up for a free trial and get access to other real-time stock quote web services such as XigniteNASDAQLastSale and XigniteBATSLastSale. You'll need to make a few adjustments to the sample code below to point to a different web service, but nothing major.

Step 2: Start a new PHP project in Eclipse.

Step 3: Create your index.php page with the following code:

<html><title>Get Real-Time Quote</title><body><form>

<input type="text" name="symbol" />

<input type="submit" value="Go" />



$client = new SoapClient('');

$quote = $client->GetRealQuote(array('Exchange' => "INET", 'Symbol' => $_GET["Symbol"], 'IncludeBidAsk' => "false"));

echo "Last price: ", $quote->GetRealQuoteResult->Last;


Step 4: Open a browser and load your index.php page to give your new stock quote widget a spin.

Congratulations! You just built a real-time stock quote widget in PHP and made a plumber, a lawyer and a psychotherapist very disappointed in you for such a ridiculous waste of your time.

Share and Enjoy: email Twitter Facebook LinkedIn Digg StumbleUpon Technorati Suggest to Techmeme via Twitter Google Bookmarks Live FriendFeed