Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 1.0   Updated Sunday, March 22nd, 2009 at 8:20pm

Stock Quotes Plugin for WordPress

This WordPress plugin allows you to easily display stock quotes on your website. The output of the plugin is designed to be minimal – the stock symbol, last price, and change amount are shown. You can configure the output in the options page for the plugin. The data is retrieved from Yahoo finance.

Download

  If you have found this page useful, please consider donating. Thanks!

Instructions

  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin options (under DDStockQuotes)

Demo

MSFT 30.495 [-0.275]
GOOG 605.91 [-5.55]

Change Log

  • 03-22-09 Version 1.0 – First release

Usage

There are two ways this plugin can be used:

In a post or page:
[stock SYMBOL]

From a template file:
<?php echo ddsq_get_quote('SYMBOL'); ?>

* where SYMBOL is the stock symbol you want to use

Important note regarding symbols

For most stocks, you can simply use the standard symbol, but for some cases (such as indexes) you will have to use the proper tags from Yahoo Finance. First, use this URL to search for your stock/index/etc..

http://finance.yahoo.com/

Then when the results are shown, look at the URL. For example, searching for the Dow Jones Industrial Average. From the ’s’ parameter in the URL, and the symbol shown next to the name, you will see that it uses ^DJI. For the S&P 500, the tag is ^GSPC.

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Output Format

This is the format of the plugin output. You can use any HTML you want, using the placeholders for the values: %NAME% %LAST% %CHANGE%

Example: <strong>%NAME%</strong> %LAST% [<strong>%CHANGE%</strong>]

Up Color

Color to use for price change when up (leave blank to disable)

Down Color

Color to use for price change when down (leave blank to disable)

Non-WordPress usage of the code

If you would like to use this script in your own PHP code, outside of WordPress, it is easy to do. All you need is the ddsq_get_quote function from the plugin, replacing the three lines at the start of the function (which pull the option settings from WordPress), with the actual option strings. Example:

$quote_format = '<strong>%NAME%</strong> %LAST% [<strong>%CHANGE%</strong>]';
$up_color = '00BB00';
$down_color = 'FF0000';

Pages: « 5 4 3 2 [1] Show All

  1. Dear Visitors,

    This blog is really nice and informative. We are pleased to know this blog is really helping people.
    It’s our pleasure to post informative content on this useful blog created by webmaster.
    THERE is a one stock that gives 400% profit in a year .
    from 10 years 2000 to 2010 it gives these types of profit .
    we make 3 times money in it .
    If some body want to check this stock status , just check the performance of this stock before invest ,
    no one can make these types of profit through trading .
    so just invest and make your money 400% in 1 year .
    our services are free of cost .
    to do so pls contact us at our site amarinvestments

    amarinvestments

  2. rally nice plugin..i was thinking for the same type for my blog.it really looks cool like the cnn and other websites

  3. Great Plugin.. Thanks for sharing..

  4. Awesome plugin! Really appreciate the effort that you put into this. In exchange for this wonderful tool, I’d like to share a site with you guys that has helped me tremendously with not only learning how to backtest my strategy for free, but it’s also a place where there’s a good community of seasoned investors and day traders willing to help. The site is wikinancial.com

  5. This plugin has been tested, and works, with the latest release of WordPress – 2.8

    For those asking about the demo – the stock information you see above is live output from the plugin.

  6. Where can I see the demo?

  7. I have lots of contents on Economy, Company news, Stock recommendations, Warren Buffett and much more.

  8. Nice thank you, i really like it.

  9. Nice plugin, thank you man!

  10. Currently there is no caching done – as people generally want up to date stock quotes, but I will consider it as an optional setting in the next release.

  11. 5
    Stephen

    Question: how is caching handled for the stock quotes? Is Yahoo Finance queried each time the page is loaded, or can this be cached to every 15/30/45/60 minutes?

  12. This is a great plugin. I should be using this at my blogs. Thanks

  13. 3
    Eric Morris

    Here is the code for the three main indices: DJIA: NASDAQ: S&P 500:

    Thanks for your help.

  14. Eric: Thanks for pointing that out. It looks like it has to do with the symbols Yahoo Finance uses (which is where this data comes from).

    I added instructions above (see ‘Important note regarding symbols’ section), to find out what the exact symbol they are using for whatever you are searching for.

  15. 1
    Eric Morris

    What symbols do I use to display DJIA, NASDAQ & S&P500? DJIA does not seem to work. Thanks.

Pages: « 5 4 3 2 [1] Show All

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.