for anyone else who stumbles across this thread, since some people are still trying to get this working outside of OP's original branch, wanted to pass along the following info:
you can still get this working if you take the BasicTradeStats analyzer class and import it as a custom analyzer of your own.
To do so, follow the steps here to make modular code for backtrader, substituting "analyzers" for "indicators" where necessary: https://backtest-rookies.com/2017/11/01/backtrader-making-modular-code/
Under your extensions folder, create the analyzers.py file (along with init file), and paste the content from the analyzer found here: https://raw.githubusercontent.com/rich-oregan/backtrader/master/backtrader/analyzers/basictradestats.py
Finally, in your code, make sure you have something like the following lines:
# import the file at the top of your code where "BasicTradeStats" is the name of the class from extensions.analyzers import BasicTradeStats # add the strategy to cerebro cerebro.addanalyzer(BasicTradeStats, _name="BasicTradeStats") opt_runs = cerebro.run(maxcpus=1, runonce=False) for run in opt_runs: for strategy in run: # finally, this will print the analyzer print(strategy.analyzers.BasicTradeStats2.print())