Content-Length: 269654 | pFad | http://github.com/kernc/backtesting.py/commit/56681cf063c05f6a9736cae7b2e4257e8c47635e

41 Apply Commissions to PnL. · kernc/backtesting.py@56681cf · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/kernc/backtesting.py/commit/56681cf063c05f6a9736cae7b2e4257e8c47635e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy