class Testcases(unittest.TestCase): def __init__(self, *args, **kwargs): super(Testcases, self).__init__(*args, **kwargs) self.account = Account(testaccount) def test_readAccount(self): self.assertEqual(self.account["id"], 1489) def test_getbalance(self): self.account.get_balances()
def main(): parser = argparse.ArgumentParser( description='show user balances', epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues' ) parser.add_argument('account', help='account name') parser.add_argument('-c', '--config', default='./common.yml', help='specify custom path for config file') args = parser.parse_args() # parse config with open(args.config, 'r') as ymlfile: conf = yaml.load(ymlfile) golos = Steem(nodes=conf['nodes_new'], no_broadcast=True) a = Account(args.account, steemd_instance=golos) b = a.get_balances() pprint(b) vests = b['total']['GESTS'] cv = Converter(golos) pprint('GP: {}'.format(cv.vests_to_sp(vests)))
def main(): parser = argparse.ArgumentParser( description='show multiple users balances', epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues' ) parser.add_argument('-c', '--config', default='./common.yml', help='specify custom path for config file') parser.add_argument('--no-header', action='store_true', help='supress header') parser.add_argument('--no-sum', action='store_true', help='supress summary output') parser.add_argument('-d', '--debug', action='store_true', help='enable debug output'), args = parser.parse_args() # create logger if args.debug == True: log.setLevel(logging.DEBUG) else: log.setLevel(logging.INFO) handler = logging.StreamHandler() formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s") handler.setFormatter(formatter) log.addHandler(handler) # parse config with open(args.config, 'r') as ymlfile: conf = yaml.load(ymlfile) golos = Steem(nodes=conf['nodes_new'], no_broadcast=True) if not args.no_header: print('{:<20} {:>10} {:>11} {:>11}'.format('Account', 'GBG', 'GOLOS', 'GP')) print('--------------------') sum_gbg = float() sum_golos = float() sum_gp = float() for acc in conf['accs']: a = Account(acc, steemd_instance=golos) b = a.get_balances() vests = b['total']['GESTS'] cv = Converter(golos) gp = cv.vests_to_sp(vests) print('{:<20} {:>10} {:>10} {:>10.0f}'.format( acc, b['total']['GBG'], b['total']['GOLOS'], gp)) sum_gbg += b['total']['GBG'] sum_golos += b['total']['GOLOS'] sum_gp += gp if not args.no_sum: print('--------------------') print('{:<20} {:>10.3f} {:>10.3f} {:>10.0f}'.format( 'Totals:', sum_gbg, sum_golos, sum_gp))
sbd = float(get_market_price('steem-dollars')) print("Steem/USD: {:.2f}\nSBD/USD: {:.2f}\n".format(steem, sbd)) username = sys.argv[1] stats = {} nodes = ['https://rpc.buildteam.io', 'https://api.steemit.com'] s = Steem(nodes) data = s.get_dynamic_global_properties() total_vesting_shares = Amount(data["total_vesting_shares"]).amount total_vesting_fund_steem = Amount(data["total_vesting_fund_steem"]).amount ratio = total_vesting_fund_steem / total_vesting_shares account = Account(str(username), s) for key, value in account.get_balances()['total'].items(): if key not in stats: stats[key] = value liquid_steem = stats['STEEM'] liquid_sbd = stats['SBD'] vested_steem = stats['VESTS'] * ratio print("Steem: {:.3f}".format(liquid_steem)) print("SBD: {:.3f}".format(liquid_sbd)) print("Steem Power: {:.3f}".format(vested_steem)) print() print("Dollar value: {:.2f}".format(liquid_steem * steem + liquid_sbd * sbd + vested_steem * steem))