Back to Community
Multi-Day Holding Periods

I believe that I might have an idea on how to capture performance realistically for multi-day holding periods for a daily factor. For example, if you wanted to capture 21-day holding period performance on a factor of a factor that was refreshed each day, you would take your hypothetical portfolio and divide into 21 slices. You would rebalance one slice each day for 21 days. The return for tomorrow would be the average of tomorrow's returns for each of the 21 slices created over the period from 21 days ago though yesterday.

Has anyone tried this approach or have any ideas on how I might do this.

Regards, Eric

2 responses

Take a look at Alphalens. It might do what you're looking for. That tool was developed to analyze factor performance. Check it out

Attached is an example of how one would get the 21 (business) day forward returns of an arbitrary factor.

Maybe also look at Thomas Wiecki's post on some recent updates

Loading notebook preview...

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.

@Eric Remole -- I do this.

The way I've sorted out for doing this is I keep a list of rolling portfolios context.rolling_portfolios = [] and use context.rolling_portfolios.pop(0) once the list exceeds my desired holding period, which gets rid of the oldest portfolio. . I use todays_weights = opt.calculate_optimal_portfolio(... and append the result to the list of rolling portfolios context.rolling_portfolios.append(todays_weights). Then I average them all together and feed the combined weights into calculate_optimal_portfolio().

In addition, I once posted a couple kind of hacky ways to adjust the weights of the previous rolling portfolios by the amount each stock had gained since. That way if on Monday you wanted a weight of 1% for SHOP, but by Friday SHOP had increased 20%, you wouldn't be rebalancing that slice back to 1%, you'd be rebalancing it to 1.2% (no change), thereby reducing needless churn and staying true to the intended holding period. I couldn't figure out an ideal way to do this on Quantopian (one method fails if the stock has splits or dividends and the other fails if there are any half-days between the current date and the slice).

If anybody has better methods for doing this, I'd love to see it.