Skip to content

Commit

Permalink
Merge pull request #423 from nathanramoscfa/add-tqdm
Browse files Browse the repository at this point in the history
Add progress bars to backtest.py
  • Loading branch information
timkpaine authored Nov 22, 2023
2 parents e74e902 + 38767ce commit 2b4c87b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions bt/backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
from matplotlib import pyplot as plt
import pyprind
from tqdm import tqdm


def run(*backtests):
Expand All @@ -24,7 +25,7 @@ def run(*backtests):
"""
# run each backtest
for bkt in backtests:
for bkt in tqdm(backtests):
bkt.run()

return Result(*backtests)
Expand Down Expand Up @@ -66,7 +67,7 @@ def benchmark_random(backtest, random_strategy, nsim=100):
data = backtest.data.dropna()

# create and run random backtests
for i in range(nsim):
for i in tqdm(range(nsim)):
random_strategy.name = "random_%s" % i
rbt = bt.Backtest(random_strategy, data)
rbt.run()
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def local_file(filename):
keywords="python finance quant backtesting strategies algotrading algorithmic trading",
url="https://github.com/pmorissette/bt",
license="MIT",
install_requires=["ffn>=1.0.0", "pyprind>=2.11"],
install_requires=[
"ffn>=1.0.0",
"pyprind>=2.11",
"tqdm>=4"
],
extras_require={
"dev": [
"cython>=0.25",
Expand Down

0 comments on commit 2b4c87b

Please sign in to comment.