Home Add Stock Quote Date Table to WordPress With Shortcode (Alpha Vantage API)

    Add Stock Quote Date Table to WordPress With Shortcode (Alpha Vantage API)


    In early October we provided a shortcode that would query Alpha Vantage for stock data. One of the comments asked about how one would include the data in tables rather than a graph. This is a very crude example (I spend no more than a couple of minutes modifying it). If you’re going to use it you’ll want to style it and copy the inline CSS to the appropriate location.

    ■ ■ ■

    Shortcode of [stocktable number="10"] returns the following. It’s kind-of mobile responsive… so if you were to use it you would certainly need to make improvements. We’re caching the data for three hours.

    19th June 12:00
    C: 6.2300
    O: 6.6400
    H: 6.6900
    L: 6.2300
    V: 125960169
    22nd June 12:00
    C: 6.2800
    O: 6.2700
    H: 6.2800
    L: 6.1300
    V: 71528188
    23rd June 12:00
    C: 6.1500
    O: 6.3300
    H: 6.3800
    L: 6.1400
    V: 86551368
    24th June 12:00
    C: 5.9500
    O: 6.0600
    H: 6.1225
    L: 5.8600
    V: 75441550
    25th June 12:00
    C: 6.0300
    O: 5.8600
    H: 6.0500
    L: 5.8000
    V: 73513570
    26th June 12:00
    C: 5.9100
    O: 6.0400
    H: 6.0700
    L: 5.8100
    V: 118309845
    29th June 12:00
    C: 6.0100
    O: 5.9100
    H: 6.0700
    L: 5.8100
    V: 58135203
    30th June 12:00
    C: 6.0800
    O: 5.9800
    H: 6.1000
    L: 5.9000
    V: 61833037
    1st July 12:00
    C: 5.9800
    O: 6.1000
    H: 6.1800
    L: 5.9500
    V: 57578573
    2nd July 12:00
    C: 6.0500
    O: 6.1000
    H: 6.1700
    L: 6.0000
    V: 67193329

    Original post published here.

    WordPress Shortcode

    Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

    If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

    Short URL for this post: http://shor.tt/1XVc