tyrauber / stock_quote

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

history not working #51

Closed ronnyworm closed 6 years ago

ronnyworm commented 6 years ago

I freshly installed Version 1.5.4 These two commands yield the same results in irb:

require 'stock_quote'
StockQuote::Stock.history("inl.de")
require 'stock_quote'
StockQuote::Stock.quote("inl.de")

And for this I am just getting a runtime Error: StockQuote::Stock.history("inl.de", "2017-01-01", "2017-12-01") RuntimeError: Invalid Query

Any ideas how to fix this?

ronnyworm commented 6 years ago

Ok, I just realized that the result thing (history vs. quote with no further parameters) is intended like this.

The runtime error results because of a "wrong" format of my symbol. Google Finance API does not recognize INL.DE. Yahoo Finance API did ...

I figured it all out now: I have to use symbols like this: FRA: instead of .F or *.DE So it's FRA:INL for example.

Furthermore Yahoo used to return an array with hashes. Now it's a hash (keys: symbol and history) including an array including the hashes. Fortunately, I can just use the history element.

Aaaand the date format changed. It used to be a string in this format: yyyy-mm-dd. Now it is dd-(Monthname with 3 letters)-yy. For my purpose I just needed to wrap it around a DateTime.parse

tyrauber commented 6 years ago

Glad you sorted it out. I tried to keep the api as close as possible, but unfortunately the switch back to Google from Yahoo obviously introduced some changes. I have found that Google is generally more lenient with date formatting...

Thanks for reporting back.