We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c163803 commit cecb18eCopy full SHA for cecb18e
backtesting/backtesting.py
@@ -682,7 +682,11 @@ def pl(self):
682
def pl_pct(self):
683
"""Trade profit (positive) or loss (negative) in percent."""
684
price = self.__exit_price or self.__broker.last_price
685
- return copysign(1, self.__size) * (price / self.__entry_price - 1)
+ gross_pl_pct = copysign(1, self.__size) * (price / self.__entry_price - 1)
686
+
687
+ # Total commission across the entire trade size to individual units
688
+ commission_pct = self._commissions / (abs(self.__size) * self.__entry_price)
689
+ return gross_pl_pct - commission_pct
690
691
@property
692
def value(self):
0 commit comments