marcopaganini / quotes-exporter

Quotes exporter for prometheus (Supports stocks, ETFs and funds)
9 stars 3 forks source link

Error response received from upstream api #4

Closed helmut72 closed 1 year ago

helmut72 commented 1 year ago

Is this still working? When opening your example URL, log output is:

2023/05/04 20:33:55 URL: /price?symbols=VTIAX
2023/05/04 20:33:55 Error looking up VTIAX: code: remote-error, detail: code: remote-error, detail: error response recieved from upstream api

Thank you.

marcopaganini commented 1 year ago

You're correct. It's broken. Thanks for bringing it to my attention. This message is coming from the upstream library. I'll take a look.

umatare5 commented 1 year ago

I checked that Y-Finance API v7 invoked by finance-go v1.0.0 has been stopped. In response to this case, finance-go created new release v1.1.0 that downgraded the API to v6.

https://github.com/piquette/finance-go/releases/tag/v1.1.0

marcopaganini commented 1 year ago

Oh nice, thanks. When I checked only v1.0.0 was available. Approving and merging.

umatare5 commented 1 year ago

Thanks!

helmut72 commented 1 year ago

Thank you. I wanted to try it today, but still doesn't work.

marcopaganini commented 1 year ago

Oh bummer. I tested this but now it's broken again?!? Let me take a look. Maybe it's time to change the library. It's a shame that there's no reasonable, free way to fetch stock prices.

marcopaganini commented 1 year ago

So I'm having a hard time finding an API that 1) Is free, 2) Is reliable, and 3) Allows a reasonable number of calls per day on the free tier. I found alphavantage which appears to be good, but they're limited to 500 calls a day, which would be exhausted rather quickly (~ one request every 3h).

From a brief read of their documentation, it appears that they consider every single request a call (counting towards the 500 calls per day limit), which would limit things even further.

I'm still looking, but please do share if you know of a good finance API that meets the above criteria.

helmut72 commented 1 year ago

I've searched in your used Library: https://github.com/piquette/finance-go/issues/25

Then found this one: https://stackoverflow.com/questions/76065035/yahoo-finance-v7-api-now-requiring-cookies-python

Then I've tried this in a Linux Bash:

curl -c cookie.txt "https://fc.yahoo.com"
crumb=$(curl -s -b cookie.txt "https://query2.finance.yahoo.com/v1/test/getcrumb")
curl -s -b cookie.txt "https://query2.finance.yahoo.com/v7/finance/quote?symbols=AAPL&crumb=$crumb" |jq

Works! Of course I don't know how long...

marcopaganini commented 1 year ago

Yeah I think anything based on yahoo finance is doomed to fail. The API has been more than deprecated. One simple option (I may implement it quickly) is to use stonks.scd31.com. I'll probably release an interim version with support for that.

On Sun, May 28, 2023 at 12:43 AM helmut72 @.***> wrote:

I've searched in your used Library: piquette/finance-go#25 https://github.com/piquette/finance-go/issues/25

Then found this one:

https://stackoverflow.com/questions/76065035/yahoo-finance-v7-api-now-requiring-cookies-python

Then I've tried this in a Linux Bash:

curl -c cookie.txt "https://fc.yahoo.com" crumb=$(curl -s -b cookie.txt "https://query2.finance.yahoo.com/v1/test/getcrumb") curl -s -b cookie.txt "https://query2.finance.yahoo.com/v7/finance/quote?symbols=AAPL&crumb=$crumb" |jq

Works! Of course I don't know how long...

— Reply to this email directly, view it on GitHub https://github.com/marcopaganini/quotes-exporter/issues/4#issuecomment-1565970267, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABYUYBC5B25TBMVFFC2YMLTXIL6ZRANCNFSM6AAAAAAXWIW2XQ . You are receiving this because you modified the open/close state.Message ID: @.***>

marcopaganini commented 1 year ago

I just submitted https://github.com/marcopaganini/quotes-exporter/commit/58f6d115c37e58f960f6008f873fa6f6214ec536 which switches the quotes provider to stonks.scd31.com. This has the unfortunate side effect of not supporting mutual funds, but at least (for now) it avoids the hassle of users having to register and maintain API keys and deal with quota issues from most financial API providers out there.

marcopaganini commented 1 year ago

@helmut72 please let me know if it works for you now.

helmut72 commented 1 year ago

Works now, thank you.