Example #1
0
def run_extension(ctx, registry):
    if registry.has_extension(ctx.source):
        config = DataProxy(make_url(ctx.locator, ctx.system_config_location,
                                    "task"),
                           readonly=True).get_task_config(ctx.name)
        config_str = {}
        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:
                ctx.logger.error('unknown config %s, %s', type(config[pname]),
                                 config[pname])
        if 'client_id' not in config_int:
            config_int['client_id'] = 1
        config_str['save_file_path'] = '{}/runtime'.format(ctx.home)
        gateway = registry.get_extension(ctx.source)(ctx.low_latency,
                                                     ctx.locator, config_str,
                                                     config_int, config_double)
        gateway.run()
    else:
        ctx.logger.error('Unrecognized %s arg %s', registry.ext_type.lower(),
                         ctx.name)
Example #2
0
def task(ctx, gateway_type, source, account, config):
    pass_ctx_from_parent(ctx)
    db = DataProxy(make_url(ctx.locator, ctx.system_config_location, "task"))
    config_name = gateway_type + '_' + source + ('' if gateway_type == 'md'
                                                 else '_' + account)
    if config:
        db.set_task_config(config_name, json.loads(config))
    record = db.get_task_config(config_name)
    click.echo(config_name)
    click.echo(record)
Example #3
0
 def __init__(self, ctx):
     mode = pyyjj.mode.REPLAY if ctx.replay else pyyjj.mode.LIVE
     pywingchun.Watcher.__init__(self, ctx.locator, mode, ctx.low_latency)
     self.ctx = ctx
     self.ctx.logger = create_logger("watcher", ctx.log_level,
                                     self.io_device.home)
     location = pyyjj.location(mode, pyyjj.category.SYSTEM, 'watcher',
                               'watcher', ctx.locator)
     url = make_url(ctx.locator, location, ctx.name)
     self.data_proxy = DataProxy(url)
     self.accounts = {}
Example #4
0
 def __init__(self, ctx):
     self.holidays = DataProxy(
         make_url(ctx.locator, ctx.system_config_location,
                  "holidays")).get_holidays()
     self.update_trading_day(datetime.datetime.now())