Daily Steem-Python Challenge #8, Win 1 Steem!

in #contest7 years ago (edited)

For each tutorial we release there will be a relevant challenge where the winner receives 1 STEEM!

Challenge

Today's challenge is a little bit more difficult than usual. Take the code from the tutorial from here and change it to be able to do the following

  1. Calculate how much your 100% upvote is worth, then upvote the specified post with an upvote that is equal to the received SBD (so if it's less, you should refund the difference)!

That's it! Good luck to everyone participating!

Deadline

The prize money will be rewarded to the person that solves the problem first. If there is no solution within 7 days after this post has been submitted the prize pool expires.

Relevant Tutorial

How To Create Your Own Upvote Bot Using Steem-Python


If you have questions about the tutorial or the challenge then don't hesitate to comment below or contact us on Discord!

Sort:  

Code:

Again on point! Just about to go over the code from the challenge from yesterday and you have already submitted another ;)

Just tested it and there are some tiny errors, but if you fix them, then it works as specified! Go, go, go, if you are quick you can still win!

Cleaned and updated!
There was one pretty big error with how I was calculating voting power. The voting power param set on the account object is your VP at the last time you voted. So you need to do some math with the last vote time to figure out your current real voting power.

def calc_vote_power(account):
    vp = account['voting_power']
    last = datetime.strptime(account['last_vote_time'], "%Y-%m-%dT%H:%M:%S")
    diff = datetime.utcnow().timestamp() - last.timestamp()
    return (vp + 1e4 * diff / 432e3) / 10000

I actually had to find this one by going through the source code for steemnow

Other than that it was just import errors and the like :P

O wow, I didn't know that about voting power! I just sent you the STEEM, congratulations!

😇

Loading...