progress bar / ETA during optimization

@tw00000 said in progress bar / ETA during optimization:
Just bumping this again, it seems strange that there's no simple way to find out:
 Estimate of how long your backtest will take
My workaround was to add another variable to backtrader so you can query the total run count for the optimization:
https://github.com/verybadsoldier/backtrader/commit/0018b38c65a5cb25b17c42913ec0838b49feb57d

@vbs said in progress bar / ETA during optimization:
@tw00000 said in progress bar / ETA during optimization:
Just bumping this again, it seems strange that there's no simple way to find out:
 Estimate of how long your backtest will take
My workaround was to add another variable to backtrader so you can query the total run count for the optimization:
https://github.com/verybadsoldier/backtrader/commit/0018b38c65a5cb25b17c42913ec0838b49feb57dGot it  could you explain in a little more detail how I could use this with
tqdm
or some other method ??sorry if I'm being daft!

Create a
tqdm
object using the total runcount from cerebroopt_count_total = cerebro.get_opt_runcount() pbar = tqdm(smoothing=0.05, desc='Optimization', total=opt_count_total) res = cerebro.run()
And use the
optcallback
to callupdate()
on thetqdm
object:c.optcallback(optimization_step) def optimization_step(strategy: bt.Strategy): pbar.update()

I wasn't able to make your code function properly 100%. In my Jupyter runs it was returning some weird stuff.
However, I figured out a simple way to get a progress bar for optimization or nonoptimization runs!
from tqdm import tqdm def __init__(self): self.iteration_progress = tqdm(desc='Total runs', total=(self.datas[0].close.buflen())) def next(self): self.iteration_progress.update() self.iteration_progress.set_description("Processing {} out of {}".format(len(self.datas[0].close), self.datas[0].close.buflen()))