You are viewing a single comment's thread from:

RE: Beem tutorials #3 - Delegations with Beem

in #utopian-io7 years ago

You also need to implement for incoming delegation if the amount of delegation changes.
What I do, go reverse in account history.
Look for incoming delegation.
If delegator is not in dict, put the numbers in the dict, that has to be defined before.
If already in dict, pass.
Now we have all and print the dict.

Sort:  

good idea!
Mine looks like this now

delegationlist = []
delegatorslist = []
spmv = steem.get_steem_per_mvest()

for operation in acc.history_reverse(only_ops=["delegate_vesting_shares"]):
    delegator = operation["delegator"]
    if delegator not in delegatorslist:
        delegatorslist.append(delegator)
        vsamount = Amount(operation["vesting_shares"]).amount
        if vsamount != 0:
            delegationlist.append([delegator, round(vsamount*spmv/1e6)])

Coin Marketplace

STEEM 0.12
TRX 0.34
JST 0.033
BTC 123358.42
ETH 4526.96
BNB 1306.65
SBD 0.77