code: def runstrat(args=None):
      args = parse_args(args)
  
      cerebro = bt.Cerebro()
      cerebro.broker.set_cash(args.cash)
  
      dkwargs = dict()
      if args.fromdate is not None:
          fromdate = datetime.datetime.strptime(
              args.fromdate, "%Y-%m-%d"
          )
          dkwargs["fromdate"] = fromdate
  
      if args.todate is not None:
          todate = datetime.datetime.strptime(args.todate, "%Y-%m-%d")
          dkwargs["todate"] = todate
  
      # if dataset is None, args.data has been given
      data = bt.feeds.BacktraderCSVData(dataname=args.data, **dkwargs)
      cerebro.adddata(data)
  
      cerebro.signal_strategy(SlipSt)
      if not args.longonly:
          stype = bt.signal.SIGNAL_LONGSHORT
      else:
          stype = bt.signal.SIGNAL_LONG
  
      cerebro.add_signal(
          stype, SMACrossOver, p1=args.period1, p2=args.period2
      )
  
      if args.slip_perc is not None:
          cerebro.broker.set_slippage_perc(
              args.slip_perc,
              slip_open=args.slip_open,
              slip_match=not args.no_slip_match,
              slip_out=args.slip_out,
          )
  
      elif args.slip_fixed is not None:
          cerebro.broker.set_slippage_fixed(
              args.slip_fixed,
              slip_open=args.slip_open,
              slip_match=not args.no_slip_match,
              slip_out=args.slip_out,
          )
  
      cerebro.run()
      if args.plot:
          pkwargs = dict(style="bar")
          if args.plot is not True:  # evals to True but is not True
              npkwargs = eval(
                  "dict(" + args.plot + ")"
              )  # args were passed
              pkwargs.update(npkwargs)
  
          cerebro.plot(**pkwargs)
  
file_path: backtrader/samples/slippage/slippage.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import collections
  import datetime
  import itertools
  import backtrader
label_desc: Use image node_id 1 for calling a global function with example usage: runstrat(args) without return types