code: def test_run(main=False):
      global _chkvalues
      global _chkcash
  
      for runonce in [True, False]:
          for preload in [True, False]:
              for exbar in [True, False, -1, -2]:
                  _chkvalues = list()
                  _chkcash = list()
  
                  datas = [
                      testcommon.getdata(i) for i in range(chkdatas)
                  ]
                  testcommon.runtest(
                      datas,
                      TestStrategy,
                      runonce=runonce,
                      preload=preload,
                      exbar=exbar,
                      optimize=True,
                      period=range(5, 45),
                      printdata=main,
                      printops=main,
                      plot=False,
                  )
  
                  if not main:
                      assert CHKVALUES == _chkvalues
                      assert CHKCASH == _chkcash
  
                  else:
                      print("*" * 50)
                      print(CHKVALUES == _chkvalues)
                      print("-" * 50)
                      print(CHKVALUES)
                      print("-" * 50)
                      print(_chkvalues)
                      print("*" * 50)
                      print(CHKCASH == _chkcash)
                      print("-" * 50)
                      print(CHKCASH)
                      print("-" * 50)
                      print(_chkcash)
  
file_path: backtrader/tests/test_strategy_optimized.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import itertools
  import time
  import testcommon
  from backtrader.utils.py3 import range
  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