Skip to content

Instantly share code, notes, and snippets.

@emre
Created November 23, 2017 13:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emre/cd88f496b7c82d6b99c6bfb9e7a345ee to your computer and use it in GitHub Desktop.
Save emre/cd88f496b7c82d6b99c6bfb9e7a345ee to your computer and use it in GitHub Desktop.
up-to-date voting power calculation (steem-python)
from dateutil.parser import parse
from datetime import datetime
def get_voting_power(account_data):
last_vote_time = parse(account_data["last_vote_time"])
diff_in_seconds = (datetime.utcnow() - last_vote_time).seconds
regenerated_vp = diff_in_seconds * 10000 / 86400 / 5
total_vp = (account_data["voting_power"] + regenerated_vp) / 100
if total_vp > 100:
return 100
return "%.2f" % total_vp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment