We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0978284 commit 881ddd0Copy full SHA for 881ddd0
backtesting/_stats.py
@@ -38,7 +38,7 @@ def compute_stats(
38
trades: Union[List['Trade'], pd.DataFrame],
39
equity: np.ndarray,
40
ohlc_data: pd.DataFrame,
41
- strategy_instance: 'Strategy',
+ strategy_instance: Strategy | None,
42
risk_free_rate: float = 0,
43
) -> pd.Series:
44
assert -1 < risk_free_rate < 1
@@ -75,7 +75,7 @@ def compute_stats(
75
trades_df['Tag'] = [t.tag for t in trades]
76
77
# Add indicator values
78
- if len(trades_df):
+ if len(trades_df) and strategy_instance:
79
for ind in strategy_instance._indicators:
80
ind = np.atleast_2d(ind)
81
for i, values in enumerate(ind): # multi-d indicators
0 commit comments