Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
2 Algorithms 1 Portfolio

QUANTOPIAN DOES NOT NATIVELY SUPPORT THIS. AND I'M SURE AS HELL NOT SUGGESTING YOU DO IT.
I needed to run two algorithms together (and didnt feel like copy and pasting everything into one algorithm. That algorithm would be 600 lines long and would just be a mess. also, i needed to deploy this method quickly and this was the fastest way to do so) The way I did so was by telling each to operate @ 50% leverage MAX, then, one algorithm would do:

order_target_value(sec, 2.0/len(context.portfolio.positions) )  

It is live trading right now and doing so with out any issues.
I did this by creating a second account since you cant have two algorithms on one portfolio on the same account.

Why did I do it?
One algorithm returns ~130 % a year since 2011 (its a volatility algorithm)
The other returns ~53% a year since 2003 (the main method is mean reversion but its not just mean reversion)

I wanted to compromise between the two since, while the volatility algorithm may be great, I have no idea how it would have performed in 07,08,09. also, combining the two resulted in a more stable time series.

I will upload its performance through the first week on friday and from there I will try to update monthly.

1 response

This is what I use to trade 5 algo's at once on one account: https://www.quantopian.com/posts/framework-modular-framework-for-trading-algorithms
All you have to do is distill each one of your two algorithms down into a small chunk (only takes 50-100 lines of code each) that generates it's portfolio weights and the framework combines all of the weights from all of the algorithms into one set of buy and sell orders.

Your method will work fine as long as the two algorithms don't trade at the same time and are always filled quickly with liquid stocks but it will be a real pain on live trading where you have to monitor and reconnect each algorithm on a weekly basis