Sadly I'm not able to test the code at the moment as I'm writing from my mobile, but it should look like this:
from steem import Steem
from steem.blockchain import Blockchain
from steem.amount import Amount
from steem.account import Account
import json
import datetime
def converter(object_):
if isinstance(object_, datetime.datetime):
return object_.__str__()
def run():
steem = Steem()
blockchain = Blockchain()
stream = blockchain.stream(filter_by=["transfer"])
username = "amosbastian"
account = Account(username)
reward_fund = steem.get_reward_fund()
reward_balance = Amount(reward_fund["reward_balance"]).amount
recent_claims = float(reward_fund["recent_claims"])
reward_share = reward_balance / recent_claims
base = Amount(steem.get_current_median_history_price()["base"]).amount
while True:
try:
for transfer in stream:
if transfer["to"] == username:
url, permlink = transfer["memo"].split("@")
if "https://steemit.com/" in url:
vests = account.get_balances()['available']['VESTS']
vp = vests * 0.02
value = vp * base * reward_share
p = float(str(transfer["amount"]).replace(" STEEM", "")) * base
if value < p:
steem.vote(f"@{permlink}", 100)
refund = p - value
steem.transfer(transfer['from'], amount=refund, asset="SBD", account=username)
else:
steem.vote(f"@{permlink}", 100 * (p/value))
except Exception as error:
print(repr(error))
continue
I think you need to take the user's current vote power into account, too
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I love how quick you are! @amosbastian will be going over your code tomorrow
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Like @maxg said you need to take the user's current vote power into account!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Ah, right, maybe next time :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit