1

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?

Mark
  • 53
  • 1
  • 1
  • 8
  • Trade analyzer will return Total 0 when there are no trades. Make sure you have actual trades in the backtest that are completed. eg: go back to zero. – run-out May 30 '21 at 11:55

0 Answers0