googlefinance-client-python icon indicating copy to clipboard operation
googlefinance-client-python copied to clipboard

Wrong data from google finance for several ticker symbols

Open Ang3er opened this issue 8 years ago • 12 comments

HI there,

Iam facing the problem that wrong values are recieved, for example the tickers FRA:ADE, FRA:SIE, FRA:IFX

Do I have to use the script in a specific way when calling FRA, as some of the values are correct and some are not.

Thanks in advance Ang3er

Ang3er avatar Nov 07 '17 11:11 Ang3er

I've had similar issues. Try replacing https://www.google.com/finance/getprices with https://finance.google.com/finance/getprices everywhere in client.py and see if it helps.

thomashaselwanter avatar Nov 12 '17 04:11 thomashaselwanter

BIT:ENV works fine for me after the change. Before the change the library makes a request to https://www.google.com/finance/getprices?i=86400&x=BIT&q=ENV&p=1Y which gets redirected to https://finance.google.com/finance/getprices?q=ENV&p=1Y and returns wrong results (it looses the exchange identifier and therefore returns results for ENV on NYSE, rather than ENV on BIT). After the change the library makes a request to https://finance.google.com/finance/getprices?i=86400&x=BIT&q=ENV&p=1Y which returns the correct results. You can try this out in your browser.

thomashaselwanter avatar Nov 16 '17 00:11 thomashaselwanter

I don't think todays prices fit in the data of this particular function which return historical prices for a long time window. It return close, high, low, open and volume. There is no column for current price. You could only provide open for the current day, but you need to wait until the exchange closes to be able to give the close, high and low price and know how much volume there was for the day.

There is probably a different function in the Google API to get the current price. Google deprecated the API years ago though, so no guarantee it is there now or will be there in the future. Not sure if this library implement getting the current quote either. I haven't seen it, but I only began using this particular library a couple days ago.

thomashaselwanter avatar Nov 16 '17 23:11 thomashaselwanter

Can you post a URL/example for the intraday query?

thomashaselwanter avatar Nov 21 '17 08:11 thomashaselwanter

I guess i=60&p=1H does the job.

thomashaselwanter avatar Nov 21 '17 09:11 thomashaselwanter

Try replacing https://www.google.com/finance/getprices with https://finance.google.com/finance/getprices everywhere in client.py and see if it helps.

Yes, that helped.

Please publish a new version via pypi, thanks.

drandreaskrueger avatar Dec 02 '17 00:12 drandreaskrueger

Please publish a new version via pypi, thanks.

I'm not the owner of this github repository just a user, so I can't. Yet another user already created a pull request with the fix, but the original author has not responded yet and has been last active on github 6 month ago, so there is a chance this code is abandoned. If you really care about pypi availability you could fork it and publish your own fixed version .

thomashaselwanter avatar Dec 02 '17 09:12 thomashaselwanter

I need currency prices. Ideally the newest possible.

For now I am using:

query=[{'q': 'USDEUR'}, {'q': 'USDCNY'}, {'q': 'USDJPY'}, ...]
forex=googlefinance.client.get_prices_data(query, period = '2d')

which seems to then query endpoints like

https://finance.google.com/finance/getprices?q=USDBRL&p=2d&i=86400

now there are several issues:

  • it is slow
  • I am using a query which is designed to return timeseries of weeks or months of data - but I only need the LAST price
  • I don't seem to be able to get the price of last HOUR, only of last DAY, so I will always be 1 day behind.

yes I have also tried

https://finance.google.com/finance/getprices?q=USDBRL&p=2h&i=3600

but get empty tables back (depending on the exact time of day).

And

googlefinance.getQuotes(symbols="USDBRL")

which generates this URL
http://finance.google.com/finance/info?client=ig&q=USDBRL
comes back 404

any hints?

Thanks!

drandreaskrueger avatar Dec 03 '17 01:12 drandreaskrueger

by the way, if anyone's interested, I am using it for this onepage app: http://btc.hopto.org

drandreaskrueger avatar Dec 03 '17 03:12 drandreaskrueger

yes I have also tried https://finance.google.com/finance/getprices?q=USDBRL&p=2h&i=3600 but get empty tables back.

Use a larger p and it wont be empty. Using the smaller i you should get you the last pricer, rather than last days price.

https://finance.google.com/finance/getprices?q=USDBRL&p=5d&i=3600

thomashaselwanter avatar Dec 03 '17 10:12 thomashaselwanter

If I am not wrong this is not a problem of this package but a characteristic of the data, in fact also on google finance chart stock split are not accounted for.

True, and there is probably no way around it with the Google Finance data. Your linkedin page says you work at Morgan Stanley, shouldn't you have access to better datasources there which account for stocksplits, dividends and spin-offs?

thomashaselwanter avatar Dec 03 '17 10:12 thomashaselwanter

does googlefinance also provide a "ticker" type of data with really only the last price, and not a whole table of many datetime-to-prices information?

Asking because that call that is used here does become very slow when asking for several currencypair symbols.

drandreaskrueger avatar Dec 07 '17 11:12 drandreaskrueger