Hello,
I'm a new user of Quantconnect, Python, and programming more generally, so I think this is a pretty fundamental point that i'm missing about control flow. I've taken courses in Python which have noted that the code will be executed top to bottom within the script. I'm struggling to understand how I should be structuring my code such that all functions are called after they are defined.
I've come across numerous examples in QC tutorials where a function is (or seems to be, to my eye) called before it is defined. One such example might be in a line like:
self.AddUniverse(self.CoarseFilter, self.FineFilter)
Which would be placed in the Initialize method, and then “CourseFilter” and “FineFilter” are defined later in the body of code. Would someone please offer an explanation to this?
On a related point, how can I work out which parts of my algorithm can ‘see’ data which has been imported by, say, a History request?
Best,Luke
Louis Szeto
Hi Luke
This is more on the object oriented programming structural framework. Your user interface only needed to fill up very few abstraction codes, while most of the work are encapsulated behind. Yes you'll have to define that first, but the place you do .initialize() method is not the place the codes run at, but just a place for the backend to get your information. Think in this way:
That is a over simplified stuff above, but hope you can have some insight if interested.
Cheers
Louis
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.
Luke Blades
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!