Ejemplo n.º 1
0
import pyyjj
import codecs
import click
from kungfu.command import kfc, pass_ctx_from_parent as pass_ctx_from_root
from extensions import EXTENSION_REGISTRY_MD, EXTENSION_REGISTRY_TD, ACCOUNT_SCHEMA
from kungfu.data.sqlite.data_proxy import AccountsDB


@kfc.group(help_priority=2)
@click.option('-s',
              '--source',
              required=True,
              type=click.Choice(EXTENSION_REGISTRY_MD.names()),
              help='account source')
@click.pass_context
def account(ctx, source):
    pass_ctx_from_root(ctx)
    ctx.source = source
    ctx.location = pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM,
                                  'etc', 'kungfu', ctx.locator)
    ctx.db = AccountsDB(ctx.location, 'accounts')
    ctx.schema = ACCOUNT_SCHEMA[source]


def pass_ctx_from_parent(ctx):
    pass_ctx_from_root(ctx)
    ctx.source = ctx.parent.source
    ctx.location = ctx.parent.location
    ctx.db = ctx.parent.db
    ctx.schema = ctx.parent.schema
Ejemplo n.º 2
0
def md(ctx, source, 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_md_account_config(source)
    ext = EXTENSION_REGISTRY_MD.get_extension(source)(low_latency, ctx.locator, account_config)
    ext.run()
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
import pyyjj
import click
from kungfu.command import kfc, pass_ctx_from_parent
from extensions import EXTENSION_REGISTRY_MD
from kungfu.data.sqlite.data_proxy import AccountsDB


@kfc.command(help_priority=3)
@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.db = AccountsDB(pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM, 'etc', 'kungfu', ctx.locator), 'accounts')
    account_config = ctx.db.get_md_account_config(source)
    ext = EXTENSION_REGISTRY_MD.get_extension(source)(low_latency, ctx.locator, account_config)
    ext.run()

Ejemplo n.º 5
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)
Ejemplo n.º 6
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')
Ejemplo 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)
Ejemplo 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)