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.

    13th May 12:00
    C: 10.0800
    O: 10.1700
    H: 10.2600
    L: 10.0400
    V: 51102054
    14th May 12:00
    C: 10.2400
    O: 10.1500
    H: 10.2900
    L: 10.1300
    V: 31297221
    15th May 12:00
    C: 10.3600
    O: 10.2100
    H: 10.4000
    L: 10.0400
    V: 44050200
    16th May 12:00
    C: 10.4000
    O: 10.3000
    H: 10.4400
    L: 10.3000
    V: 32696980
    17th May 12:00
    C: 10.2900
    O: 10.3200
    H: 10.4400
    L: 10.2400
    V: 34565393
    20th May 12:00
    C: 10.2800
    O: 10.3000
    H: 10.3000
    L: 10.2000
    V: 29535935
    21st May 12:00
    C: 10.2400
    O: 10.3100
    H: 10.3100
    L: 10.1500
    V: 30099324
    22nd May 12:00
    C: 9.9700
    O: 10.1700
    H: 10.2100
    L: 9.9300
    V: 51407182
    23rd May 12:00
    C: 9.8500
    O: 9.8500
    H: 9.8500
    L: 9.6700
    V: 43153773
    24th May 12:00
    C: 9.8300
    O: 9.9200
    H: 9.9500
    L: 9.8000
    V: 22125616

    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