-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathget_balance.py
More file actions
executable file
·36 lines (24 loc) · 841 Bytes
/
get_balance.py
File metadata and controls
executable file
·36 lines (24 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
from collections import Counter
from typing import Counter as TCounter
import click
from bitshares.account import Account
from bitsharesscripts.decorators import chain, common_options
@click.command()
@common_options
@chain
@click.argument('account')
@click.pass_context
def main(ctx, account):
"""Show account balances (avail + orders balance)"""
sum_balances: TCounter[str] = Counter()
account = Account(account, bitshares_instance=ctx.bitshares)
for i in account.balances:
sum_balances[i['symbol']] += i['amount']
for order in account.openorders:
asset = order['for_sale']['symbol']
sum_balances[asset] += order['for_sale']['amount']
for key in sum_balances:
print('{}: {:.8f}'.format(key, sum_balances[key]))
if __name__ == '__main__':
main()