code: def parse_args(pargs=None):
      parser = argparse.ArgumentParser(
          formatter_class=argparse.ArgumentDefaultsHelpFormatter,
          description="Sample for Tharp example with MACD",
      )
  
      group1 = parser.add_mutually_exclusive_group(required=True)
      group1.add_argument(
          "--data",
          required=False,
          default=None,
          help="Specific data to be read in",
      )
  
      group1.add_argument(
          "--dataset",
          required=False,
          action="store",
          default=None,
          choices=DATASETS.keys(),
          help="Choose one of the predefined data sets",
      )
  
      parser.add_argument(
          "--fromdate",
          required=False,
          default="2005-01-01",
          help="Starting date in YYYY-MM-DD format",
      )
  
      parser.add_argument(
          "--todate",
          required=False,
          default=None,
          help="Ending date in YYYY-MM-DD format",
      )
  
      parser.add_argument(
          "--cash",
          required=False,
          action="store",
          type=float,
          default=50000,
          help=("Cash to start with"),
      )
  
      parser.add_argument(
          "--cashalloc",
          required=False,
          action="store",
          type=float,
          default=0.20,
          help=("Perc (abs) of cash to allocate for ops"),
      )
  
      parser.add_argument(
          "--commperc",
          required=False,
          action="store",
          type=float,
          default=0.0033,
          help=(
              "Perc (abs) commision in each operation. "
              "0.001 -> 0.1%%, 0.01 -> 1%%"
          ),
      )
  
      parser.add_argument(
          "--macd1",
          required=False,
          action="store",
          type=int,
          default=12,
          help=("MACD Period 1 value"),
      )
  
      parser.add_argument(
          "--macd2",
          required=False,
          action="store",
          type=int,
          default=26,
          help=("MACD Period 2 value"),
      )
  
      parser.add_argument(
          "--macdsig",
          required=False,
          action="store",
          type=int,
          default=9,
          help=("MACD Signal Period value"),
      )
  
      parser.add_argument(
          "--atrperiod",
          required=False,
          action="store",
          type=int,
          default=14,
          help=("ATR Period To Consider"),
      )
  
      parser.add_argument(
          "--atrdist",
          required=False,
          action="store",
          type=float,
          default=3.0,
          help=("ATR Factor for stop price calculation"),
      )
  
      parser.add_argument(
          "--smaperiod",
          required=False,
          action="store",
          type=int,
          default=30,
          help=("Period for the moving average"),
      )
  
      parser.add_argument(
          "--dirperiod",
          required=False,
          action="store",
          type=int,
          default=10,
          help=("Period for SMA direction calculation"),
      )
  
      parser.add_argument(
          "--riskfreerate",
          required=False,
          action="store",
          type=float,
          default=0.01,
          help=(
              "Risk free rate in Perc (abs) of the asset for "
              "the Sharpe Ratio"
          ),
      )
      # Plot options
      parser.add_argument(
          "--plot",
          "-p",
          nargs="?",
          required=False,
          metavar="kwargs",
          const=True,
          help=(
              "Plot the read data applying any kwargs passed\n"
              "\n"
              "For example:\n"
              "\n"
              '  --plot style="candle" (to plot candles)\n'
          ),
      )
  
      if pargs is not None:
          return parser.parse_args(pargs)
  
      return parser.parse_args()
  
file_path: backtrader/samples/macd-settings/macd-settings.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import argparse
  import datetime
  import random
  import backtrader
label_desc: Use image node_id 2 for calling a global function with example usage: parse_args(pargs) and returns: parser, parser