Back to Community
Corrections to cumulative risk metrics

Thanks to Jason Swearingen for catching a bug in our headline beta calculation and pointing it out on an earlier thread.

After investigation, we found that there was indeed a bug and the calculation for the cumulative value displayed on the overall results tab was flawed, while the calculation for the shorter period beta values was correct. This was causing the two versions of the same value to skew widely from each other at certain times. We've corrected this issue. In the course of our audit of all the risk metrics we found several other places where our overall risk metrics were not in agreement with the period stats as a result of the same bug.

Below is a summary of the items that were corrected, along with the current logic:

Results Overview headline stats:

  • BETA = cov((r1:ri),(b1:bi)) / var(b1:bi) ; where r1:ri is the time series of daily algorithm returns, and b1:bi is the time series of daily benchmark returns.

  • ALPHA = r_ann - (rf + BETA * (b_ann - rf)) ; where r_ann is the annualized algorithm returns, rf is the risk free rate, and b_ann is the annualized benchmark returns.

  • INFORMATION RATIO = (r_ann - b_ann ) / (stdev(r1:ri) * sqrt(252)) ; denominator is annualized standard deviation of the algorithm returns time series.

  • SHARPE RATIO = (r_ann - rf ) / (stdev(r1:ri) * sqrt(252)) ; denominator is annualized standard deviation of the algorithm returns time series.

Risk Metrics period stats:

  • SORTINO RATIO = (r_ann - rf ) / (DR) ; where DR is than annualized standard deviation of returns below the running average return level.

This update represents the latest in our ongoing efforts to improve the completeness and accuracy of our backtester - we appreciate the continued support and expertise of everyone in the community who uses these tools. As we have done in prior posts here is a link to the Excel file that we use as our "answer key" in our development process to verify the accuracy of our risk metrics.

As always, we try to avoid changes to the backtester. In backtesting, stability and correctness are virtues that are sometimes in conflict. We welcome feedback about how we're balancing them.


The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

1 response

great, good to know this is now fixed!