def main(): parser = argparse.ArgumentParser( description='v1.0 Copyright (C) 2020 Spire Trading Inc.') parser.add_argument('-c', '--config', type=str, help='Configuration file.', default='config.yml') parser.add_argument('-r', '--region', type=str, help='The region to reset.') args = parser.parse_args() try: stream = open(args.config, 'r').read() config = yaml.load(stream, yaml.SafeLoader) except IOError: sys.stderr.write('%s not found\n' % args.config) exit(1) except yaml.YAMLError as e: report_yaml_error(e) exit(1) section = config['service_locator'] address = parse_ip_address(section['address']) username = section['username'] password = section['password'] service_clients = nexus.ApplicationServiceClients(username, password, address) countries = service_clients.get_definitions_client().load_country_database() markets = service_clients.get_definitions_client().load_market_database() region = nexus.parse_country_code(args.region, countries) if region == nexus.CountryCode.NONE: region = nexus.parse_market_code(args.region, markets) if region != '': region = markets.from_code(region) else: region = nexus.parse_security(args.region, markets) service_clients.get_risk_client().reset(nexus.Region(region))
def parse_region(service_clients, region): if region == '*': return nexus.Region.GLOBAL market_database = \ service_clients.get_definitions_client().load_market_database() countries = service_clients.get_definitions_client().load_country_database( ) region = nexus.parse_country_code(region, countries) if region == nexus.CountryCode.NONE: region = nexus.parse_market_code(region, market_database) if region != '': region = market_database.from_code(region) else: region = nexus.parse_security(region, market_database) return nexus.Region(region)
def main(): parser = argparse.ArgumentParser( description='v1.0 Copyright (C) 2020 Spire Trading Inc.') parser.add_argument('-c', '--config', type=str, help='Configuration file', default='config.yml') parser.add_argument('-s', '--start', type=parse_date, help='Start range', required=True) parser.add_argument('-e', '--end', type=parse_date, help='End range', required=True) parser.add_argument('-m', '--market', type=str, help='Market') parser.add_argument('-t', '--symbol', type=str, help='Ticker symbol') parser.add_argument('-a', '--account', type=str, help='Account') args = parser.parse_args() try: stream = open(args.config, 'r').read() config = yaml.load(stream, yaml.SafeLoader) except IOError: sys.stderr.write('%s not found\n' % args.config) exit(1) except yaml.YAMLError as e: report_yaml_error(e) exit(1) address = parse_ip_address(config['service_locator']) username = config['username'] password = config['password'] start_date = beam.time_service.to_utc_time(args.start) end_date = beam.time_service.to_utc_time(args.end) service_locator_client = beam.service_locator.ApplicationServiceLocatorClient( username, password, address) definitions_client = nexus.definitions_service.ApplicationDefinitionsClient( service_locator_client) order_execution_client = \ nexus.order_execution_service.ApplicationOrderExecutionClient( service_locator_client) market_database = definitions_client.load_market_database() time_zone_database = definitions_client.load_time_zone_database() if args.market is not None: market = nexus.parse_market_code(args.market, market_database) else: market = None if args.symbol is not None: security = nexus.parse_security(args.symbol, market_database) else: security = None if args.account is not None: account = service_locator_client.find_account(args.account) else: account = None (orders, activity_log) = execute_report(start_date, end_date, security, market, account, market_database, time_zone_database, service_locator_client, order_execution_client) output_order_log(orders) output_activity_log(activity_log)