text: import pyyjj
  import click
  import sys
  from tabulate import tabulate
  
  from kungfu.command.backtest import backtest, pass_ctx_from_parent
  
  from kungfu.wingchun import Runner
  #from kungfu.wingchun.oms.order import *
  from kungfu.wingchun.strategy import Strategy
  from kungfu.yijinjing.log import create_logger
  import kungfu.yijinjing.time as kft
  import kungfu.yijinjing.journal as kfj
  
  
  @backtest.command()
  @click.option('-p', '--path', type=str, required=True, help='path of strategy py file path')
  @click.option('-i', '--session_id', type=int, help='replay session id, MUST be specified if replay is set')
  @click.pass_context
  def run(ctx, path, session_id):
      pass_ctx_from_parent(ctx)
      ctx.path = path
      ctx.low_latency = False
      ctx.logger = create_logger(ctx.name, ctx.log_level, 
                                 pyyjj.location(pyyjj.mode.BACKTEST, pyyjj.category.STRATEGY, ctx.group, ctx.name, ctx.locator))
      ctx.strategy = Strategy(ctx)
      runner = Runner(ctx, pyyjj.mode.BACKTEST)
      runner.add_strategy(ctx.strategy)
      ctx.session_id = session_id
      setup(ctx, session_id, run, runner)
      runner.run()
  
  def setup(ctx, session_id, cmd, instance):
      ctx.journal_util_location = pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM, 'util', 'journal', ctx.locator)
      if not session_id:
          all_sessions = kfj.find_sessions(ctx)
          all_sessions['begin_time'] = all_sessions['begin_time'].apply(lambda t: kft.strftime(t, kft.SESSION_DATETIME_FORMAT))
          all_sessions['end_time'] = all_sessions['end_time'].apply(lambda t: kft.strftime(t, kft.SESSION_DATETIME_FORMAT))
          all_sessions['duration'] = all_sessions['duration'].apply(lambda t: kft.strftime(t - kft.DURATION_TZ_ADJUST, kft.DURATION_FORMAT))
          click.echo(cmd.get_help(ctx))
          click.echo('please select sessions:')
          click.echo(tabulate(all_sessions.values, headers=all_sessions.columns, tablefmt='simple'))
          sys.exit(-1)
      else:
          session = kfj.find_session(ctx, session_id)
          instance.set_begin_time(session['begin_time'])
          instance.set_end_time(session['end_time'])
          
  # yarn dev -l trace backtest -g tushare -n 20190808 run -p ../examples/strategy/py/strategy_demo.py -i 1