For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

problems when using cerebro.optstrategy



  • I am new to backtrader. I tried to use the the optimizer and changed the code from:
    cerebro.addstrategy(MyStrategy)
    To
    cerebro.addstrategy(MyStrategy)
    cerebro.optstrategy(
    MyStrategy,
    maperiod=range(10, 11))

    But after changing the code, it stuck at the step cerebro.run() after running the code. In the cmd windows, there are some print as below. I appricate it very much if someone could solve my issue.

    Starting Portfolio Value: 10000.00
    Starting Portfolio Value: 10000.00
    Starting Portfolio Value: 10000.00
    Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Python27\lib\multiprocessing\forking.py", line 380, in main
    prepare(preparation_data)
    File "C:\Python27\lib\multiprocessing\forking.py", line 510, in prepare
    'parents_main', file, path_name, etc
    File "C:\Python27\Scripts\tu_back_trader\New_opt.py", line 103, in <module>
    cerebro.run()
    File "build\bdist.win32\egg\backtrader\cerebro.py", line 1142, in run
    File "C:\Python27\lib\multiprocessing_init_.py", line 232, in Pool
    return Pool(processes, initializer, initargs, maxtasksperchild)
    File "C:\Python27\lib\multiprocessing\pool.py", line 161, in init
    self._repopulate_pool()
    File "C:\Python27\lib\multiprocessing\pool.py", line 225, in _repopulate_pool
    w.start()
    File "C:\Python27\lib\multiprocessing\process.py", line 130, in start
    self._popen = Popen(self)


  • administrators

    By the looks of it ... it could a problem with your Python installation. The error is deep in the stack.

    It could of course have to do with your code snippet, but the sample you post is too small to conclude anything.