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.

    18th March 12:00
    C: 4.5000
    O: 4.7500
    H: 4.8400
    L: 4.1000
    V: 125246528
    19th March 12:00
    C: 4.4700
    O: 4.3300
    H: 4.5800
    L: 4.1000
    V: 126403658
    20th March 12:00
    C: 4.3300
    O: 4.5400
    H: 4.7500
    L: 4.2500
    V: 129311362
    23rd March 12:00
    C: 4.0100
    O: 4.2700
    H: 4.5200
    L: 3.9600
    V: 134826921
    24th March 12:00
    C: 4.9500
    O: 4.4700
    H: 4.9900
    L: 4.2600
    V: 145754989
    25th March 12:00
    C: 5.3900
    O: 5.7700
    H: 5.8700
    L: 5.1200
    V: 198655076
    26th March 12:00
    C: 5.2500
    O: 5.3600
    H: 5.6500
    L: 5.1600
    V: 138212065
    27th March 12:00
    C: 5.1900
    O: 5.0700
    H: 5.3000
    L: 4.9100
    V: 106239953
    30th March 12:00
    C: 5.0300
    O: 5.1100
    H: 5.1197
    L: 4.9300
    V: 96304242
    31st March 12:00
    C: 4.8550
    O: 5.0300
    H: 5.1900
    L: 4.8500
    V: 113061534

    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