Statistics of SBD payment has been received by transfer

in python •  6 years ago 

want to know how much SBD people has been transfer to your account?

from steem import Steem
from coinmarketcap import Market

################################################################################
#####################       update deposit            ##########################
################################################################################
def payment_list(acc_name,nodes):
    s = Steem(nodes)
    ac=steem.account.Account(acc_name,s)
    transfers = ac.get_account_history(-1,10000,filter_by=['transfer'])
    coinmarketcap = Market()
    Steem_market_price_USD= float(coinmarketcap.ticker('steem', convert='USD')[0]['price_usd'])
    SBD_market_price_USD= float(coinmarketcap.ticker('steem-dollars', convert='USD')[0]['price_usd'])

    payment_list={}
    # update transfer record and deposit list
    for transfer in transfers:
        if(transfer['to']==acc_name):
            if(transfer['from'] not in payment_list):
                if (transfer['amount'].split()[0]=='STEEM'):
                    SBD_amount = float(transfer['amount'].split()[0])*Steem_market_price_USD/SBD_market_price_USD
                else:
                    SBD_amount = float(transfer['amount'].split()[0])

                payment_list.update({transfer['from']:{'SBD':SBD_amount,
                                                       'last_transfer_time':transfer['timestamp']
                    }
                })
            else:
                payment_list[transfer['from']]['SBD'] = payment_list[transfer['from']]['SBD']+float(transfer['amount'].split()[0])
                payment_list[transfer['from']]['last_transfer_time'] = transfer['timestamp']
    print(payment_list)

################################################################################
nodes = ['https://api.steemit.com',
         'https://steemd.minnowsupportproject.org',
         'https://rpc.buildteam.io',
         'https://steemd.privex.io',
         'https://gtg.steem.house:8090']
payment_list('python-dev',nodes)
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:  

Congratulations @python-dev! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You made your First Comment
You got a First Reply

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - Steem Power, Followers and Following added

Support SteemitBoard's project! Vote for its witness and get one more award!

这个非常实用啊,什么时候统计一下我的账户,看看谁才是我的金主?哈哈