Navigation

    Quantiacs Community

    • Register
    • Login
    • Search
    • Categories
    • News
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Difference between relative_return & mean_return

    Support
    3
    6
    193
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • illustrious.felice
      illustrious.felice last edited by

      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

      V 1 Reply Last reply Reply Quote 1
      • V
        Vyacheslav_B @illustrious.felice last edited by

        @illustrious-felice Hello.
        The answer to your question is in the documentation

        https://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.py

        Functions 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.

        illustrious.felice 1 Reply Last reply Reply Quote 0
        • illustrious.felice
          illustrious.felice @Vyacheslav_B last edited by

          @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

          V 1 Reply Last reply Reply Quote 0
          • V
            Vyacheslav_B @illustrious.felice last edited by

            @illustrious-felice Yes

            https://github.com/quantiacs/toolbox/blob/main/qnt/stats.py

            ed11ad2d-d4ea-4e30-b225-c62ca671ffb3-image.png

            illustrious.felice 1 Reply Last reply Reply Quote 0
            • illustrious.felice
              illustrious.felice @Vyacheslav_B last edited by

              @vyacheslav_b Thank you so much

              1 Reply Last reply Reply Quote 0
              • T
                taylorcurran Banned last edited by taylorcurran

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                Powered by NodeBB | Contributors
                • Documentation
                • About
                • Career
                • My account
                • Privacy policy
                • Terms and Conditions
                • Cookies policy
                Home
                Copyright © 2014 - 2021 Quantiacs LLC.
                Powered by NodeBB | Contributors