File tree 2 files changed +4
-4
lines changed
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,8 @@ def _round_timedelta(value, _period=_data_period(index)):
128
128
s .loc ['Max. Drawdown Duration' ] = _round_timedelta (dd_dur .max ())
129
129
s .loc ['Avg. Drawdown Duration' ] = _round_timedelta (dd_dur .mean ())
130
130
s .loc ['# Trades' ] = n_trades = len (trades_df )
131
- s .loc ['Win Rate [%]' ] = np .nan if not n_trades else (pl > 0 ).sum () / n_trades * 100 # noqa: E501
131
+ win_rate = np .nan if not n_trades else (pl > 0 ).mean ()
132
+ s .loc ['Win Rate [%]' ] = win_rate * 100
132
133
s .loc ['Best Trade [%]' ] = returns .max () * 100
133
134
s .loc ['Worst Trade [%]' ] = returns .min () * 100
134
135
mean_return = geometric_mean (returns )
@@ -138,8 +139,7 @@ def _round_timedelta(value, _period=_data_period(index)):
138
139
s .loc ['Profit Factor' ] = returns [returns > 0 ].sum () / (abs (returns [returns < 0 ].sum ()) or np .nan ) # noqa: E501
139
140
s .loc ['Expectancy [%]' ] = returns .mean () * 100
140
141
s .loc ['SQN' ] = np .sqrt (n_trades ) * pl .mean () / (pl .std () or np .nan )
141
- win_prob = (pl > 0 ).sum () / n_trades
142
- s .loc ['Kelly Criterion' ] = win_prob - (1 - win_prob ) / (pl [pl > 0 ].mean () / pl [pl < 0 ].mean ()) # noqa: E501
142
+ s .loc ['Kelly Criterion' ] = win_rate - (1 - win_rate ) / (pl [pl > 0 ].mean () / - pl [pl < 0 ].mean ())
143
143
144
144
s .loc ['_strategy' ] = strategy_instance
145
145
s .loc ['_equity_curve' ] = equity_df
Original file line number Diff line number Diff line change @@ -276,7 +276,7 @@ def test_compute_stats(self):
276
276
'Return [%]' : 414.2298999999996 ,
277
277
'Volatility (Ann.) [%]' : 36.49390889140787 ,
278
278
'SQN' : 1.0766187356697705 ,
279
- 'Kelly Criterion' : 0.7875234266909678 ,
279
+ 'Kelly Criterion' : 0.1518705127029717 ,
280
280
'Sharpe Ratio' : 0.5803778344714113 ,
281
281
'Sortino Ratio' : 1.0847880675854096 ,
282
282
'Start' : pd .Timestamp ('2004-08-19 00:00:00' ),
You can’t perform that action at this time.
0 commit comments