示例#1
0
文件: test.py 项目: steemtm/payoutbot

# USE ONLY IF YOU WANT TO PULL KEYS FROM KEYS.TXT (MUST BE IN THE SAME DIRECTORY AS THIS PYTHON FILE!)
def get_keys():
    with open('keys.txt', 'r') as f:
        keys = f.read().split()
    return keys


##########################################################
# Initialize STEEM blockchain connections and variables. #
##########################################################
# s = Steem(keys=['<PRIVATE_POSTING_KEY>', '<PRIVATE_ACTIVE_KEY>'])
s = Steem(keys=get_keys())
m = Market()
spmv = s.get_steem_per_mvest()
steem_per_sbd = str(m.ticker()['latest']).split()[0]
d = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
# td = d - timedelta(days=1) FOR TESTING PURPOSES
users = {}
chart = ''

# Check all @hybridbot transfers and if criteria is met, create a user and update the steem and sbd payout for user.
for h in Account('hybridbot').history(start=d, only_ops=['transfer']):
    if h['to'] != 'hybridbot' and '#' in h['memo']:
        if h['to'] not in users:
            users[h['to']] = User(username=h['to'])
        users[h['to']].update_username(h['to'])
        if 'STEEM' in h['amount']:
            steem = h['amount'].split()
            users[h['to']].update_steem_payout(steem[0])
示例#2
0
from beem.amount import Amount
from datetime import datetime, timedelta
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt

# 200,401,648 STEEM
# 403,671,878,952 VESTS
# 0.0004964   S/V

s = shelve.open("accounts.shelf")
accounts = s['accounts']
s.close()

stm = Steem()
steem_per_mvests = stm.get_steem_per_mvest()
exclude = ['steem', 'steemit']

cur_date = datetime(2018, 11, 23)

intervals = [3, 7, 14, 28, 26 * 7, 52 * 7, 5 * 52 * 7, 100 * 52 * 7]
labels = [
    '<3 days ago', '3-7 days ago', '1-2 weeks ago', '2-4 weeks ago',
    '4-26 weeks ago', '0.5-1 year ago', 'more than\na year ago', 'never'
]
sp_dist = {}
acc_dist = {}

top_idle = []

for i in intervals: