code: def runstrat(args=None):
      args = parse_args(args)
  
      cerebro = bt.Cerebro()
      cerebro.broker.set_cash(args.cash)
      cerebro.broker.set_int2pnl(args.no_int2pnl)
  
      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(St)
      cerebro.addsizer(bt.sizers.FixedSize, stake=args.stake)
  
      sigtype = bt.signal.SIGNAL_LONGSHORT
      if args.long:
          sigtype = bt.signal.SIGNAL_LONG
      elif args.short:
          sigtype = bt.signal.SIGNAL_SHORT
  
      cerebro.add_signal(
          sigtype, SMACrossOver, p1=args.period1, p2=args.period2
      )
  
      if args.no_exit:
          if args.long:
              cerebro.add_signal(bt.signal.SIGNAL_LONGEXIT, NoExit)
          elif args.short:
              cerebro.add_signal(bt.signal.SIGNAL_SHORTEXIT, NoExit)
  
      comminfo = bt.CommissionInfo(
          mult=args.mult,
          margin=args.margin,
          stocklike=args.stocklike,
          interest=args.interest,
          interest_long=args.interest_long,
      )
  
      cerebro.broker.addcommissioninfo(comminfo)
  
      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/credit-interest/credit-interest.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