Skip to content

Commit fb7cc7c

Browse files
committed
Added active trades in compute stats
1 parent 589a018 commit fb7cc7c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

backtesting/backtesting.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,8 @@ def _compute_stats(self, broker: _Broker, strategy: Strategy) -> pd.Series:
15331533
'DrawdownDuration': dd_dur},
15341534
index=index)
15351535

1536-
trades = broker.trades
1536+
trades = broker.closed_trades
1537+
active_trades = broker.trades
15371538
trades_df = pd.DataFrame({
15381539
'Size': [t.size for t in trades],
15391540
'EntryBar': [t.entry_bar for t in trades],
@@ -1623,7 +1624,7 @@ def geometric_mean(returns):
16231624
s.loc['_strategy'] = strategy
16241625
s.loc['_equity_curve'] = equity_df
16251626
s.loc['_trades'] = trades_df
1626-
1627+
s.loc['_active_trades'] = active_trades
16271628
s = Backtest._Stats(s)
16281629
return s
16291630

0 commit comments

Comments
 (0)