def main2(**kwargs): output = kwargs['output'] mysqldest = kwargs['mysqldest'] mysql = kwargs['mysql'] mysqlschema = kwargs['mysqlschema'] instmts = kwargs['instmts'] exchtime = kwargs['exchtime'] Logger.init_log(output) db_clients = [] is_database_defined = False if mysql: db_client = MysqlClient() logon_credential = mysqldest.split('@')[0] connection = mysqldest.split('@')[1] db_client.connect(host=connection.split(':')[0], port=int(connection.split(':')[1]), user=logon_credential.split(':')[0], pwd=logon_credential.split(':')[1], schema=mysqlschema) db_clients.append(db_client) is_database_defined = True if not is_database_defined: print('Error: Please define which database is used.') sys.exit(1) # Subscription instruments if instmts is None or len(instmts) == 0: print( 'Error: Please define the instrument subscription list. You can refer to subscriptions.ini.' ) sys.exit(1) # Use exchange timestamp rather than local timestamp if exchtime: ExchangeGateway.is_local_timestamp = False # Initialize subscriptions subscription_instmts = SubscriptionManager(instmts).get_subscriptions() if len(subscription_instmts) == 0: print( 'Error: No instrument is found in the subscription file. ' + 'Please check the file path and the content of the subscription file.' ) sys.exit(1) # Initialize snapshot destination ExchangeGateway.init_snapshot_table(db_clients) Logger.info('[main]', 'Subscription file = %s' % instmts) log_str = 'Exchange/Instrument/InstrumentCode:\n' for instmt in subscription_instmts: log_str += '%s/%s/%s\n' % (instmt.exchange_name, instmt.instmt_name, instmt.instmt_code) Logger.info('[main]', log_str) exch_gws = [] exch_gws.append(ExchGwBitfinex(db_clients)) threads = [] for exch in exch_gws: for instmt in subscription_instmts: if instmt.get_exchange_name() == exch.get_exchange_name(): Logger.info("[main]", "Starting instrument %s-%s..." % \ (instmt.get_exchange_name(), instmt.get_instmt_name())) threads += exch.start(instmt)
) parser.print_help() sys.exit(1) # Data mode if args.mode is not None: ExchangeGateway.data_mode = ExchangeGateway.DataMode.fromstring( args.mode) # Use exchange timestamp rather than local timestamp if args.exchtime: ExchangeGateway.is_local_timestamp = False subscription_instmts = SubscriptionManager( args.instmts).get_subscriptions() ExchangeGateway.init_snapshot_table(ExchangeGateway.data_mode, db_client) Logger.info('[main]', 'Current mode = %s' % args.mode) Logger.info('[main]', 'Subscription file = %s' % args.instmts) exch_gws = [] exch_gws.append(ExchGwBtccSpot(db_client)) exch_gws.append(ExchGwBtccFuture(db_client)) exch_gws.append(ExchGwBitmex(db_client)) exch_gws.append(ExchGwBitfinex(db_client)) exch_gws.append(ExchGwOkCoin(db_client)) exch_gws.append(ExchGwKraken(db_client)) exch_gws.append(ExchGwHuobi(db_client)) exch_gws.append(ExchGwGdax(db_client)) exch_gws.append(ExchGwBitstamp(db_client)) exch_gws.append(ExchGwGatecoin(db_client))