Hi there
I just found the definition/formula of information ratio in zipline seems not consistent.
As in investopia and wikipeida, it should be defined as the ratio between (portfolio returns - benchmark returns) and standard deviation of (portfolio returns - benchmark returns)
In zipline/finance/risk/risk.py, the information_ratio function is formulated accordingly.
def information_ratio(algorithm_returns, benchmark_returns):
"""
Args:
algorithm_returns (np.array-like):
All returns during algorithm lifetime.
benchmark_returns (np.array-like):
All benchmark returns during algo lifetime.
Returns:
float. Information ratio.
"""
relative_returns = algorithm_returns - benchmark_returns
relative_deviation = relative_returns.std(ddof=1)
if zp_math.tolerant_equals(relative_deviation, 0) or \
np.isnan(relative_deviation):
return 0.0
return np.mean(relative_returns) / relative_deviation
But this function is not imported elsewhere
However, in both risk/cumulative.py, and risk/period.py, a information_ratio function is defined and it uses the algorithm volatility instead as the denominator.
def information_ratio(algo_volatility, algorithm_return, benchmark_return):
"""
Args:
algorithm_returns (np.array-like):
All returns during algorithm lifetime.
benchmark_returns (np.array-like):
All benchmark returns during algo lifetime.
Returns:
float. Information ratio.
"""
if zp_math.tolerant_equals(algo_volatility, 0):
return np.nan
# The square of the annualization factor is in the volatility,
# because the volatility is also annualized,
# i.e. the sqrt(annual factor) is in the volatility's numerator.
# So to have the the correct annualization factor for the
# Sharpe value's numerator, which should be the sqrt(annual factor).
# The square of the sqrt of the annual factor, i.e. the annual factor
# itself, is needed in the numerator to factor out the division by
# its square root.
return (algorithm_return - benchmark_return) / algo_volatility
Any reasoning behind this ?