Steemit API + Python: Calculate Your Steemit Spending!

in #python7 years ago (edited)

steemit

Another discussion with @themarkymark, another DIY Seemit report! ;)

We were trying to figure out if I was over-spending on my Steemit activities.

I have a tendency to get carried away with spending money, physical or crypto. Had I gone overboard with my SBD investment?

Using the approximately accurate math ( reward * 0.75 / 2 ) we can roughly determine the SBD I get back from an article.

payout=(( Amount(post["pending_payout_value"]).amount * 0.75) /2)

Therefore we can see what the actual reward was or forthcoming reward might be.

payout = (Amount(post["total_payout_value"]).amount - Amount(post["curator_payout_value"]).amount)

How do we tell how much I spent?

Code

from steem import Steem
s = Steem()


import time, random, os

rposts = s.get_account_history('makerhacks',-1,10000)

total = 0
for post in rposts:

    operation =  post[1]['op'][0]
    if operation == "transfer":
        if post[1]['op'][1]['from'] == "makerhacks" and not post[1]['op'][1]['to'] == "themarkymark":
            print( post[1]['op'][1]['to'] + "\t\t\t" + str( post[1]['op'][1]['amount'] ))
            total = total + float(post[1]['op'][1]['amount'].replace(' SBD',''))


print ("\n\n" + str(total) + " SBD \n\n\n")

This gets 10,000 transfers where I sent from my account but NOT to @themarkymark (because that would have been a loan repayment - yes, he is my Steem loan shark ;) ).

Obviously you would need your own Steemit details and logic there.

See any problems with this? Please share in the comments!

Sort:  

Maybe, my solution is helpful:
https://steemit.com/steemdev/@holger80/how-to-estimate-the-real-pending-post-payout-by-subtracting-bought-votes
I used my script to calculate the sum of your last 46 posts (fixed version):
Sum for the last 46 posts:
Payout: 563.78 SBD and 122.95 SP
483.77 SBD used for buying votes
Remaining: 80.01 SBD and 122.95 SP
The estimated real value gained per post in SBD (including SP) is 4.870881

So what's the conclusion ? Are you overspending ?

Unclear 😂

@themarkymark used a database approach and says not, when I use the "* 0.75 / 2" calculation I find I've overspent slightly but potentially ahead depending on actual curation rewards and the 10% your WP plugin takes on my syndicated posts :)

We don't take 10% of the sbd so it should be fine :D It's only 10% of the steem power.

Ahhh good to know :)

I'm working on steemit analyzers with the python library, although some API functions seem to be no-op, like
get_account(user)['comment_count']
as comments are counted as posts.

Thank you for sharing this code snippet!

Just query for author_reward ops.

[7579, {'block': 19557607, 'op': ['author_reward', {'author': 'makerhacks', 'permlink': 'getstartedwiththeinternetofthingswithanesp8266iotsensortimer2l7cfpzml5', 'sbd_payout': '19.577 SBD', 'steem_payout': '0.000 STEEM', 'vesting_payout': '8704.567300 VESTS'}], 'op_in_trx': 1, 'timestamp': '2018-02-03T22:12:03', 'trx_id': '0000000000000000000000000000000000000000', 'trx_in_block': 51, 'virtual_op': 0}],

You will need to use the converter class to convert the vests to SP to make more sense of it.

How do you do that?

You can only grab 10,000 at a time with get_account_history, but you can walk them. Or you can use SteemData.

I need to look at SteemData, seems the right approach

I've been using it far more lately, I usually just use python but I'm starting to love it. You can also use SteemSQL which uses SQL instead of MongoDB.

I estimated the relation between vests and Steem by a linear approximation. You can find my python code here: https://steemit.com/steemdev/@holger80/how-to-estimate-historic-steempermvests-values-for-converting-old-rewards-from-vest-to-steem

Your post had been curated by the @buildawhale & @ipromote team and mentioned here:

https://steemit.com/curation/@buildawhale/buildawhale-curation-digest-02-09-18

Keep up the good work and original content, everyone appreciates it!

Useful code, Thank you

You got a 2.07% upvote from @postpromoter courtesy of @makerhacks!

Want to promote your posts too? Check out the Steem Bot Tracker website for more info. If you would like to support the development of @postpromoter and the bot tracker please vote for @yabapmatt for witness!

Where are you reading the user's credentials from?
I know you said :"Obviously you would need your own Steemit details and logic there.", but just curious how you passed your credentials.
Thanks nice article.

You use the wallet that comes with steem-python