steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
153 stars 99 forks source link

What is the function to get Steem Power of an account? #110

Closed kingsofcoms closed 6 years ago

kingsofcoms commented 6 years ago

I've looked over at https://steem.readthedocs.io/en/latest/ and i couldn't find anything. Is it possibe?

all i got was sp_to_rshares(sp, voting_power=10000, vote_pct=10000)

Parameters: sp (number) – Steem Power voting_power (int) – voting power (100% = 10000) vote_pct (int) – voting participation (100% = 10000)

kingsofcoms commented 6 years ago

Tried

from steem.account import Account

account = Account("manuelcho12") print("VP: %s" % account.voting_power()) print("SP: %s" % account.sp())

Got this error: VP: 94.13 Traceback (most recent call last): File "steemapp.py", line 5, in print("SP: %s" % account.sp()) TypeError: 'float' object is not callable

E-D-A commented 6 years ago

You get this from the Account object. You have to take into account SP delgated to you and SP you have delegated to get the active SP. I don't think there is an out of the box function. See below. I have used rstrip to remove VESTS from the string. I haven't checked, but there might be a converter function that can simplify it, but the concept stays the same.

kingsofcoms commented 6 years ago

thank you for the workaround. account.get_balances() also gets total vests but have to use json and to convert total vests to SP.