Skip to content

Instantly share code, notes, and snippets.

@buzzkillb
Last active August 19, 2020 18:20
Show Gist options
  • Save buzzkillb/7176dd0e2b2eeebd5006da328345be01 to your computer and use it in GitHub Desktop.
Save buzzkillb/7176dd0e2b2eeebd5006da328345be01 to your computer and use it in GitHub Desktop.
#calculate total staking against circulating, median, min, max for $BLOCK, python3
import statistics
import requests
# TODO: Add error handling
staking = requests.get("https://chainz.cryptoid.info/explorer/index.stakes.dws?coin=block").json()
circulating = float(requests.get("https://chainz.cryptoid.info/block/api.dws?q=circulating").text)
staking_sum = sum(map(lambda x: float(x['amount'] or 0), staking['stakes']))
staking_median = statistics.median(map(lambda x: float(x['amount'] or 0), staking['stakes']))
staking_min = min(map(lambda x: float(x['amount'] or 0), staking['stakes']))
staking_max = max(map(lambda x: float(x['amount'] or 0), staking['stakes']))
print("Total Staking:", staking_sum)
print("Staking Median:", staking_median)
print("Staking Minimum:", staking_min)
print("Staking Maximum:", staking_max)
print("Circulating Supply", circulating)
percent_staking = (staking_sum / circulating) * 100
print("Percent Staking", percent_staking)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment