Content-Length: 305265 | pFad | http://github.com/kernc/backtesting.py/pull/1277/commits/7fe36c6711230e8bf253d38205678eda84165368

CB Include Commissions in _trades DataFrame. by abhirathmahipal · Pull Request #1277 · kernc/backtesting.py · GitHub
Skip to content

Include Commissions in _trades DataFrame. #1277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
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
Include Commissions in _trades DataFrame.
  • Loading branch information
abhirathmahipal committed May 27, 2025
commit 7fe36c6711230e8bf253d38205678eda84165368
1 change: 1 addition & 0 deletions backtesting/_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def compute_stats(
'SL': [t.sl for t in trades],
'TP': [t.tp for t in trades],
'PnL': [t.pl for t in trades],
'Commissions': [t._commissions 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],
Expand Down
5 changes: 3 additions & 2 deletions backtesting/test/_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ def almost_equal(a, b):
for n in (SmaCross.fast, SmaCross.slow)]
self.assertSequenceEqual(
sorted(stats['_trades'].columns),
sorted(['Size', 'EntryBar', 'ExitBar', 'EntryPrice', 'ExitPrice', 'SL', 'TP',
'PnL', 'ReturnPct', 'EntryTime', 'ExitTime', 'Duration', 'Tag',
sorted(['Size', 'EntryBar', 'ExitBar', 'EntryPrice', 'ExitPrice',
'SL', 'TP', 'PnL', 'ReturnPct', 'EntryTime', 'ExitTime',
'Duration', 'Tag', 'Commissions',
*indicator_columns]))

def test_compute_stats_bordercase(self):
Expand Down








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/pull/1277/commits/7fe36c6711230e8bf253d38205678eda84165368

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy