Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress bars to backtest.py #423

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update backtest.py
Add progress bars to backtest.py
nathanramoscfa committed Sep 13, 2023
commit 47d322b8d0221ba57ed2ee4af6a028f4bd7a65d7
5 changes: 3 additions & 2 deletions bt/backtest.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
import numpy as np
from matplotlib import pyplot as plt
import pyprind
from tqdm import tqdm


def run(*backtests):
@@ -24,7 +25,7 @@ def run(*backtests):

"""
# run each backtest
for bkt in backtests:
for bkt in tqdm(backtests):
bkt.run()

return Result(*backtests)
@@ -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()