code: def test_run(main=False):
      datas = [testcommon.getdata(i) for i in range(chkdatas)]
  
      for maxtrades in [None, 0, 1]:
          cerebros = testcommon.runtest(
              datas,
              TestStrategy,
              printdata=main,
              stocklike=False,
              maxtrades=maxtrades,
              printops=main,
              plot=main,
              analyzer=(bt.analyzers.SQN, {}),
          )
  
          for cerebro in cerebros:
              strat = cerebro.runstrats[0][0]  # no optimization, only 1
              analyzer = strat.analyzers[0]  # only 1
              analysis = analyzer.get_analysis()
              if main:
                  print(analysis)
                  print(str(analysis.sqn))
              else:
                  if maxtrades == 0 or maxtrades == 1:
                      assert analysis.sqn == 0
                      assert analysis.trades == maxtrades
                  else:
                      # Handle different precision
                      assert str(analysis.sqn)[0:14] == "0.912550316439"
                      assert str(analysis.trades) == "11"
  
file_path: backtrader/tests/test_analyzer-sqn.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import time
  import testcommon
  import backtrader
  import backtrader.indicators
label_desc: Use image node_id 1 for calling a global function with example usage: test_run(main) without return types