code: def runstrategy():
      args = parse_args()
  
      # Create a cerebro
      cerebro = bt.Cerebro()
  
      # Get the dates from the args
      fromdate = datetime.datetime.strptime(args.fromdate, "%Y-%m-%d")
      todate = datetime.datetime.strptime(args.todate, "%Y-%m-%d")
  
      # Create the 1st data
      data = btfeeds.BacktraderCSVData(
          dataname=args.data, fromdate=fromdate, todate=todate
      )
  
      # Add the 1st data to cerebro
      cerebro.adddata(data)
  
      # Add the strategy
      cerebro.addstrategy(
          LongShortStrategy,
          period=args.period,
          onlylong=args.onlylong,
          csvcross=args.csvcross,
          stake=args.stake,
      )
  
      # Add the commission - only stocks like a for each operation
      cerebro.broker.setcash(args.cash)
  
      # Add the commission - only stocks like a for each operation
      cerebro.broker.setcommission(
          commission=args.comm, mult=args.mult, margin=args.margin
      )
  
      tframes = dict(
          days=bt.TimeFrame.Days,
          weeks=bt.TimeFrame.Weeks,
          months=bt.TimeFrame.Months,
          years=bt.TimeFrame.Years,
      )
  
      # Add the Analyzers
      cerebro.addanalyzer(SQN)
      if args.legacyannual:
          cerebro.addanalyzer(AnnualReturn)
          cerebro.addanalyzer(SharpeRatio, legacyannual=True)
      else:
          cerebro.addanalyzer(
              TimeReturn, timeframe=tframes[args.tframe]
          )
          cerebro.addanalyzer(
              SharpeRatio, timeframe=tframes[args.tframe]
          )
  
      cerebro.addanalyzer(TradeAnalyzer)
  
      cerebro.addwriter(bt.WriterFile, csv=args.writercsv, rounding=4)
  
      # And run it
      cerebro.run()
  
      # Plot if requested
      if args.plot:
          cerebro.plot(numfigs=args.numfigs, volume=False, zdown=False)
  
file_path: backtrader/samples/analyzer-annualreturn/analyzer-annualreturn.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import datetime
  import backtrader
  import backtrader.feeds
  import backtrader.indicators
  from backtrader.analyzers import SQN, AnnualReturn, TimeReturn, SharpeRatio, TradeAnalyzer
label_desc: Use image node_id 1 for calling a global function with example usage: runstrategy() without return types