New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explain when Cryptofeed crashes during pairs retrieval #378
Conversation
looks good other than this one change. I can make the change myself it you do not have the time, just let me know |
Hi Bryant |
thanks for the PR! |
Hi Bryant The issue with CoinGecko is the huge number of supported pairs, and the difficulty to list all of them. The endpoint https://api.coingecko.com/api/v3/coins/list returns 5441 quote assets. I think there are about 15400 combinations of pairs |
Hi @olibre , I thought about that and had in mind to add to the dict of pairs a last Then, in the function checking that pair exist,
|
the pairs functions need to return all legal symbols/pairs/etc, so however you want to do it, thats fine by me |
Hi @yohplala Thank you for your ideas. |
Hi @olibre |
Thanks @yohplala Yes I think we will do some thing in this way... On my side I think we can use the endpoint
EDIT: replaced Base -> Quote |
supported vs currencies gives you quote assets, not base assets. |
🤦I sometimes confuse Quote and Base 😉 |
To clarify the situation, I will send another PR to fix the regression I have introduced with this PR. I see two solutions:
I am currently working on the second solution. But if I do not find anything better, I will just stick on the first solution. @yohplala has also good ideas. |
Sorry, I thought I had introduced a bug (regression), but it was an earlier commit that changed the def coingecko_pairs():
- quote_c = requests.get('https://api.coingecko.com/api/v3/coins/list').json()
- # Normalization
- normalized = dict({'miota': 'iota'})
- # Base currencies are defined manually (USD + BTC + ETH).
- # The full list from Coingecko is not used, as the generated dict of pairs would be tremendous.
- # base_c = requests.get('https://api.coingecko.com/api/v3/simple/supported_vs_currencies').json()
- base_c = (('USD', 'usd'), ('BTC', 'btc'), ('ETH', 'eth'))
- return {(f"{q['symbol']}{PAIR_SEP}{bk}".upper() if q['symbol'] not in normalized else f"{normalized[q['symbol']]}{PAIR_SEP}{bk}".upper()): f"{q['id']}_{bv}" for q in quote_c for bk, bv in base_c}
+ data = requests.get('https://api.coingecko.com/api/v3/coins/list').json()
+ return {entry['symbol'].upper(): entry['id'] for entry in data} The latter |
During the pairs retrieval at startup time, some exchanges may reply an erroneous response.
Currently Cryptofeed does not always handle the exception, and crashes.
Some users think this is a bug in Cryptofeed: #371 (comment)
This PR improves the user experience by providing a clear explanation of the failure.