I am trying to run a backtest with backtrader. When I try to print out the result from TradeAnalyzer, I only get this:
===============================================================================
TradeAnalyzer:
-----------------------------------------------------------------------------
- total:
- total: 0
Other analyzers like Sharpe Ratio work. What can I do?
My code:
cerebro.addanalyzer(bt.analyzers.DrawDown)
cerebro.addanalyzer(bt.analyzers.TradeAnalyzer)
cerebro.addanalyzer(bt.analyzers.SharpeRatio)
#cerebro.addanalyzer(bt.analyzers.PyFolio)
cerebro.addstrategy(TestStrategy)
result = cerebro.run()
for each in result[0].analyzers:
each.print()
It seems like TradeAnalyzer is not really "listening" or what could be the problem?