Im trying to string together basic core modules in order to achieve having a coarse universe able to scan during premarket and regular market hours. For alpha creation, I'm basing signals off ema crossovers, which I can make into a ribbon later. For execution Im trying to use vwap seeking execution model, Although I do not currently have any risk management, I was going to try and have a trailing stop loss based off price. Im using this combination because a stripped down alpha creation when backtesting with manual equity selection I was able to have a compounding annual return over 1000% which from my research having premarket scanning and trading will greatly improve this. Im currently stuck with this error code and cannot find a solution so any help with the code to fix this would be fantastic!
Error :
Algorithm.Initialize() Error: Loader.TryCreatePythonAlgorithm(): Unable to import python module ./cache/algorithm/main.pyc. AlgorithmPythonWrapper(): Please ensure that one class inherits from QCAlgorithm or QCAlgorithmFramework. Try re-building algorithm. Stack Trace: at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x00061] in <2caed54565be465db25fe6e7c00ef877>:0
at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath) [0x000e9] in <2caed54565be465db25fe6e7c00ef877>:0 (Open Stacktrace)
Trey Spethman
Having a similar issue, if one of the developerrs could take a look at this, it would be greatly appreciated.
Josh Parchen
I'm dealing with a similar issue and help would be appreciated from anyone. Thanks
Gurumeher Sawhney
Super cool you're getting into the framework! It looks like you've got everything except the primary algorithm which joins them together. The BasicTemplateFramework algorithm demonstrates these setters for telling LEAN what models to use so you need to add the class. In the back test below you can check out class BasicTemplateFrameworkAlgorithm(QCAlgorithmFramework). This is the part of the framework that was missing. You can see how it initializes the classes (models) that were chosen above.
Ben Newsom
Thank you !
Is using framework the best option for what I am trying to do?
Gurumeher Sawhney
The algorithm framework gives a defined structure for designing strategies. This strategy in specific has enough complexity where the framework helps break it down. And since universe selection seems to be a critical part of the algorithm you can focus more on as a result of the framework.
Grimreaper
Hi Gurumeher, Instead of copying the entire implementation, can't I just inherit the function and then only implement the menthods that I want different from the base class?
Daniel Chen
Hi Grimreaper,
Sorry for the late reply. We are glad to tell you it is possible in QC. For the existing models in QC, like NullRiskManagementModel, you can just use them without copying all the implementation. Only the models designed for your algorithm should be included in the code.
Let me give you one example of how I combine existing models and my custom model. In this example, I use four existing models and don't need to copy the implementation of them in my algorithm. On the other hand, I build a custom alpha model (AssetClassTrendAlphaModel) designed for my own strategy, and I need to include it in the code. Also, I need to follow the structure of alpha model, which means I should update my alpha model in *Update()* method and handle security changes in *OnSecuritiesChanged()* method. All of these are easy to implement as long as we follow the structure of Algorithm Framework. Please check here to get more information on Alpha Model.
We hope you enjoy the convenience and efficiency brought by Algorithm Framework. It's easy to learn. If you have more time, we recommend you read through the documentation of this framework. Thank you!
Ben Newsom
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!