tyrauber / stock_quote

A ruby gem that retrieves stock quotes from IEX
MIT License
210 stars 57 forks source link

real_time values are not shown #23

Closed piratmc closed 9 years ago

piratmc commented 9 years ago

Hi currentTradingSession = StockQuote::Stock.quote(tickers[n])

I'm testing live currentTradingSession.ask_realtime and other real_time values are returned as NilClass. Other non real_time values are properly returned as Float but seems like 20 minutes behind compared to actual prices. Is this a known issue and a limitation of gem/API or am I doing something wrong? Thank you!

tyrauber commented 9 years ago

@piratmc Looking at an aapl quote after trading hours I notice that ask_realtime is nil. Perhaps, those values are only available while the market is open? Or it may no longer be available through the yahoo api.

Unfortunately, the delay is a function of the Yahoo API. Originally the gem used the google finance api, before it was deprecated, which seemed to be 'more real-time'. In my experience, the closest I have been able to get to 'real-time' is with the TradeKing API (https://github.com/tyrauber/tradeking).

piratmc commented 9 years ago

Thank you for reply. I was checking values DURING trading session so expected Float but not Nil’s for real-time values. If you have time to check out if these numbers still available via yahoo API’s that would be great. Perhaps it’s just na name change or small things like that causes the return to be Nil during open trading session. Regardless, thanks work your work. And thanks for a link.

On Apr 14, 2015, at 3:51 PM, Ty Rauber notifications@github.com wrote:

@piratmc https://github.com/piratmc Looking at an aapl quote after trading hours I notice that ask_realtime is nil. Perhaps, those values are only available while the market is open? Or it may no longer be available through the yahoo api.

Unfortunately, the delay is a function of the Yahoo API. Originally the gem used the google finance api, before it was deprecated, which seemed to be 'more real-time'. In my experience, the closest I have been able to get to 'real-time' is with the TradeKing API (https://github.com/tyrauber/tradeking https://github.com/tyrauber/tradeking).

— Reply to this email directly or view it on GitHub https://github.com/tyrauber/stock_quote/issues/23#issuecomment-93102381.

tyrauber commented 9 years ago

@piratmc Unfortunately, it is not an attribute change or parsing issue. The raw data includes null for those values in the response. I have no idea why.

Query:

https://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20yahoo.finance.quotes%20WHERE%20symbol%20IN%20(%27AAPL%27)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=

Response:

   {"query":{"count":1,"created":"2015-04-14T23:17:39Z","lang":"en-US","diagnostics":{"url":[{"execution-start-time":"0","execution-stop-time":"1","execution-time":"1","content":"http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml"},{"execution-start-time":"7","execution-stop-time":"12","execution-time":"5","content":"http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AAPL"}],"publiclyCallable":"true","cache":{"execution-start-time":"5","execution-stop-time":"6","execution-time":"1","method":"GET","type":"MEMCACHED","content":"5d1e1de680846a307c9874dc3d6878dc"},"query":{"execution-start-time":"6","execution-stop-time":"13","execution-time":"7","params":"{url=[http://download.finance.yahoo.com/d/quotes.csv?f=aa2bb2b3b4cc1c3c4c6c8dd1d2ee1e7e8e9ghjkg1g3g4g5g6ii5j1j3j4j5j6k1k2k4k5ll1l2l3mm2m3m4m5m6m7m8nn4opp1p2p5p6qrr1r2r5r6r7ss1s7t1t7t8vv1v7ww1w4xy&s=AAPL]}","content":"select * from csv where url=@url and columns='Ask,AverageDailyVolume,Bid,AskRealtime,BidRealtime,BookValue,Change&PercentChange,Change,Commission,Currency,ChangeRealtime,AfterHoursChangeRealtime,DividendShare,LastTradeDate,TradeDate,EarningsShare,ErrorIndicationreturnedforsymbolchangedinvalid,EPSEstimateCurrentYear,EPSEstimateNextYear,EPSEstimateNextQuarter,DaysLow,DaysHigh,YearLow,YearHigh,HoldingsGainPercent,AnnualizedGain,HoldingsGain,HoldingsGainPercentRealtime,HoldingsGainRealtime,MoreInfo,OrderBookRealtime,MarketCapitalization,MarketCapRealtime,EBITDA,ChangeFromYearLow,PercentChangeFromYearLow,LastTradeRealtimeWithTime,ChangePercentRealtime,ChangeFromYearHigh,PercebtChangeFromYearHigh,LastTradeWithTime,LastTradePriceOnly,HighLimit,LowLimit,DaysRange,DaysRangeRealtime,FiftydayMovingAverage,TwoHundreddayMovingAverage,ChangeFromTwoHundreddayMovingAverage,PercentChangeFromTwoHundreddayMovingAverage,ChangeFromFiftydayMovingAverage,PercentChangeFromFiftydayMovingAverage,Name,Notes,Open,PreviousClose,PricePaid,ChangeinPercent,PriceSales,PriceBook,ExDividendDate,PERatio,DividendPayDate,PERatioRealtime,PEGRatio,PriceEPSEstimateCurrentYear,PriceEPSEstimateNextYear,Symbol,SharesOwned,ShortRatio,LastTradeTime,TickerTrend,OneyrTargetPrice,Volume,HoldingsValue,HoldingsValueRealtime,YearRange,DaysValueChange,DaysValueChangeRealtime,StockExchange,DividendYield'"},"javascript":{"execution-start-time":"4","execution-stop-time":"23","execution-time":"18","instructions-used":"64823","table-name":"yahoo.finance.quotes"},"user-time":"24","service-time":"7","build-version":"0.2.75"},"results":{"quote":{"symbol":"AAPL","Ask":"126.37","AverageDailyVolume":"56031500","Bid":"126.35","AskRealtime":null,"BidRealtime":null,"BookValue":"21.17","Change_PercentChange":"-0.55 - -0.43%","Change":"-0.55","Commission":null,"Currency":"USD","ChangeRealtime":null,"AfterHoursChangeRealtime":null,"DividendShare":"1.88","LastTradeDate":"4/14/2015","TradeDate":null,"EarningsShare":"7.39","ErrorIndicationreturnedforsymbolchangedinvalid":null,"EPSEstimateCurrentYear":"8.66","EPSEstimateNextYear":"9.40","EPSEstimateNextQuarter":"1.67","DaysLow":"125.91","DaysHigh":"127.29","YearLow":"73.05","YearHigh":"133.60","HoldingsGainPercent":null,"AnnualizedGain":null,"HoldingsGain":null,"HoldingsGainPercentRealtime":null,"HoldingsGainRealtime":null,"MoreInfo":null,"OrderBookRealtime":null,"MarketCapitalization":"735.67B","MarketCapRealtime":null,"EBITDA":"67.66B","ChangeFromYearLow":"53.25","PercentChangeFromYearLow":"+72.90%","LastTradeRealtimeWithTime":null,"ChangePercentRealtime":null,"ChangeFromYearHigh":"-7.30","PercebtChangeFromYearHigh":"-5.46%","LastTradeWithTime":"4:00pm - <b>126.30</b>","LastTradePriceOnly":"126.30","HighLimit":null,"LowLimit":null,"DaysRange":"125.91 - 127.29","DaysRangeRealtime":null,"FiftydayMovingAverage":"126.66","TwoHundreddayMovingAverage":"115.02","ChangeFromTwoHundreddayMovingAverage":"11.28","PercentChangeFromTwoHundreddayMovingAverage":"+9.81%","ChangeFromFiftydayMovingAverage":"-0.36","PercentChangeFromFiftydayMovingAverage":"-0.29%","Name":"Apple Inc.","Notes":null,"Open":"127.09","PreviousClose":"126.85","PricePaid":null,"ChangeinPercent":"-0.43%","PriceSales":"3.70","PriceBook":"5.99","ExDividendDate":"2/5/2015","PERatio":"17.10","DividendPayDate":"2/12/2015","PERatioRealtime":null,"PEGRatio":"1.09","PriceEPSEstimateCurrentYear":"14.57","PriceEPSEstimateNextYear":"13.44","Symbol":"AAPL","SharesOwned":null,"ShortRatio":"1.30","LastTradeTime":"4:00pm","TickerTrend":null,"OneyrTargetPrice":"139.72","Volume":"25502351","HoldingsValue":null,"HoldingsValueRealtime":null,"YearRange":"73.05 - 133.60","DaysValueChange":null,"DaysValueChangeRealtime":null,"StockExchange":"NMS","DividendYield":"1.50","PercentChange":"-0.43%"}}}}
tyrauber commented 9 years ago

@piratmc I am going to close this for now, but let me know if the above is not correct or you think there is something we could be doing differently here.