def calls(ctx, obj): """ List call/short positions of an account or an asset """ if obj.upper() == obj: # Asset from bitshares.asset import Asset asset = Asset(obj, full=True) calls = asset.get_call_orders(10) t = PrettyTable( ["acount", "debt", "collateral", "call price", "ratio"]) t.align = 'r' for call in calls: t.add_row([ str(call["account"]["name"]), str(call["debt"]), str(call["collateral"]), str(call["call_price"]), "%.2f" % (call["ratio"]) ]) click.echo(str(t)) else: # Account from bitshares.dex import Dex dex = Dex(bitshares_instance=ctx.bitshares) calls = dex.list_debt_positions(account=obj) t = PrettyTable(["debt", "collateral", "call price", "ratio"]) t.align = 'r' for symbol in calls: t.add_row([ str(calls[symbol]["debt"]), str(calls[symbol]["collateral"]), str(calls[symbol]["call_price"]), "%.2f" % (calls[symbol]["ratio"]) ]) click.echo(str(t))
def calls(ctx, account): """ List call/short positions of an account """ from bitshares.dex import Dex dex = Dex(bitshares_instance=ctx.bitshares) t = PrettyTable(["debt", "collateral", "call price", "ratio"]) t.align = 'r' calls = dex.list_debt_positions(account=account) for symbol in calls: t.add_row([ str(calls[symbol]["debt"]), str(calls[symbol]["collateral"]), str(calls[symbol]["call_price"]), "%.2f" % (calls[symbol]["ratio"]) ]) click.echo(str(t))
def calls(ctx, obj, limit): """ List call/short positions of an account or an asset """ if obj.upper() == obj: # Asset from bitshares.asset import Asset asset = Asset(obj, full=True) calls = asset.get_call_orders(limit) t = [["acount", "debt", "collateral", "call price", "ratio"]] for call in calls: t.append( [ str(call["account"]["name"]), str(call["debt"]), str(call["collateral"]), str(call["call_price"]), "%.2f" % (call["ratio"]), ] ) print_table(t) else: # Account from bitshares.dex import Dex dex = Dex(bitshares_instance=ctx.bitshares) calls = dex.list_debt_positions(account=obj) t = [["debt", "collateral", "call price", "ratio"]] for symbol in calls: t.append( [ str(calls[symbol]["debt"]), str(calls[symbol]["collateral"]), str(calls[symbol]["call_price"]), "%.2f" % (calls[symbol]["ratio"]), ] ) print_table(t)