-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_asset.py
executable file
·40 lines (29 loc) · 1.18 KB
/
get_asset.py
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
37
38
39
40
#!/usr/bin/env python
from pprint import pprint
import click
from bitshares.asset import Asset
from bitsharesscripts.decorators import chain, common_options
from bitsharesscripts.functions import raw_to_decimal
@click.command()
@common_options
@chain
@click.option('--raw', is_flag=True, default=False, help='show raw asset data')
@click.argument('asset')
@click.pass_context
def main(ctx, raw, asset):
"""Get asset info."""
asset = Asset(asset, full=True, bitshares_instance=ctx.bitshares)
if raw:
pprint(dict(asset))
return
print('id: {}'.format(asset['id']))
supply = raw_to_decimal(asset['dynamic_asset_data']['current_supply'], asset['precision'])
print('supply: {} {}'.format(supply, asset['symbol']))
if asset.is_bitasset:
feed = asset.feed
print('MCR: {}'.format(feed['maintenance_collateral_ratio']))
print('MSSR: {}'.format(feed['maximum_short_squeeze_ratio']))
print('Settlement: {} or {}'.format(feed['settlement_price'], feed['settlement_price'].copy().invert()))
print('CER: {} or {}'.format(feed['core_exchange_rate'], feed['core_exchange_rate'].copy().invert()))
if __name__ == '__main__':
main()