Exemplo n.º 1
0
def td(ctx, source, account, low_latency):
    pass_ctx_from_parent(ctx)
    ctx.db = AccountsDB(
        pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM, 'etc', 'kungfu',
                       ctx.locator), 'accounts')
    account_config = ctx.db.get_td_account_config(source, account)
    ext = EXTENSION_REGISTRY_TD.get_extension(source)(low_latency, ctx.locator,
                                                      account, account_config)
    ext.run()
Exemplo n.º 2
0
from .marketdata_sim import MarketDataSim
from .trader_sim import TraderSim
from extensions import EXTENSION_REGISTRY_MD, EXTENSION_REGISTRY_TD
EXTENSION_REGISTRY_MD.register_extension('sim', MarketDataSim)
EXTENSION_REGISTRY_TD.register_extension('sim', TraderSim)
Exemplo n.º 3
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,
Exemplo n.º 4
0
from . import ${PROJECT_NAME} as ext
from extensions import EXTENSION_REGISTRY_MD, EXTENSION_REGISTRY_TD
EXTENSION_REGISTRY_MD.register_extension('tora', ext.MD)
EXTENSION_REGISTRY_TD.register_extension('tora', ext.TD)
Exemplo n.º 5
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')
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
from . import ${PROJECT_NAME} as ext
from extensions import EXTENSION_REGISTRY_MD, EXTENSION_REGISTRY_TD
EXTENSION_REGISTRY_MD.register_extension('kfextdemo', ext.MD)
EXTENSION_REGISTRY_TD.register_extension('kfextdemo', ext.TD)
Exemplo n.º 8
0
from . import ${PROJECT_NAME} as ext
from extensions import EXTENSION_REGISTRY_MD, EXTENSION_REGISTRY_TD
EXTENSION_REGISTRY_MD.register_extension('passive', ext.MD)
EXTENSION_REGISTRY_TD.register_extension('passive', ext.TD)