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.

    9th April 12:00
    C: 11.2500
    O: 11.2500
    H: 11.3800
    L: 11.2000
    V: 36462658
    10th April 12:00
    C: 11.4500
    O: 11.4400
    H: 11.5500
    L: 11.4100
    V: 44005015
    11th April 12:00
    C: 11.4300
    O: 11.3800
    H: 11.4900
    L: 11.3000
    V: 32979038
    12th April 12:00
    C: 11.3100
    O: 11.5000
    H: 11.5400
    L: 11.2500
    V: 47133732
    13th April 12:00
    C: 11.2800
    O: 11.3500
    H: 11.3900
    L: 11.2300
    V: 34598783
    16th April 12:00
    C: 11.3800
    O: 11.3600
    H: 11.4500
    L: 11.2700
    V: 32803268
    17th April 12:00
    C: 11.3800
    O: 11.4300
    H: 11.4500
    L: 11.3000
    V: 30906803
    18th April 12:00
    C: 11.3300
    O: 11.3800
    H: 11.4800
    L: 11.3000
    V: 46226082
    19th April 12:00
    C: 10.9600
    O: 11.1800
    H: 11.2494
    L: 10.8500
    V: 49154173
    20th April 12:00
    C: 10.8200
    O: 11.0100
    H: 11.0300
    L: 10.7800
    V: 44930027

    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