@@ -117,11 +117,11 @@ def _round_timedelta(value, _period=_data_period(index)):
117
117
118
118
# Our Sharpe mismatches `empyrical.sharpe_ratio()` because they use arithmetic mean return
119
119
# and simple standard deviation
120
- s .loc ['Sharpe Ratio' ] = np . clip (( s .loc ['Return (Ann.) [%]' ] - risk_free_rate ) / (s .loc ['Volatility (Ann.) [%]' ] or np .nan ), 0 , np . inf ) # noqa: E501
120
+ s .loc ['Sharpe Ratio' ] = ( s .loc ['Return (Ann.) [%]' ] - risk_free_rate ) / (s .loc ['Volatility (Ann.) [%]' ] or np .nan ) # noqa: E501
121
121
# Our Sortino mismatches `empyrical.sortino_ratio()` because they use arithmetic mean return
122
- s .loc ['Sortino Ratio' ] = np . clip (( annualized_return - risk_free_rate ) / (np .sqrt (np .mean (day_returns .clip (- np .inf , 0 )** 2 )) * np .sqrt (annual_trading_days )), 0 , np . inf ) # noqa: E501
122
+ s .loc ['Sortino Ratio' ] = ( annualized_return - risk_free_rate ) / (np .sqrt (np .mean (day_returns .clip (- np .inf , 0 )** 2 )) * np .sqrt (annual_trading_days )) # noqa: E501
123
123
max_dd = - np .nan_to_num (dd .max ())
124
- s .loc ['Calmar Ratio' ] = np . clip ( annualized_return / (- max_dd or np .nan ), 0 , np . inf )
124
+ s .loc ['Calmar Ratio' ] = annualized_return / (- max_dd or np .nan )
125
125
s .loc ['Max. Drawdown [%]' ] = max_dd * 100
126
126
s .loc ['Avg. Drawdown [%]' ] = - dd_peaks .mean () * 100
127
127
s .loc ['Max. Drawdown Duration' ] = _round_timedelta (dd_dur .max ())
@@ -137,6 +137,8 @@ def _round_timedelta(value, _period=_data_period(index)):
137
137
s .loc ['Profit Factor' ] = returns [returns > 0 ].sum () / (abs (returns [returns < 0 ].sum ()) or np .nan ) # noqa: E501
138
138
s .loc ['Expectancy [%]' ] = returns .mean () * 100
139
139
s .loc ['SQN' ] = np .sqrt (n_trades ) * pl .mean () / (pl .std () or np .nan )
140
+ win_prob = (pl > 0 ).sum () / n_trades
141
+ s .loc ['Kelly Criterion' ] = win_prob - (1 - win_prob ) / (pl [pl > 0 ].mean () / pl [pl < 0 ].mean ()) # noqa: E501
140
142
141
143
s .loc ['_strategy' ] = strategy_instance
142
144
s .loc ['_equity_curve' ] = equity_df
0 commit comments