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 COMMUNITY
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?
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.
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?
Non Compete
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:
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.
Non Compete
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 😊)
David E
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!