Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backtesting/_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ def compute_stats(
'ExitBar': [t.exit_bar for t in trades],
'EntryPrice': [t.entry_price for t in trades],
'ExitPrice': [t.exit_price for t in trades],
'SL': [t.sl for t in trades],
'TP': [t.tp for t in trades],
'PnL': [t.pl for t in trades],
'ReturnPct': [t.pl_pct for t in trades],
'EntryTime': [t.entry_time for t in trades],
'ExitTime': [t.exit_time for t in trades],
'Tag': [t.tag for t in trades],
})
trades_df['Duration'] = trades_df['ExitTime'] - trades_df['EntryTime']
trades_df['Tag'] = [t.tag for t in trades]
commissions = sum(t._commissions for t in trades)
del trades

Expand Down
2 changes: 1 addition & 1 deletion backtesting/test/_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def almost_equal(a, b):

self.assertSequenceEqual(
sorted(stats['_trades'].columns),
sorted(['Size', 'EntryBar', 'ExitBar', 'EntryPrice', 'ExitPrice',
sorted(['Size', 'EntryBar', 'ExitBar', 'EntryPrice', 'ExitPrice', 'SL', 'TP',
'PnL', 'ReturnPct', 'EntryTime', 'ExitTime', 'Duration', 'Tag']))

def test_compute_stats_bordercase(self):
Expand Down
Loading