Last active
August 3, 2018 20:33
-
-
Save meany/158c898745273e16074be7690b9b6455 to your computer and use it in GitHub Desktop.
CMC Banano lookup (temporary until listing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/sterlingbeason/coinmarketcap-professional | |
from coinmarketcap_pro.client import Client | |
client = Client("<GUID>") | |
# query weight 10 | |
# so like, only one call an hour maybe on the free version | |
response = client.request_api_endpoint("cryptocurrency/listings/latest", {'limit': 1000}) | |
if response["status"]["error_code"] is 0: | |
# cache response | |
f = open('cmc.txt', 'w') | |
f.write(str(response)) | |
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inside !price logic | |
f = open('cmc.txt', 'r') | |
r = eval(f.read()) | |
f.close() | |
# replace with calculated ban cap | |
cap = 7817437.18 | |
i = 1 | |
for coin in r['data']: | |
if coin['quote']['USD']['market_cap'] < cap: | |
# i = CMC rank | |
print i | |
break | |
else: | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment