Difference between relative_return & mean_return
-
Hello, I would like to ask what is the difference between relative_return & mean_return and what information do these two parameters indicate?
Thank you
-
@illustrious-felice Hello.
The answer to your question is in the documentationhttps://quantiacs.com/documentation/en/user_guide/functional_quality.html
relative_return: the relative daily variation of equity;
mean_return: the annualized mean return of the investment since inception;
You can see how these parameters are calculated here
https://github.com/quantiacs/toolbox/blob/main/qnt/stats.pyFunctions calc_relative_return_np_per_asset, calc_relative_return_np, calc_mean_return
This function calculates the relative return for each asset in a portfolio for each trading day, considering the opening and closing prices, along with adjustments for trading costs and dividends. The relative return for each day is computed as the ratio of the equity value at the end of the day to the equity value at the beginning of the day, minus one.
The calc_mean_return function calculates the daily mean return based on the daily relative returns. It does this by first converting the relative returns to log returns (to normalize the distribution and make it more suitable for statistical analysis), then applying a rolling mean with specified maximum and minimum periods, and finally converting back to relative terms by exponentiation. This approach allows for analyzing the average performance of a trading strategy over different time windows, adjusting for the effects of compounding returns.
def calc_mean_return(relative_return, max_periods=None, min_periods=1, points_per_year=None): """ :param relative_return: daily return :param max_periods: maximal number of days :param min_periods: minimal number of days :return: daily mean return """ if points_per_year is None: points_per_year = calc_avg_points_per_year(relative_return) if max_periods is None: max_periods = len(relative_return.coords[ds.TIME]) max_periods = min(max_periods, len(relative_return.coords[ds.TIME])) min_periods = min(min_periods, max_periods) return np.exp( np.log(relative_return + 1).rolling({ds.TIME: max_periods}, min_periods=min_periods).mean(skipna=True)) - 1
In summary, relative return helps understand the fluctuation and immediate performance of a trading strategy, while mean return offers a broader view of its long-term effectiveness and expected average outcome.
-
@vyacheslav_b Thank you for your response. Can I ask where I can find a list of functions in the qntstat library? I want to calculate volatility, max_drawdown, holding day,...
Thank you so much
-
-
@vyacheslav_b Thank you so much
-
This post is deleted!