Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Trailing 5-year average Return on Invested Capital

I am fairly new here on this site. I would like to try coding an algorithm, such as the one described here: http://www.quant-investing.com/blogs/general/2014/08/21/a-better-alternative-to-the-magic-formula

I can easily get most of the data from the get_fundamentals() call, including calculating the Return on Invested Capital = (EBIT / (Net Working Capital + Net Fixed Assets))

But I am stumped by the question of how I could calculate a 5-year trailing average of this? Any help would be greatly appreciated.

1 response

Here's an example. To convert it to minute mode, you would have to only accept one data point per day, for example if the time is equal to some value. You could also only accept one per week, etc. depending on your preferences.

Now to live trade with it, one way is to do a backtest and compute the 5 year average up to the previous day. Then add that 5 year number into your algorithm, and to compute the new 5 year average for the next day you would do [1259*(5 year average) + 1*(today's average)]/1260. This is only when you have daily information about what you want to take the value of, if you were doing weeks it would be 52*5 for 5 years for instance. There may be an easier way to, others can chime in, but that's one method. Also see here.

Let me know if you have any other questions.

Disclaimer

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.