Python Backtrader Optstrategy results in BrokenPipeError: [Errno 32] Broken pipe

34 views Asked by At

I'm attempting to use the optstrategy functionality to optimize my algorithm using an Orange Pi 5 Plus running Ubuntu OS.

My script functions properly when run with only a few variations such as below

strats = cerebro.optstrategy(
            IndicatorResearch,
            period1 = range(1, 3),
            period2 = range(15, 18),
            rsibuy = range (30, 35),
            rsisell = range(60, 65),
    )

It fails after several minutes when more variations are introduced:

strats = cerebro.optstrategy(
            IndicatorResearch,
            period1 = range(1, 15),
            period2 = range(15, 25  ),
            rsibuy = range (16, 46),
            rsisell = range(56, 76),
    )

When it fails the errors I get for each pool worker are:

Process ForkPoolWorker-2:
Traceback (most recent call last):
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/usr/lib/python3.10/multiprocessing/queues.py", line 377, in put
    self._writer.send_bytes(obj)
  File "/usr/lib/python3.10/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/usr/lib/python3.10/multiprocessing/connection.py", line 404, in _send_bytes
    self._send(header)
  File "/usr/lib/python3.10/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/usr/lib/python3.10/multiprocessing/queues.py", line 377, in put
    self._writer.send_bytes(obj)
  File "/usr/lib/python3.10/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/usr/lib/python3.10/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/usr/lib/python3.10/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe

I'm having trouble understanding what connection is failing, all file reading occurs on the local drive and results are added to the local PostgreSQL database on the Orange Pi 5 Plus.

Thanks.

I've tried variations of indicators and how many variations are tested for the optimization results.

I'm expecting the script to process and add the results to the database, no results make it to the database as it errors out before that step occurs.

Thanks.

0

There are 0 answers