Menu

Real-time data

Wasssssup
2010-06-14
2012-09-07
  • Wasssssup

    Wasssssup - 2010-06-14

    Hello,

    I'm looking to create a chart that tells me the price of gold in dollars. I'm
    getting the data from the yahoo stock price csv.

    I can get two arrays - last trade time and price.

    The problem I am having is finding out how this can be continually updated
    every 30mins so that I have a 24 hour chart.

    Any help would be much appreciated.

    This is the code I am using at the moment

    SetPlotType('points'); $plot->SetDataType('data-data'); $plot->SetDataValues($datatoplot); $plot->DrawGraph(); ?>
     
  • Alex Doll

    Alex Doll - 2010-06-14

    The data you are getting from Yahoo is only one data point. If you want a 24
    hour chart, then you either need to request more data from Yahoo or find a way
    to cache it. This isn't PHPlot's problem - you need to construct an array with
    all 24h worth of data to feed to PHPlot.

    Also remember to watch the structure of your $datatoplot array. It should
    contain a (blank) label then the two values you want to plot (ergo: "label",
    X, Y). The time that Yahoo provides is not a valid ISO time code readable by
    PHPlot, so you need to turn that into something more digestible.

     
  • Jon Allport

    Jon Allport - 2010-10-12

    Agreed, you will need to cache the values yourself. I'd pull the values into a
    mySQL table and then use something like:

    SELECT TradeTime, Price FROM gold WHERE  TradeTime>=DATE_SUB(DATE(),INTERVAL 24 HOUR);
    

    to pull the latest 24 hours for any given refresh and give that to PHPlot.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.