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.

    5th November 12:00
    C: 9.5300
    O: 9.3800
    H: 9.5700
    L: 9.3500
    V: 41274267
    6th November 12:00
    C: 9.5400
    O: 9.4600
    H: 9.5700
    L: 9.4100
    V: 40928647
    7th November 12:00
    C: 9.6000
    O: 9.6000
    H: 9.6000
    L: 9.4500
    V: 37347419
    8th November 12:00
    C: 9.4600
    O: 9.5800
    H: 9.6500
    L: 9.4400
    V: 55810120
    9th November 12:00
    C: 9.3800
    O: 9.3800
    H: 9.8000
    L: 9.2700
    V: 52203593
    12th November 12:00
    C: 9.4900
    O: 9.3800
    H: 9.5800
    L: 9.3700
    V: 36317186
    13th November 12:00
    C: 9.5400
    O: 9.5300
    H: 9.6700
    L: 9.4700
    V: 33097995
    14th November 12:00
    C: 9.5400
    O: 9.6300
    H: 9.6658
    L: 9.4300
    V: 46677594
    15th November 12:00
    C: 9.3100
    O: 9.5000
    H: 9.5300
    L: 9.1200
    V: 57163626
    16th November 12:00
    C: 9.0700
    O: 9.2800
    H: 9.3100
    L: 9.0500
    V: 17048578

    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.

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