Back to Community
low-capital conservative algo for Robinhood?

Comments and improvements welcome. --Grant

Clone Algorithm
575
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5699759dfa88d910ff86d844
We have migrated this algorithm to work with a new version of the Quantopian API. The code is different than the original version, but the investment rationale of the algorithm has not changed. We've put everything you need to know here on one page.
There was a runtime error.
10 responses

Bootstrapping reduces the wild swings in allocation caused by using portfolio optimization.

What is bootstrapping?

https://www.quantopian.com/posts/bootstrapping-volatility-standardized-asset-weights

Just ignore everything after the first post, it's rubbish. Bootstrapping is repeatedly re-optimizing with random samples of the data and averaging the results.

Thanks. I'll have to scratch my head about how to apply it to the algo I posted above. I don't see how to randomly sample the minutely returns data. I suppose I could run the optimization more frequently (randomly in time?), and then average? In theory, I could run the optimization 390 times per day for a week, and store all of the results, average them, and update the portfolio weekly. Is this the kind of thing you are talking about? Just smooth everything out, on a rolling basis, with random sampling to cut down on the computation time?

The notebook has code for randomly sampling subsets of returns. If the problem is there are no random generators allowed in quantopian algos, I am not sure how to overcome that.

Random generators are allowed, but you have to use a fixed seed. This way, every time the algo is run as a backtest, the results will be identical. Q has never quite explained why this is necessary, but I figure one reason is for QC, as they make changes to code.

A similar idea that I had some time ago, except that it uses a simple analytical formula resulting from the minimization of the variance of a portfolio of two risky assets.

It only uses an index ETF and a bond, but does not assume that the bond is riskless.

As the market plunges, its volatility increases and the allocation automatically moves into the bond.

It is perhaps interesting that when times are good the average index-to-bond ratio resulting form the optimization is not far from the famed 60/40 rule (in the backest, "beta" is the proportion of the index ETF in the portfolio).

Clone Algorithm
86
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 569b8a029529b911882b8acd
There was a runtime error.

I have a question for you Grant...

...what is this algorithm doing? I'm looking at your code and it's very difficult to see the data (structure and all) let alone the reasoning behind your functions. Could you put me in the right direction, please?

Thanks for your help!

Hello Dylan,

The basic idea is to minimize the variance subject to a constraint. The constraint np.dot(x,ret_norm)-context.eps should be biasing the allocation to stocks with higher values of ret_norm (the mean return divided by its standard deviation), if I haven't botched things up.

In a day or two, maybe I'll re-post with comments. If you don't hear from me, feel free to ping again.

Grant

Backtested it on a more recent timeframe, seems like it still works. Doesn't seem low-risk with that 20% drawdown but the returns look very good.

Clone Algorithm
13
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5981f3194f34264fc510e0bd
There was a runtime error.