code: def runstrategy():
      args = parse_args()
  
      # Create a cerebro
      cerebro = bt.Cerebro()
  
      storekwargs = dict(
          token=args.token, account=args.account, practice=not args.live
      )
  
      if not args.no_store:
          store = StoreCls(**storekwargs)
  
      if args.broker:
          if args.no_store:
              broker = BrokerCls(**storekwargs)
          else:
              broker = store.getbroker()
  
          cerebro.setbroker(broker)
  
      timeframe = bt.TimeFrame.TFrame(args.timeframe)
      # Manage data1 parameters
      tf1 = args.timeframe1
      tf1 = bt.TimeFrame.TFrame(tf1) if tf1 is not None else timeframe
      cp1 = args.compression1
      cp1 = cp1 if cp1 is not None else args.compression
  
      if args.resample or args.replay:
          datatf = datatf1 = bt.TimeFrame.Ticks
          datacomp = datacomp1 = 1
      else:
          datatf = timeframe
          datacomp = args.compression
          datatf1 = tf1
          datacomp1 = cp1
  
      fromdate = None
      if args.fromdate:
          dtformat = "%Y-%m-%d" + ("T%H:%M:%S" * ("T" in args.fromdate))
          fromdate = datetime.datetime.strptime(args.fromdate, dtformat)
  
      DataFactory = DataCls if args.no_store else store.getdata
  
      datakwargs = dict(
          timeframe=datatf,
          compression=datacomp,
          qcheck=args.qcheck,
          historical=args.historical,
          fromdate=fromdate,
          bidask=args.bidask,
          useask=args.useask,
          backfill_start=not args.no_backfill_start,
          backfill=not args.no_backfill,
          tz=args.timezone,
      )
  
      if args.no_store and not args.broker:  # neither store nor broker
          datakwargs.update(
              storekwargs
          )  # pass the store args over the data
  
      data0 = DataFactory(dataname=args.data0, **datakwargs)
  
      data1 = None
      if args.data1 is not None:
          if args.data1 != args.data0:
              datakwargs["timeframe"] = datatf1
              datakwargs["compression"] = datacomp1
              data1 = DataFactory(dataname=args.data1, **datakwargs)
          else:
              data1 = data0
  
      rekwargs = dict(
          timeframe=timeframe,
          compression=args.compression,
          bar2edge=not args.no_bar2edge,
          adjbartime=not args.no_adjbartime,
          rightedge=not args.no_rightedge,
          takelate=not args.no_takelate,
      )
  
      if args.replay:
          cerebro.replaydata(data0, **rekwargs)
  
          if data1 is not None:
              rekwargs["timeframe"] = tf1
              rekwargs["compression"] = cp1
              cerebro.replaydata(data1, **rekwargs)
  
      elif args.resample:
          cerebro.resampledata(data0, **rekwargs)
  
          if data1 is not None:
              rekwargs["timeframe"] = tf1
              rekwargs["compression"] = cp1
              cerebro.resampledata(data1, **rekwargs)
  
      else:
          cerebro.adddata(data0)
          if data1 is not None:
              cerebro.adddata(data1)
  
      if args.valid is None:
          valid = None
      else:
          valid = datetime.timedelta(seconds=args.valid)
      # Add the strategy
      cerebro.addstrategy(
          TestStrategy,
          smaperiod=args.smaperiod,
          trade=args.trade,
          exectype=bt.Order.ExecType(args.exectype),
          stake=args.stake,
          stopafter=args.stopafter,
          valid=valid,
          cancel=args.cancel,
          donotcounter=args.donotcounter,
          sell=args.sell,
          usebracket=args.usebracket,
      )
  
      # Live data ... avoid long data accumulation by switching to "exactbars"
      cerebro.run(exactbars=args.exactbars)
      if args.exactbars < 1:  # plotting is possible
          if args.plot:
              pkwargs = dict(style="line")
              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/oandatest/oandatest.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import datetime
  import backtrader
  from backtrader.utils import flushfile
label_desc: Use image node_id 1 for calling a global function with example usage: runstrategy() without return types