Guess you can only have about 64k characters in an algo?
Mine is about 1300 lines of code and I hit the max characters allowed. Did I go overboard on my strategy? Anyone else have an algo that's super long?
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
Algo hits max character limit, 1300 lines of code. Others share similar experiences.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
My algo is so big it hit the maximum characters allowed! Anyone else have this issue?
David E | David Eldringhoff | February 2023
Guess you can only have about 64k characters in an algo?
Mine is about 1300 lines of code and I hit the max characters allowed. Did I go overboard on my strategy? Anyone else have an algo that's super long?
QuantConnect™ 2025. All Rights Reserved
Jared Broad
1300 isn't bad. Normal “good programming” rules suggest no more than 200 per file. Its easier to debug strategies if you break them into classes / separate files. We found people's huge strategies were making the files difficult to save.
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
David E
Hey Jared, thanks for the comments. I'm by no means a professional coder. I just understand enough to get the job done (barely lol). The forum here has been great, thanks for putting all this together.
I thought I saw somewhere that you can break things down into different tabs or files but its all under the same algo. So could I copy over my bar handlers or option chain providers into a separate file and then my main algo references the other file? Do you have a reference to help walk me through that?
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Non Compete INVESTOR
Is the limit per file? or the sum of all the characters in all the files?
For breaking up your algo I suggest using classes/object oriented programming. You can pass the QCAlgorithm object to other classes by passing self to them in the algo entrypoint, or use a static holder like:
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
David E
I hope its per file and I can open other files. I've had to delete a bunch of my logs just to squeeze in recent adjustments. I need to figure this whole separate files issue out. What I need to find is a simple working algo with multiple files that I can use as an example. I appreciate your code but I'm such an armature that I cant follow how that would allow me to open a separate file up.
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Non Compete INVESTOR
David Eldringhoff
I dont have an example, but I suggest reading some tutorials about Python modules and classes. Then you can just split up your logic into different classes and load them with “import”. My code approaches the problem of “how do i interact with the QCAlgorithm class?”. This is what the algos inherit from. I store that object in a static variable making it accessible to all classes so you don't need to pass it around. Heres an updated version which includes some useful logging logic. Also if your super stuck i know there are some quantconnect coders on upwork (i'm not there, no self promotion here 😊)
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!