def strategy(ctx, group, name): pass_ctx_from_root(ctx) ctx.group = group ctx.name = name ctx.category = 'strategy' ctx.mode = "live" ctx.low_latency = False ctx.logger = create_logger( ctx.name, ctx.log_level, pyyjj.location(pyyjj.get_mode_by_name(ctx.mode), pyyjj.category.STRATEGY, ctx.group, ctx.name, ctx.locator)) ctx.path = None ctx.runner = Runner(ctx, pyyjj.get_mode_by_name(ctx.mode)) def init_strategy_patch(self, path): pass with patch.object(Strategy, '_Strategy__init_strategy', init_strategy_patch): ctx.strategy = Strategy(ctx) ctx.strategy._pre_start = lambda ctx: None ctx.strategy._post_start = lambda ctx: None ctx.strategy._pre_stop = lambda ctx: None ctx.strategy._post_stop = lambda ctx: None ctx.strategy._on_trading_day = lambda ctx, daytime: None ctx.strategy._on_entrust = lambda ctx, entrust: None ctx.strategy._on_transaction = lambda ctx, transaction: None ctx.strategy._on_quote = lambda ctx, quote: ctx.logger.info( "quote received: {}".format(quote)) ctx.strategy._on_order = lambda ctx, order: ctx.logger.info( "order received: {}".format(order)) ctx.strategy._on_trade = lambda ctx, trade: ctx.logger.info( "trade received: {}".format(trade))
def pass_ctx_from_parent(ctx): pass_ctx_from_root(ctx) ctx.group = ctx.parent.group ctx.name = ctx.parent.name ctx.category = ctx.parent.category ctx.mode = ctx.parent.mode ctx.low_latency = ctx.parent.low_latency ctx.logger = ctx.parent.logger ctx.strategy = ctx.parent.strategy ctx.runner = ctx.parent.runner
def strategy(ctx, group, name): pass_ctx_from_root(ctx) ctx.group = group ctx.name = name ctx.category = 'strategy' ctx.mode = "live" ctx.low_latency = False ctx.logger = create_logger( ctx.name, ctx.log_level, pyyjj.location(pyyjj.get_mode_by_name(ctx.mode), pyyjj.category.STRATEGY, ctx.group, ctx.name, ctx.locator)) ctx.path = None ctx.runner = Runner(ctx, pyyjj.get_mode_by_name(ctx.mode)) def init_strategy_patch(self, path): pass with patch.object(Strategy, '_Strategy__init_strategy', init_strategy_patch): ctx.strategy = Strategy(ctx)
def units(ctx): pass_ctx_from_root(ctx) loader = unittest.TestLoader() suite = loader.discover('.') runner = unittest.TextTestRunner() runner.run(suite)
def pass_ctx_from_parent(ctx): pass_ctx_from_root(ctx) ctx.category = ctx.parent.category ctx.group = ctx.parent.group ctx.name = ctx.parent.name ctx.ledger_client = ctx.parent.ledger_client
def ledger(ctx, category, group, name): pass_ctx_from_root(ctx) ctx.category = category ctx.group = group ctx.name = name ctx.ledger_client = LedgerClient(ctx.locator)