Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A variation of Fred Monroe's variation of Henry Brown's permanent portfolio

In this variation the portfolio is balanced every 15 days but instead of always re-balancing each asset to 25% of the portfolio value, if the asset had a positive return over the prior 15 days it is rebalanced at 33% of the total portfolio value and if the return was negative it is rebalanced to 10% with any extra swept into the 'cash' account.

Anyway, the code is a bit sloppy since moving to Python after so much Ruby get's a little annoying. :)

10 responses

Hi @Joe, thanks for sharing your variation. The code looks good to me. I especially like the Asset class - more readable and it made it easy to quickly iterate over a few values for the rebalancing levels. How did you settle on the rebalance levels you have for gainers/losers? It is interesting because the rebalance value is a continuous range (rather than discrete, like the # of days in a moving average). In theory, the rebalance level would be possible to optimize.

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.

Hi @John,

The choices were completely arbitrary. This was my first go with your system, so I just wanted to use something as a baseline and then stretch it a little. just to get a feel for how everything works. My original intention was to in fact build a more complex metric to use as an input to the algorithm and dynamically adjust the rebalance levels based on some sort of weighted view of past performance and recent volatility of the asset class with the intent of trying to make the model react in a more incremental manner during certain times, and more swiftly during others. This is just the first baby step :)..

Oh, and a question. You see that in handle_data, I had to dig into one of the assets to get at the 'current' simulation time (data[context.assets[0].id].datetime). Is that date available directly in the context? It seems to me it should be, so perhaps I haven't found that information yet.

@Joe, actually we didn't think of tucking the current time into the context before you mentioned it. That's a great idea, and I've made a ticket for us to do it.

The data object has a datetime per sid because the minute data is jagged - if a security doesn't trade during a particular minute bar, the data parameter will just keep the most recent minute bar.

Dynamically adjusting the weights sounds awesome. It will be really interesting to see how it affects your algorithms performance during volatile times like 2008, as well as calmer periods like 2004 or 2005.

@John,

It's interesting because this particular algorithm is pretty sensitive to how often you rebalance. If you rebalance every 7 days, or every day for that matter, instead of every 15 days as in the example, it seems to perform substantially worse. I was a little surprised at that and haven't really looked into it yet.

@Joe - does the performance simply degrade with more active trading? Or is the performance erratic with respect to the trading activity?

@John,

There seems to be a sudden drop off when the portfolio is rebalanced more frequently than once a week or so. All of the trials I've run above 7 or 8 seem to result in returns similar to the one I posted. All portfolios balanced more frequently than once a week seem to drop off top about a total 40% return. It seems fishy to me just off-hand, but perhaps there is something wrong with the code so I'm going to investigate the cause when I get a chance.

@joe -Thanks for sharing your handy asset class, much easier to work with then my hacked together script - i will likely use it soon.

over-weighting assets that are performing well is a very nice touch, There are few asset allocation strategies floating around that act similarly and it seems to be a winning approach in a variety of circumstances. This has been a particularly good time frame for that strategy given things like historic multi decade lows in treasury yields.

I notice that max drawdown increased quite a bit, which one would expect for the dramatic increase in return (risk/reward).

It will be great once quantopian has more historical data, results for trading at this frequency aren't very meaningful in a two year window.

I am a fan of portfolio allocation strategies in the minute bar+ time frames and would love to see utility classes that ease implementing and analyzing this kind of trade added to quantopian's toolbox.

you guys might want to experiment with rebalancing triggers other than time. Most PP followers have guidance like rebalance when an asset falls below 15% of the portfolio value, etc.

@Fred - we have data back to 2002, so you should be able to run a 10 year test. However, one of the securities used in the algorithm is GLD, an etf that didn't start trading until 11/19/2004. If you try to run a backtest from 2002, the system will automatically shift the test to start on 11/19/2004. You can turn this off if you need to force a test from 2002, but you will need to keep track of security availability.