Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How do I clone my own algorithm?

It is often productive to write code incrementally: start with something small and simple, make it work if it doesn't already, then make another version with one small change, make that one work, and so on. At the same time, older versions may still be useful. And a well thought out sequence of versions may be a good teaching tool.

I wanted to do that, start with a simple buy-and-hold one-asset strategy, but didn't see a Clone Algorithm button or Save As option in the IDE. Is there a way to fork one's own algorithm with one click? (There should be.)

6 responses

nope: CTRL-C, go to my algorithms, click new algorithm. type New name, goto code, CTRL-A, CTRL-V....

@Peter - I think you mean Ctrl-A (Select All), Ctrl-C (Copy), create a new algorithm (why not Ctrl-N? with a Yes/No/Cancel dialog box asking whether to copy contents?), and Ctrl-V (Paste).

I would have done it, but (I forgot to mention) I'm on a tablet and the Q IDE does not allow me to select, much less copy and paste. There's no Ctrl key either.

@Andre' P., "A" way to version your code is to run a full backtest. The code snapshot is saved with that backtest and you can refer back to it in the future (after you make changes) for reference. There's no way to identify them, aside from date, but you can keep a running history of code changes.

@Market Tech, Good - I didn't know about it, this was not obvious from the IDE. But there should be a way to giving different versions (or backtests) different names reflecting the core properties or parameter values of each.

And what I had in mind was not slightly different versions of the same algorithm, but substantially different algorithms, or algorithm evolutionary trees. These should be considered separate in the storage system. What you propose would have me keep all my code as one "algorithm" with the same name, distinguished only by last modification date.

@Andre', what I "propose" is a hack in file based system that lacks the most rudimentary file versioning or organization. 30 minutes of design time 4 years ago would have alleviated much of this angst.

@Market Tech, It is indeed a helpful hack, a workaround. Thank you for helping out.