Skip to content

Commit 56681cf

Browse files
Apply Commissions to PnL.
1 parent 590dee7 commit 56681cf

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

backtesting/backtesting.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,12 @@ def is_short(self):
671671

672672
@property
673673
def pl(self):
674-
"""Trade profit (positive) or loss (negative) in cash units."""
674+
"""
675+
Trade profit (positive) or loss (negative) in cash units.
676+
Commissions are reflected only after the Trade is closed.
677+
"""
675678
price = self.__exit_price or self.__broker.last_price
676-
return self.__size * (price - self.__entry_price)
679+
return (self.__size * (price - self.__entry_price)) - self._commissions
677680

678681
@property
679682
def pl_pct(self):

0 commit comments

Comments
 (0)