Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using multiple source files for algorithms

Is there some way I can split my algorithm source into multiple files? I would like to split all my custom factor code out into a separate file which can be included in each of my projects. That way if I change a factor to fix a bug, I don't have to update it in each algorithm I write.

12 responses

Hi Eliot,

Currently it's not possible for algorithms to share code from a common repository. This has been a request that's come up a few times and I'll add your +1 vote. We build features based on feedback from the community (like yours) and product direction. It's in the queue and when we start working on this, we'll let you know.

thanks,
Alisa

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.

Thanks!

What is the ETA on being able to import separate files into algorithms so we can split code off and share it between our algorithms? For example, I would like to put all my custom factors into a separate file instead of trying to copy/paste all of them between all my test algorithms and trying to keep the changes in sync. It is a management nightmare! The lack of this functionality dramatically reduces the usefulness of the Pipeline API and custom factors.

Going beyond custom factors, I would like to put together a basic class-based algorithm structure I can reuse to quickly write new test algorithms while recycling all my position management and entry/exit code. Again, this is essentially not possible at the moment simply due to the code management nightmare of trying to manually sync up any changes between all the different test algorithms.

In short, the lack of the most basic code management functionality of splitting it out into separate files for inclusion dramatically hinders the use of this platform and basically makes it look like more of a toy / hobby than a real, professional trading algorithm development platform. If I write all the custom factors I use in my algorithms elsewhere and I write the framework for how I execute trades and balance my portfolios, it will easily be around 10,000 lines of code. Do you really expect us to copy 10,000 lines of code from one algorithm to the next every time we want to test something? Do you really expect us to try to keep 10,000 lines of code in sync between multiple test and production algorithms every time we make a change to that framework code or those custom factors? The #1 biggest reason I have not yet transferred my trading algorithms over here and away from the paid service I currently use is because of this issue. The #2 issue is because of the complete lack of almost all useful factors for filtering stocks. Of course #2 can be fixed by me writing all of them myself, which I don't have an issue with. Except, that then requires issue #1 to be fixed.

I would really, really, like to use Quantopian because writing actual code to manage my algorithms would provide far more flexibility than the current system I use. In addition, it's free, where the current system I use is costing me over $2k/yr. But this lack of functionality makes it almost impossible to use it effectively.

Hi Eliot,

There's no ETA right now but I'll +1 the issue and forward your comments along internally. We've been racing to add features and data to the platform, which in turn has increased the potential complexity of algorithms. Improving the development experience is on our list, and it helps when members of the community like you give us this type of feedback as it helps us to prioritize what we should be working on.

Thanks!

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.

@elioy: leverage zipline. That s why i' ve done this. HTH

Hey, I'd like to add my +1 to this as well. I'm currently writing my algorithms in eclipse across multiple files then copy pasting them into quantopian. It's really inconvenient.

+1

+1

+1

+1

Ideally would like to be able to use pycharm

+1