8000 Include Commissions in _trades DataFrame (#1277) · kernc/backtesting.py@590dee7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 590dee7

Browse files
Include Commissions in _trades DataFrame (#1277)
1 parent cb7c8d6 commit 590dee7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

backtesting/_stats.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def compute_stats(
6767
'SL': [t.sl for t in trades],
6868
'TP': [t.tp for t in trades],
6969
'PnL': [t.pl for t in trades],
70+
'Commissions': [t._commissions for t in trades],
7071
'ReturnPct': [t.pl_pct for t in trades],
7172
'EntryTime': [t.entry_time for t in trades],
7273
'ExitTime': [t.exit_time for t in trades],

backtesting/test/_test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,9 @@ def almost_equal(a, b):
345345
for n in (SmaCross.fast, SmaCross.slow)]
346346
self.assertSequenceEqual(
347347
sorted(stats['_trades'].columns),
348-
sorted(['Size', 'EntryBar', 'ExitBar', 'EntryPrice', 'ExitPrice', 'SL', 'TP',
349-
'PnL', 'ReturnPct', 'EntryTime', 'ExitTime', 'Duration', 'Tag',
348+
sorted(['Size', 'EntryBar', 'ExitBar', 'EntryPrice', 'ExitPrice',
349+
'SL', 'TP', 'PnL', 'ReturnPct', 'EntryTime', 'ExitTime',
350+
'Duration', 'Tag', 'Commissions',
350351
*indicator_columns]))
351352

352353
def test_compute_stats_bordercase(self):

0 commit comments

Comments
 (0)
0