What are general rules for how to hookup Framework components?

Back

When one hooks up certain Framework Algorithm components using the project creating wizard, it will trade, other times not.

What are some general rules for hooking up these components so that they will trade as intended.

Here I chose some compenents and when I ran a backtest it generated insights but no trading happened with the default project.  By handling events and overriding OnData was able to force some trading but I wasn't sure I had done it correctly.  For example I might be bypassing some of the components.

To try to find out what might be needed to hook them properly up I subclassed all the framework components, overriding whatever methods I could.  

That did not seem to reveal how it should really be hooked up, so I tried hooking up event handlers.

To get some trading to happen I store the insights in a dictionary and then during OnData override I trade on the insights.

I look at the Lean Github repo a lot and update my own fork with tests and examples, and search repeatedly in Visual Studio trying to see how the framework components should hook up, but so far have not got a good idea for how to hook them up to get trading to happen properly.

What thought process should one go through to figure out how to hook framework components up properly, and what is wrong with this example?

Update Backtest








 
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.


I researched my own question and came up with some general rules/thought process for how to go about solving the "no trading" issue when using creating a project using the Framework wizard.

As a beginner you might get discouraged if you use the Framework wizard and end up with no trades, but don't let that stop you.  There is always some explanation, and it is possible to find out why that happens.

Create a new project using Framework wizard that does trade immediately on creation without any changes by watching this 

https://www.youtube.com/watch?v=mBqFEeXANqQ

Then, substitute in the choices, one by one, for ones you really want, and see which ones cause it to stop trading.

If Insights are being created despite the lack of trades, look at the Insights and see what data is included in them.  There I noticed that there was no Weight being included. That was a big clue!

Read the Lean repo code in Github (I Forked it and used Visual Studio), and look for certain things:
Lack of data. e.g. if your Alpha model is not setting the Insight.Weight and your Portfolio balancing/target allocation is expecting Weight to have a value then that could cause "no orders".  It did in my case.

There are other things to look for.  Some overrides are public and some are protected, so there may be more methods that can be overriden.  Some virtual methods might as well be abstract methods because they have no default implementation.

If needed, just copy all the code for a Framework component, rename it and make it your own.  Then you will know exactly what is going on.  In my case I did that and made sure the Alpha model attaches a Weight to each Insight.

Though I didn't run into it with this project there are some Framework components that need some code implemented.  Often there is a callback function parameter one can pass into to one of the contructor overloads.

Is getting 15% CAGR due to overfitting, or is it a legitimate backtest?

0


Hi Kevin,

Thanks for providing a solution to the problem. Indeed, the InsightWeightingPortfolioConstructionModel requires the insights to have a weight assigned while the EqualWeightingPortfolioConstructionModel does not. It's easiest to swap out framework components when we understand what each one does, so we encourage users to review the source code in our GitHub repo.

This strategy has a few parameters, but I don't think there is too much overfitting. One way to detect overfitting is study parameter sensibility. If changing the parameters doesn't change the results too much, there's not too much overfitting.

Best,
Derek Melchin

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.


Update Backtest





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.


Loading...

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!