Оценка качества стратегии¶
Другие статистики¶
def print_stat(stat):
"""Prints selected statistical key indicators:
- the global Sharpe ratio of the strategy;
- the global mean profit;
- the global volatility;
- the maximum drawdown.
Note that Sharpe ratio, mean profit and volatility
apply to max simulation period, and not to the
rolling basis of 3 years.
"""
days = len(stat.coords["time"])
returns = stat.loc[:, "relative_return"]
equity = stat.loc[:, "equity"]
sharpe_ratio = qnstats.calc_sharpe_ratio_annualized(
returns,
max_periods=days,
min_periods=days).to_pandas().values[-1]
profit = (qnstats.calc_mean_return_annualized(
returns,
max_periods=days,
min_periods=days).to_pandas().values[-1])*100.0
volatility = (qnstats.calc_volatility_annualized(
returns,
max_periods=days,
min_periods=days).to_pandas().values[-1])*100.0
max_ddown = (qnstats.calc_max_drawdown(
qnstats.calc_underwater(equity)).to_pandas().values[-1])*100.0
print("Sharpe Ratio : ", "{0:.3f}".format(sharpe_ratio))
print("Mean Return [%] : ", "{0:.3f}".format(profit))
print("Volatility [%] : ", "{0:.3f}".format(volatility))
print("Maximum Drawdown [%] : ", "{0:.3f}".format(-max_ddown))
Вызовем функцию из предыдущего примера
print_stat(data, weights)
Sharpe Ratio : 0.902
Mean Return [%] : 18.294
Volatility [%] : 20.276
Maximum Drawdown [%] : 31.493