MCPcopy Create free account
hub / github.com/kernc/backtesting.py / run

Method run

backtesting/lib.py:586–604  ·  view source on GitHub ↗

Wraps `backtesting.backtesting.Backtest.run`. Returns `pd.DataFrame` with currency indexes in columns.

(self, **kwargs)

Source from the content-addressed store, hash-verified

584 self._bt_kwargs = kwargs
585
586 def run(self, **kwargs):
587 """
588 Wraps `backtesting.backtesting.Backtest.run`. Returns `pd.DataFrame` with
589 currency indexes in columns.
590 """
591 from . import Pool
592 with Pool() as pool, \
593 SharedMemoryManager() as smm:
594 shm = [smm.df2shm(df) for df in self._dfs]
595 results = _tqdm(
596 pool.imap(self._mp_task_run,
597 ((df_batch, self._strategy, self._bt_kwargs, kwargs)
598 for df_batch in _batch(shm))),
599 total=len(shm),
600 desc=self.run.__qualname__,
601 mininterval=2
602 )
603 df = pd.DataFrame(list(chain(*results))).transpose()
604 return df
605
606 @staticmethod
607 def _mp_task_run(args):

Callers 15

test_MultiBacktestMethod · 0.95
runMethod · 0.45
_mp_task_runMethod · 0.45
test_data_nan_columnsMethod · 0.45
test_data_invalidMethod · 0.45

Calls 5

PoolFunction · 0.85
SharedMemoryManagerClass · 0.85
_tqdmFunction · 0.85
_batchFunction · 0.85
df2shmMethod · 0.80