Errata corr.:
@federico-bld said in Discrepancy with PnL in the Stop function vs TradeAnalyzer Net PnL:
def stop(self): # if we're backtesting and out of data, close open positions so they get counted properly. # must be done on the 2nd to last, as market orders wait to get another candle, to execute based on open price. for data in self.datas: if self.getposition(data) and len(data) == data.buflen() - 1 and "live" not in self.environment: logger.debug("Closing open position to conclude backtesting") self.close(data=data)