Getting expiring delegations via steem-python

in steem-python •  7 years ago 

I believe none of the alternative steem interfaces shows thatR.I.P steem.rocks. Steemd supports a RPC call which returns the expiring delegations.

It means, you can actually see the exact time when you will get your SP back after the delegation revoke cooldown period. (1 week, 1 month on some cases.)


from steem import Steem
from datetime import datetime, timedelta
from steem.converter import Converter
from steem.amount import Amount


def get_expiring_delegations(username):
    s = Steem()
    c = Converter()
    eight_days_ago = datetime.utcnow() - timedelta(days=8)

    expiring_delegations = s.get_expiring_vesting_delegations(
        username,
        eight_days_ago.strftime("%Y-%m-%dT%H:%M:%S"),
        1000
    )

    for delegation in expiring_delegations:
        sp = c.vests_to_sp(Amount(delegation["vesting_shares"]).amount)
        expiration = delegation["expiration"]
        print(f"{sp} SP will be released at {expiration}")


if __name__ == '__main__':
    get_expiring_delegations("emrebeyler")

Example output:

300.24084853296995 SP will be released at 2018-06-20T12:17:30
1201.0209624783504 SP will be released at 2018-06-22T15:10:00
10.011333005430853 SP will be released at 2018-06-25T23:48:45

@steemchiller, can we have that on steemworld? :)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thanks man! Didn't know about the 'get_expiring_vesting_delegations' call. Would be great to have them in the outgoing delegations section... I will see what I can do ;)

Hey - I noticed a changed implemented in steemworld this morning :-) Delegation tab on left, and three tabs are possible to open now - it looks a lot neater and this expiring delegation feature is really cool. Thanks to @emrebeyler for the collaboration

Done! Is there any reason why you subtracted 8 days in your example? I'm using the current utc time and it seems to work:

Thanks for the fast implementation! :) Regarding the question, to be honest I dont remember why I removed 8 days. That was an old code - cant recall why I did that.

@oneazania appreciated this comment via @poetsunit
Poetsunit
DISCORD - @poetsunited - witness upvote

Great post, keep it up @emrebeyler