예제 #1
0
        config_int = {}
        config_double = {}
        for pname in config:
            if type(config[pname]) == str:
                config_str[pname] = config[pname]
            elif type(config[pname]) == int:
                config_int[pname] = config[pname]
            elif type(config[pname]) == float:
                config_double[pname] = config[pname]
            else:
                logger.error('unknown config %s, %s', type(config[pname]), config[pname])
        if not 'client_id' in config_int:
            config_int['client_id'] = 1
        config_str['save_file_path'] = '{}/runtime'.format(args.home)
        plugin = registry.get_extension(extension_name)(config_str, config_int, config_double)
        plugin.init()
        plugin.start()
    else:
        logger.error('Unrecognized %s arg %s', extension_type, extension_name)

@arg('-s', '--source', dest='source', type=str, required=True, choices=EXTENSION_REGISTRY_MD.names(), help='data source')
@command(help='market data gateway')
def md(args, logger):
    args.name = 'md_' + args.source
    run_extension(EXTENSION_REGISTRY_MD, args, logger, args.source, 'md')

@arg('-d', '--dest', dest='dest', type=str, required=True, choices=EXTENSION_REGISTRY_TD.names(), help='destination to send order')
@command(help='trade gateway')
def td(args, logger):
    run_extension(EXTENSION_REGISTRY_TD, args, logger, args.dest, 'td')
예제 #2
0
    pass_ctx_from_parent(ctx)
    ctx.name = 'md_' + source
    ctx.source = source
    ctx.low_latency = low_latency
    ctx.logger = create_logger(
        source, ctx.log_level,
        pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.MD, source, source,
                       ctx.locator))
    run_extension(ctx, EXTENSION_REGISTRY_MD)


@kfc.command()
@click.option('-s',
              '--source',
              required=True,
              type=click.Choice(EXTENSION_REGISTRY_TD.names()),
              help='destination to send order')
@click.option('-a', '--account', type=str, help='account')
@click.option('-x',
              '--low_latency',
              is_flag=True,
              help='run in low latency mode')
@click.pass_context
def td(ctx, source, account, low_latency):
    pass_ctx_from_parent(ctx)
    ctx.name = 'td_' + source + '_' + account
    ctx.source = source
    ctx.account = account
    ctx.low_latency = low_latency
    ctx.logger = create_logger(
        source, ctx.log_level,
예제 #3
0
파일: gateway.py 프로젝트: yanqiong/kungfu
    else:
        ctx.logger.error('Unrecognized %s arg %s', registry.ext_type.lower(), ctx.name)


@kfc.command()
@click.option('-s', '--source', required=True, type=click.Choice(EXTENSION_REGISTRY_MD.names()), help='data source')
@click.option('-x', '--low_latency', is_flag=True, help='run in low latency mode')
@click.pass_context
def md(ctx, source, low_latency):
    pass_ctx_from_parent(ctx)
    ctx.name = 'md_' + source
    ctx.source = source
    ctx.low_latency = low_latency
    ctx.logger = create_logger(source, ctx.log_level, pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.MD, source, source, ctx.locator))
    run_extension(ctx, EXTENSION_REGISTRY_MD)


@kfc.command()
@click.option('-s', '--source', required=True, type=click.Choice(EXTENSION_REGISTRY_TD.names()), help='destination to send order')
@click.option('-a', '--account', type=str, help='account')
@click.option('-x', '--low_latency', is_flag=True, help='run in low latency mode')
@click.pass_context
def td(ctx, source, account, low_latency):
    pass_ctx_from_parent(ctx)
    ctx.name = 'td_' + source + '_' + account
    ctx.source = source
    ctx.account = account
    ctx.low_latency = low_latency
    ctx.logger = create_logger(source, ctx.log_level, pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.TD, source, account, ctx.locator))
    run_extension(ctx, EXTENSION_REGISTRY_TD)