code: def runstrat(args=None):
      args = parse_args(args)
  
      cerebro = bt.Cerebro()
  
      # Data feed kwargs
      kwargs = dict()
  
      # Parse from/to-date
      dtfmt, tmfmt = "%Y-%m-%d", "T%H:%M:%S"
      for a, d in (
          (getattr(args, x), x) for x in ["fromdate", "todate"]
      ):
          if a:
              strpfmt = dtfmt + tmfmt * ("T" in a)
              kwargs[d] = datetime.datetime.strptime(a, strpfmt)
  
      data0 = bt.feeds.BacktraderCSVData(dataname=args.data0, **kwargs)
      cerebro.adddata(data0)
  
      # Broker
      cerebro.broker = bt.brokers.BackBroker(
          **eval("dict(" + args.broker + ")")
      )
  
      # Sizer
      cerebro.addsizer(
          bt.sizers.FixedSize, **eval("dict(" + args.sizer + ")")
      )
  
      # Strategy
      if not args.order_history:
          cerebro.addstrategy(
              SmaCross, **eval("dict(" + args.strat + ")")
          )
      else:
          cerebro.addstrategy(St, **eval("dict(" + args.strat + ")"))
          cerebro.add_order_history(ORDER_HISTORY, notify=True)
  
      cerebro.addanalyzer(
          bt.analyzers.TimeReturn, timeframe=bt.TimeFrame.Months
      )
      cerebro.addanalyzer(
          bt.analyzers.TimeReturn, timeframe=bt.TimeFrame.Years
      )
      cerebro.addanalyzer(bt.analyzers.TradeAnalyzer)
  
      # Execute
      cerebro.run(**eval("dict(" + args.cerebro + ")"))
  
      if args.plot:  # Plot if requested to
          cerebro.plot(**eval("dict(" + args.plot + ")"))
  
file_path: backtrader/samples/order-history/order-history.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import datetime
  import backtrader
label_desc: Use image node_id 1 for calling a global function with example usage: runstrat(args) without return types