Need Help with Yahoo Finance API Web Request

Hey ..

Well .. I have a need for some help. I am interested in making a stock app .. so that I can check my stocks.

Edit .. I can get the data in the simulator, which is a start.

It is as follows ..

{query=>{results=>{quote=>{OneyrTargetPrice=>null, LowLimit=>null, HoldingsGain=>null, AverageDailyVolume=>934476, Commission=>null, ExDividendDate=>null, MarketCapitalization=>316.96B, HoldingsValueRealtime=>null, LastTradeDate=>2/10/2017, ErrorIndicationreturnedforsymbolchangedinvalid=>null, HighLimit=>null, EPSEstimateNextYear=>null, LastTradePriceOnly=>1.05, Symbol=>LAC.TO, LastTradeTime=>3:59pm, PriceSales=>486880.53, Bid=>1.04, Volume=>1823026, DaysHigh=>1.05, Notes=>null, PriceBook=>6.25, TradeDate=>null, FiftydayMovingAverage=>0.93, PercentChangeFromYearLow=>+141.38%, DaysLow=>1.00, ChangeRealtime=>null, DaysRangeRealtime=>null, PricePaid=>null, PercentChange=>+5.00%, Name=>LITHIUM AMERICAS CORP, symbol=>LAC.TO, AskRealtime=>null, DaysValueChangeRealtime=>null, PriceEPSEstimateNextYear=>null, HoldingsGainPercent=>null, YearHigh=>1.14, EPSEstimateCurrentYear=>0.00, AfterHoursChangeRealtime=>null, BookValue=>0.16, PreviousClose=>1.00, Currency=>CAD, SharesOwned=>null, ChangePercentRealtime=>null, DividendYield=>null, ChangeFromFiftydayMovingAverage=>0.12, EarningsShare=>-0.08, PEGRatio=>0.00, Ask=>1.05, MoreInfo=>null, TickerTrend=>null, PercebtChangeFromYearHigh=>-7.89%, ShortRatio=>0.00, YearLow=>0.44, YearRange=>0.44 - 1.14, Open=>1.02, Change_PercentChange=>+0.05 - +5.00%, TwoHundreddayMovingAverage=>0.86, ChangeFromYearHigh=>-0.09, PERatioRealtime=>null, PercentChangeFromFiftydayMovingAverage=>+13.16%, DaysRange=>1.00 - 1.05, EPSEstimateNextQuarter=>0.00, PriceEPSEstimateCurrentYear=>null, LastTradeWithTime=>3:59pm - <b>1.05</b>, StockExchange=>TOR, MarketCapRealtime=>null, HoldingsValue=>null, PERatio=>null, Change=>+0.05, DaysValueChange=>null, DividendShare=>null, AnnualizedGain=>null, BidRealtime=>null, LastTradeRealtimeWithTime=>null, ChangeFromTwoHundreddayMovingAverage=>0.19, HoldingsGainRealtime=>null, PercentChangeFromTwoHundreddayMovingAverage=>+22.17%, ChangeFromYearLow=>0.61, HoldingsGainPercentRealtime=>null, OrderBookRealtime=>null, EBITDA=>-10.93M, ChangeinPercent=>+5.00%, DividendPayDate=>null}}, created=>2017-02-12T20:08:06Z, count=>1, lang=>en-US}}

My web request is as follows ..

Comm.makeWebRequest("query.yahooapis.com/.../yql, null, {},method(:onWebResponse) );



But I am only interested in really .. the LastTradePrice and the OpeningPrice. I can do the needed math.

If someone would be able to let me know how to parse out the needed data from the above .. that would be nice.

Thanks
Kevin
  • Actually I found that it was my error as it is working just fine now.
    There was something wrong in my code that was causing the issue. Not 100% sure what it was ... but the problem has resolved itself.

    Now that the markets are open for the day now .. I can test the app and see how it is working.

    Kevin
  • Ok .... well, it was a good concept, but it is flaky as bleep.

    If I run it .. I get yesterdays data, then running it again a minute later, I get data from today.

    I surely need some help on this one. I guess this project is on hold for now.

    I feel it is definitely an issue with the WHERE in the URL but I cannot find any good documentation on that on the web.

    Kevin
  • Former Member
    Former Member over 8 years ago
    Ok .... well, it was a good concept, but it is flaky as bleep.

    If I run it .. I get yesterdays data, then running it again a minute later, I get data from today.

    I surely need some help on this one. I guess this project is on hold for now.

    I feel it is definitely an issue with the WHERE in the URL but I cannot find any good documentation on that on the web.

    Kevin



    I have been using the YQL api the last couple of weeks to make some test web requests, and discovered that the data is very bad for stock prices. I found numerous reports when googling the issue of YQL returning old data. There doesn't seem to be any resolution to the issue. In my experience the Google Finance API works really well, but it is deprecated, and has invalid characters at the start of the JSON response, so CIQ will not convert it. If you created a pass through service that stripped those characters it would probably work well, but Google could change/remove/restrict the service at any time since it isn't officially supported anymore.

    Edit: Someone on stackexchange (here) mentions that "if your application is for public consumption, using the Google Finance API is against Google's terms of service.", so I guess that is something important I should mention.
  • I have been using the YQL api the last couple of weeks to make some test web requests, and discovered that the data is very bad for stock prices. I found numerous reports when googling the issue of YQL returning old data. There doesn't seem to be any resolution to the issue. In my experience the Google Finance API works really well, but it is deprecated, and has invalid characters at the start of the JSON response, so CIQ will not convert it. If you created a pass through service that stripped those characters it would probably work well, but Google could change/remove/restrict the service at any time since it isn't officially supported anymore.

    Edit: Someone on stackexchange (here) mentions that "if your application is for public consumption, using the Google Finance API is against Google's terms of service.", so I guess that is something important I should mention.


    Brian .. I would be very interested in what you come up with. I am testing it with Yahoo Finance ... and see how it works for me. My program is for personal use only.
  • Former Member
    Former Member over 8 years ago
    I probably won't come up with much of anything beyond this. I was just trying to fetch a stock price to validate that an application I was working on could complete a web request successfully. I noticed that the data I was getting from YQL was bad and investigated a bit, but don't actually need the data to be reliable for my testing.

    I did some quick searches to see if there are any other services out there, but didn't really turn up anything. I found one other service, but it appeared to be returning the YQL data.
  • I probably won't come up with much of anything beyond this. I was just trying to fetch a stock price to validate that an application I was working on could complete a web request successfully. I noticed that the data I was getting from YQL was bad and investigated a bit, but don't actually need the data to be reliable for my testing.

    I did some quick searches to see if there are any other services out there, but didn't really turn up anything. I found one other service, but it appeared to be returning the YQL data.


    Thanks Brian .. I will look into it. Right now my app is undergoing testing.
  • I am using phoneConnected to see if GCM is running, but is there a way to see if I have internet connectivity ?
    I want to make it a bit more robust. Other than the possibly flaky data from Yahoo (it doesn't seem to be like the downloaded Yahoo CSV data), the app is working very well.

    For example .. I get this, the current time on the TSX is about 1:34 PM, so it looks like the data is over an hour old.
    LastTradeWithTime=>12:31pm - <b>12.56</b>, PreviousClose=>12.10, LastTradeDate=>2/16/2017}

    As a note, my data from "download.finance.yahoo.com/.../quotes.csv" is 15 min delayed.

    I have determined that the CSV version is bang on .. but yes 15 min delayed. So does anyone know .. if I can use that data ? I am assuming not as it is a download vs a query.

    Kevin
  • I am using phoneConnected to see if GCM is running, but is there a way to see if I have internet connectivity ?
    I want to make it a bit more robust. Other than the possibly flaky data from Yahoo (it doesn't seem to be like the downloaded Yahoo CSV data), the app is working very well.


    In my METAR/TAF widget I just attempt to request the data. Then if the responseCode == Communications.BLE_CONNECTION_UNAVAILABLE then I know that there's an issue with the BLE connection with the phone. If the responseCode == Communications.NETWORK_REQUEST_TIMED_OUT it usually means that there's no Internet connection.

    Cheers,
    Douglas
  • Thanks Douglas I will give that a try ..

    Kevin
  • For me. phoneConnected is always tested. If there is no BT, I don't even try the request, and display a message which indicates that. For a widget, that's it - try again later when there's a connection and stop. For an app that does something like get data every 10 minutes, I'll note the error on the display, and just wait for the next try (usually with an action to try again right away). If there's an error with phoneConnected==true, I'll then display the error with that. Some of the error codes are a bit of a catch all - if the request timed out, it could be there's no internet connection, or it could be the server is down or very slow. Other sites might be responding just fine.