Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
I'm new to Quantopian, is it possible to combine strategies in one algo?

My question is whether it is possible to get an algo to do several things in one; for example:

  1. I set up a few technology stocks that I want to keep (defining the stocks) and rebalance those on an ongoing basis
  2. I have a separate part of my portfolio where Invest in long-term blue-chip holdings, reinvesting dividends
  3. I have a volatile part of my portfolio where I chase good deals and strong trends (probably based on moving averages)

Can all of these things be completed in one algo, or is a separate one (and hence a separate IB account) needed for each?

Any information gratefully received!

2 responses

Hi Paul,
The short answer to your question is yes, you can combine multiple algorithms into one and have them all in one IB account. The trickier thing to answer is how to go about it.

The API allows you to use the full capabilities of the Python language, minus a few methods that are blacklisted for security reasons. That means what we can implement is probably limited by our imagination and coding abilities before the the platform. Memory use and getting your algorithm to run fast enough to be called on every market minute could also be a challenge if it's really complicated.

The attached backtest is a rudimentary implementation of the algorithm you described. I made a few strategy classes, gave each one a percent of the account to work with and some stocks. Then, I defined a handle_data function for each one and call them from the main handle_data function. There is no right way to do what you are looking to do, just whatever works for you, hopefully this helps spark your imagination.

Cheers,
David Edwards

David, that's an awesome response, thanks very much. I will use your algo as a basis for some tinkering myself.