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.
Andrew Hart
We have included more cryptocurrency pairs for trading in both live and paper trading. The following are the cryptocurrency pairs that are now available. Remember that depending on your location, not all pairs may be avialable for live trading, however, all pairs should be available for paper trading.
BTC/USD
BTC/EUR
BTC/GBP
ETH/USD
ETH/BTC
ETH/EUR
LTC/USD
LTC/BTC
LTC/EUR
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.
Barney
class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 10, 01) self.SetEndDate(2017, 10, 23) self.SetCash(10000) self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash) self.AddCrypto("BTCETH", Resolution.Daily) self.Log(format(self.Securities["BTCETH"].Price)) def OnData(self, data): self.Log(format(self.Securities["BTCETH"].Price))
Hello Andrew !For some reason I am not able to acees LTC or ETH markets... Only GDAX
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.
Wayne Adams
Hi!
When using the resesarch notebook I got this error when trying to call
Quantbook.AddCrypto() AttributeError: 'QuantBook' object has no attribute 'AddCrypto'
Is this expected?
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.
Alexandre Catarino
Yes, it is expected, since we haven't included support for crypto-currencies in quantbook yet.
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
Coming later today !
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.
CryptoKing
Still having issues with Consolidators (Trying to consolidate to 3 hour) and a simple SMA strategy .. Anyone?
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.
Liquidgenius
Big thanks to Jared and Andrew for you work on cryptos. Jared, thanks for taking a look at my first crypto algo and providing feedback.
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.
Andrew Hart
All available gdax cryptocurrency pairs are now available for backtesting at tick, second, minute, hour and daily resolutions. Here are the listing dates for each pair available:
BTCEUR: 20150423
BTCGDP: 20161001
BTCUSD: 20141201
ETHBTC: 20160518
ETHEUR: 20170810
ETHUSD: 20160518
LTCBTC: 20161001
LTCEUR: 20170810
LTCUSD: 20161001
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
CryptoKing I just swapped out for minute data and its fine. Also note I used the SMA helper methods not the class names. If you want to use the classes you also need to "Register" the indicator object otherwise it'll never get any data. We're going to fix the hour issue today.
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.
CryptoKing
Jared Broad Thanks that was helpful so primarily the issue was that the "Hourly" Resolution for GDAX was not working?
Appreciate the help there.
Also tried going live with an algo today but says GDAX brokerage is under maintenance. If I were to have a live algo what happens to it while brokerages are under maintenance? Also is there anywhere we can see status of brokerages (for example so I can know when I can and cannot "go live") ?
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
There were 2 issues; hourly data and the SimpleMovingAverage class. Please see the documentation for examples of how to use indicators. There's effectively no difference to using Minute data other than backtest load time but for such a short backtest its basically the same.
You can go live on all brokekrages; not sure where you saw the maintenance notice? Do you mind sending an email with that to support@quantconnect.com -- thanks.
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.
Barney
Did anyone try using the RSI indicator on ETHBTC markets? all the outputs are 0. I feel like this has to do something with the face that prices are between 0 and 1 for example 0.67
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.
Barney
Actually, same situation with ETHUSD. RSI gives value of 0
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
Please attach an example if seeking assistance. RSI is always 0 until IsReady is true. See the indicator algorithms in Documentation for examples.
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.
Barney
class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 10, 01) self.SetEndDate(2017, 10, 20) self.SetCash(10000) self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash) self.security = self.AddCrypto("ETHUSD", Resolution.Hour) self.rsi = self.RSI("ETHUSD",12,MovingAverageType.Simple) def OnData(self, data): self.Log(format(self.rsi.Current.Value))
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.
Andrew Hart
Hey - Thanks for reporting this to us. There was a problem with indicators for crypto securities that has been fixed.
We have also added the quote data for all the crypto pairs we currently support
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.
Farshid Zoghalchi
Hi All,
Andrew Hart mentioned there are quote data available for crypto pairs, does this mean that "all" limit order book data is accessible from withi QC? (or maybe at the best bid/ask?) If yes, how can I access volume at different price levels? (or best bid/ask)
Thanks
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
Farshid Zoghalchi - we only pump through the "NBBO" top of book. I understand the desire for the full book but we currently only use it for spread modelling. We're working on a backtesting L2 quotes feature but its still a few months out as there is limited data availability.
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.
Farshid Zoghalchi
If I am not wrong, one can also use their own data in backtesting. Does
this mean, I can use my own L2 data to backtest strategy?
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.
Matt Alan
Having trouble downloading the crypto data for use offline, is it possible?
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!