diff --git a/backtesting/backtesting.py b/backtesting/backtesting.py index 3a331651..f0b67b50 100644 --- a/backtesting/backtesting.py +++ b/backtesting/backtesting.py @@ -671,15 +671,22 @@ def is_short(self): @property def pl(self): - """Trade profit (positive) or loss (negative) in cash units.""" + """ + Trade profit (positive) or loss (negative) in cash units. + Commissions are reflected only after the Trade is closed. + """ price = self.__exit_price or self.__broker.last_price - return self.__size * (price - self.__entry_price) + return (self.__size * (price - self.__entry_price)) - self._commissions @property def pl_pct(self): """Trade profit (positive) or loss (negative) in percent.""" price = self.__exit_price or self.__broker.last_price - return copysign(1, self.__size) * (price / self.__entry_price - 1) + gross_pl_pct = copysign(1, self.__size) * (price / self.__entry_price - 1) + + # Total commission across the entire trade size to individual units + commission_pct = self._commissions / (abs(self.__size) * self.__entry_price) + return gross_pl_pct - commission_pct @property def value(self):