1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

display stock price on the website?

Discussion in 'Scripts' started by sabahat, Mar 11, 2014.

  1. #1
    Hello there,

    I want to display stock price on my website for the company for instance YHOO. what I need to do?
    I would like to mention that I only understand html and css so I would highly appreciate if someone properly guide me considering my skill set (not just by using programming names, jargons etc ).
    Obviously I understand there might be another language involved therefore a proper direction and guidance would be appreciated.

    regards
     
    sabahat, Mar 11, 2014 IP
  2. AbstractChaos

    AbstractChaos Member

    Messages:
    58
    Likes Received:
    4
    Best Answers:
    4
    Trophy Points:
    25
    #2
    Hi there,

    One way to do this would be to use a Stock Data api, one such is googles the url below
    http://www.google.com/finance/info?infotype=infoquoteall&q=GOOG&callback=?

    Returns JSONP which is "JSON with padding" a workaround for cross domain scripting rule.

    I written an example of its usage in JQuery
    $(document).ready(function() {
        $.ajax({ url: 'http://www.google.com/finance/info?infotype=infoquoteall&q=GOOG&callback=?',
                jsonpCallback: 'jsonCallback',
                contentType: "application/json",
                dataType: 'jsonp',
                async:false,
                success: function(json) {
                   $('#result').html(json[0].name+' - '+json[0].l);
                },
                error: function(e) {
                   console.log(e.message);
                }
               });
    });
    Code (markup):
    This requres the JQuery library found here (http://jquery.com/)

    and a working example (http://jsfiddle.net/B2HL8/4/)

    Hope this helps
     
    AbstractChaos, Mar 20, 2014 IP
  3. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3

    Perfect! thats called proper guidance. with fiddle link. Thanks bro
    One more thing there are some Stocks that do not show up. like LRDR, ASKE when I replace GOOG with any of these.

    what do I need to do for that?
     
    sabahat, Mar 21, 2014 IP
  4. AbstractChaos

    AbstractChaos Member

    Messages:
    58
    Likes Received:
    4
    Best Answers:
    4
    Trophy Points:
    25
    #4
    From what i can tell they are not present on googles financial data. I Checked yahoo for the ones you provided and they are both present there i updated the fiddle with a way to do it.
    http://jsfiddle.net/B2HL8/7/

    however it requires the use of yahoo query builder.
    developer.yahoo.com/yql/console
     
    AbstractChaos, Mar 21, 2014 IP
  5. MikeLugar

    MikeLugar Well-Known Member

    Messages:
    1,453
    Likes Received:
    36
    Best Answers:
    2
    Trophy Points:
    150
    #5
    I think Yahoo also has an API as well that you can use. If you eventually want to display real-time stock prices you can purchase a license from http://www.xignite.com/
     
    MikeLugar, Mar 21, 2014 IP
  6. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6

    Thank you so much for your reply. sorry for late response. The fiddle you shared this time shows loads of information not sure if that's a glitch or what but as the fiddle link you shared above that showed just google price is perfect and something I am looking for.
    but the stock in this case is LRDR

    I checked on google stock it showed me LRDR information
    https://www.google.co.uk/finance?q=lrdr&ei=zAdFU4DwLqmEwAOGvwE
    Could we use it the way you used/displayed Google stock.

    Your help would be highly appreciated.
     
    sabahat, Apr 9, 2014 IP
  7. AbstractChaos

    AbstractChaos Member

    Messages:
    58
    Likes Received:
    4
    Best Answers:
    4
    Trophy Points:
    25
    #7
    Not a glitch, it's simply to show everything that is sent back to you which is a lot more info than just a stock price.

    I was able to retrieve the price using q='OTCMKTS%3ALRDR'
    http://jsfiddle.net/B2HL8/9/

    Note %3A is a urlencoded :
     
    AbstractChaos, Apr 9, 2014 IP
  8. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #8
    Thanks for your quick reply.


    Thanks for your quick reply.
    I am naive in this area so thought may be that is a glitch lol sorry about that.

    Sorry for being pain again. Could you also tell me please how to hide other stock info. I am basically just interested in Stock price like initially you displayed Google's price
     
    sabahat, Apr 9, 2014 IP
  9. AbstractChaos

    AbstractChaos Member

    Messages:
    58
    Likes Received:
    4
    Best Answers:
    4
    Trophy Points:
    25
    #9
    AbstractChaos, Apr 9, 2014 IP
  10. sabahat

    sabahat Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #10
    Hey thank you so much bro.
     
    sabahat, Apr 9, 2014 IP