Hi
I've been thinking of creating my own Alpha Model that uses an indicator. To get an idea of how to code one I looked through the Strategy Library and found “Ichimoku Clouds in the Energy Sector”, which seemed like a great example.
I wanted to see the list of insights etc so I decided to clone the code and backtest it. But it gave a different result to that shown on the Strategy Library page eg on the Strategy Library page it says Total Trades 11941 and Sharpe Ratio -0.234, but the backtest I ran of the cloned code says Total Trades 7700 and Sharpe Ratio -0.622 (see attached backtest).
I thought it should be identical but it isn't. Why? Is there something wrong with the code?
Derek Melchin
Hi NH,
The algorithm behaves differently when we run it now because the universe of Equities is slightly different than it was when we originally ran the algorithm. We are currently working with the data vendor to resolve the issue.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
NH
Ah, that makes sense. Thanks.
I now have another question with regards to this algorithm. If you could help me out I'd really appreciate it.
I'm confused how Flat insights work in an Alpha Model. I want to create an Alpha Model that is long only. My thinking is that such a model would just emit Up and Flat insights, and when a Flat insight is emitted an existing position would be closed.
I tried to alter the “Ichimoku Clouds in the Energy Sector” algorithm to make it long only. I changed only 1 thing - I changed InsightDirection.Down to InsightDirection.Flat (see attached backtest). I thought this would simply mean that Down insights emitted by the original model would instead be Flat insights with this new version.
But when I backtested it there doesn't seem to be any Flat insights in the list of insights. I'm really puzzled to be honest 🤔
Arthur Asenheimer
Hi,
the following applies:
Therefore, in line 45 of IchimokuCloudCrossOverAlphaModel.py, you have to replace
with
That should fix it.
NH
Thanks Arthur, that fixes it! 😁
I found this in the LEAN API reference:
Is it basically to do with this? In the original algorithm code where it says:
that will call
But because InsightDirection.Flat gives 0 (picture above), that means that (like you said):
So doing it that way isn't right, we gotta use
Because that way we're checking that we've got some kinda value, so value 0 (Flat) gets accepted by “if symbol_data.direction is not None:”
Is my understanding correct? Sorry, I've only just started to learn programming so I'm kinda unsure of stuff 😣
Big thanks to you Arthur, and also Derek. I was confused as f*** a couple of days ago but I think I (kind of?) get it now 😊
Arthur Asenheimer
Yes, your understanding is 100% correct. 👍
NH
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!