def do_receipt_list(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() if args.org is not None: org_obj = try_get_then_lookup( state, 'organization', ['organization:ticker', 'organization:pricing-source'], args.org) if org_obj is not None: ListWriter(state, 'receipt', args.full, args.yaml).write('PayeeId', org_obj.get('object-id')) else: raise ClientException("{} does not match an organization".format( args.org)) elif args.bond is not None: bond_obj = try_get_then_lookup(state, 'bond', ['bond:isin', 'bond:cusip'], args.bond) if bond_obj is not None: ListWriter(state, 'receipt', args.full, args.yaml).write('BondId', bond_obj.get('object-id')) else: raise ClientException("{} does not match a bond".format(args.bond)) else: ListWriter(state, 'receipt', args.full, args.yaml).write()
def do_quote_list(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() if args.org is not None: org_obj = try_get_then_lookup( state, 'organization', ['organization:ticker', 'organization:pricing-source'], args.org) if org_obj is not None: ListWriter(state, 'quote', args.full, args.yaml).write('Firm', org_obj.get('pricing-source')) else: raise ClientException("{} does not match an organization".format( args.org)) elif args.user is not None: user_obj = try_get_then_lookup( state, 'participant', ['participant:username', 'participant:key-id'], args.user) if user_obj is not None: ListWriter(state, 'quote', args.full, args.yaml).write('CreatorId', user_obj.get('object-id')) else: raise ClientException("{} does not match a user".format(args.user)) else: ListWriter(state, 'quote', args.full, args.yaml).write()
def do_order_create(args, config): url = config.get('DEFAULT', 'url') key_file = config.get('DEFAULT', 'key_file') username = config.get("DEFAULT", 'username') client = BondClient(base_url=url, keyfile=key_file) args_dict = vars(args) store = client.get_all_store_objects() limit_price = None if args_dict.get('order-type') == 'Limit': if args.limit_price is not None: limit_price = args.limit_price if args.firm_id is None: firm_id = args.firm_id try: firm_id = try_get_then_lookup(store, 'participant', ['participant:username'], username)["firm-id"] print firm_id except KeyError: pass else: firm_id = args.firm_id client.create_order(args.action, args_dict.get('order-type'), firm_id, args.quantity, args.isin, args.cusip, limit_price, object_id=args.object_id) if args.wait: client.wait_for_commit()
def do_holding_show(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() org_obj = try_get_then_lookup(state, 'holding', [], args.identifier) ShowWriter(org_obj, 'holding', args.identifier).write()
def do_bond_show(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() bond_obj = try_get_then_lookup(state, 'bond', ['bond:isin', 'bond:cusip'], args.identifier) ShowWriter(bond_obj, 'bond', args.identifier).write()
def do_settlement_show(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() object_id = vars(args).get('object-id') settlement_obj = try_get_then_lookup(state, 'settlement', ['settlement:order-id'], object_id) ShowWriter(settlement_obj, 'settlement', object_id).write()
def do_user_show(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() user_obj = try_get_then_lookup( state, 'participant', ['participant:username', 'participant:key-id'], args.identifier) ShowWriter(user_obj, 'User', args.identifier).write()
def do_org_show(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() org_obj = try_get_then_lookup( state, 'organization', ['organization:ticker', 'organization:pricing-source'], args.identifier) ShowWriter(org_obj, 'organization', args.identifier).write()
def do_holding_create(args, config): url = config.get('DEFAULT', 'url') key_file = config.get('DEFAULT', 'key_file') client = BondClient(base_url=url, keyfile=key_file) state = client.get_all_store_objects() args_dict = vars(args) org = try_get_then_lookup( state, "organization", ["organization:ticker", "organization:pricing_source"], args.owner) if args_dict.get("asset-type") == "Currency": asset_id = args_dict.get("asset-id") else: asset_id = try_get_then_lookup(state, "bond", ["bond:cusip", "bond:isin"], args_dict.get("asset-id"))["object-id"] client.create_holding(org["object-id"], args_dict.get("asset-type"), asset_id, args.amount, args.object_id) if args.wait: client.wait_for_commit()
def do_holding_list(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() if args.org is not None: org_obj = try_get_then_lookup( state, 'organization', ['organization:ticker', 'organization:pricing-source'], args.org) if org_obj is None: raise ClientException("--org did not specify an organization") ListWriter(state, 'holding', args.full, args.yaml).write('OwnerId', org_obj.get('object-id')) else: ListWriter(state, 'holding', args.full, args.yaml).write()
def do_settlement_list(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() if args.creator is not None: user_obj = try_get_then_lookup( state, 'participant', ['participant:username', 'participant:key-id'], args.creator) if user_obj is not None: ListWriter(state, 'settlement', args.full, args.yaml).write('CreatorId', user_obj.get('object-id')) else: raise ClientException("{} does not match a user".format( args.creator)) else: ListWriter(state, 'settlement', args.full, args.yaml).write()
def do_order_show(args, config): url = config.get("DEFAULT", 'url') client = BondClient(base_url=url, keyfile=None) state = client.get_all_store_objects() order_obj = try_get_then_lookup(state, 'order', [], args.identifier) ShowWriter(order_obj, 'order', args.identifier).write() if order_obj is not None and order_obj.get('status') == 'Settled': settlement_obj = None try: settlement_obj = state.lookup('settlement:order-id', order_obj.get('object-id')) print "Settlement:" print "----------------------------------------------------" except KeyError: pass ShowWriter(settlement_obj, 'settlement', order_obj.get('object-id')).write()