Been learing Lean for a ~month and I'm a C# developer with 10 year experience.
Did I miss something in tutorials or documentation, but the API surface seems to lack high level functions that just do what you expect without ceremony and glueing things together etc. Don't want to compare with Pine Script, which by language standarts is trash, BUT it's so simple and it (mostly) just works.
What I haven't found in the API surface is a combination that gives me:
1) Indicator on any timeframe - not minute or hour, but 15 minute, 4 hour etc. - without manually writing Consolidators.
2) Automatic RollingWindow for those indicators. I don't need/want to wire it all together, I want to just ask ema50[10] and get my ema50 (15 minute consolidated for example) value 10 bars ago without thinking about it. Use History API behind the scenes, warmup on demand or something.
3) Automatic Warmup of all those things. I don't to specify and look manually how much I need to warm up each of my indicators etc. every time I change the algo.
All these things are reletively easy possible with the API we have, but is very cumbersome to implement and introduces high risk of bugs. I've debugged way too much code to catch errors with lagging indicators by a bar, not warmed up stuff, "Forward only indicator" errors etc.
Unfortunately for efficient algo writing and exploration this is something that I'm building myself, but really wanted to know if I missed something that already exists...
Derek Melchin
Hi Biiiipy Bip,
Thank you for the feedback. We are always working to improve the API.
(1/2) We have open GitHub Issues to have this functionality added. Subscribe to our progress here (#1) and here (#2).
(3) It's possible to enable automatic warmup when using the short-cut methods of indicators (self.SMA instead of SimpleMovingAverage). We just need to add the following line to the Initialize method:
self.EnableAutomaticIndicatorWarmUp = True
See the SmaCrossUniverseSelectionAlgorithm for reference.
Best,
Derek Melchin
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.
Biiiipy Bip
Thank you for the response!
self.EnableAutomaticIndicatorWarmUp = True
This only works when using shorthand indicators methods, and those don't support custom resolutions - 15 minute, 2 hour etc., so in actual usage this is not usable.
Also, a huuuuuge problem with shorthand methods is that "Updated" event can be wired only after the shorthand method return the indicator, and that means it happens only after the WarmUp (if it's enabled), and that breaks the logic, because the indicator will get warmed up, but dependant logic will start functioning only after that, and for me, that breaks manual RollingWindow updating. So, the shorthand methods and Automatic Warmup basically is not usable at all.
Jared Broad
See more on the Indicator Documentation page.
>1) Indicator on any timeframe - not minute or hour, but 15 minute, 4 hour etc.
SMA("SPY", 4, Resolution.Hour) SMA("SPY", 15, Resolution.Minute)
Covered at the very top of the documentation page above.
2) This is the idea behind the .Current property of indicators (and planned .History) but it has not been built yet. I'd welcome your help contributing to the open-source project.
3) Automatic Warmup of all those things
SetWarmup() is pretty simple.
Please take some time and complete Boot Camp, get to know the API and the reasons why some things are the way they are, then would welcome more feedback. Posting like this without reading basic docs will be deleted as unconstructive and against our code of conduct.
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.
Biiiipy Bip
I think you are confusing period with timeframe. You can define 14 period(bar) RSI as you suggested - on a minute or hour resolution - but you can't define 14 period RSI on 15 minute timeframe (using shorthand).
So, as I said, as this is not possible with shorthand methods, that means every indicator has to be manually constructed and registered, and that is unnecesary cumbersome and would be great if could be made better :)
And also, that still leaves the issue with Updated event I described in previous answer.
Don't get me wrong, I'm super grateful for Lean, you are awesome! But I was kind of surprised that the top level API is not that It-Just-Works kind of style, especially that all the peaces are there, it's just the way API is defined...
Biiiipy Bip
>1) Indicator on any timeframe - not minute or hour, but 15 minute, 4 hour etc. SMA("SPY", 4, Resolution.Hour) SMA("SPY", 15, Resolution.Minute)
And I don't see from where you copied that documentation sample, I can't find that, and search also doesn't show any results for that...
Jared Broad
We have many weaknesses and will continue grinding away to make it better.
Automating some things introduces more risk than it benefits the average user, and 98% of people are happy with the flexibility as it is now. The remaining 2% of people who want edge cases can use an additional 1 line of code to get infinite combinations.
This is a copy-paste from the docs; creates +1 line of code.
self.window = RollingWindow[TradeBar](2) self.Consolidate("SPY", timedelta(minutes=45), lambda x: self.window.Add(x))
And with the insight gained from completing Boot Camp:
self.sma = SimpleMovingAverage(10) self.Consolidate("SPY", timedelta(minutes=45), lambda x: self.sma.Update(x.EndTime, x.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.
Biiiipy Bip
Automating some things introduces more risk than it benefits the average user, and 98% of people are happy with the flexibility as it is now. The remaining 2% of people who want edge cases can use an additional 1 line of code to get infinite combinations.
I would say, that I strongly disagree with this. What I'm suggesting is not a edge case or specific need, but a simpler API that sits on top of the existing, amazing, core. All the peaces are there. For example, the shorthand syntax was created for that reason - to simplify the things. It creates the indicator, registers it and can warm it up. Great! Now just add RollingWindow hooks into that (and pass Updated events) and add arbitrary timeframe (15 minute) overloads, and volla. Ideally it would be a coherent structure that hides all that complexity from the user code, but well, working with what we have, this is the biggest improvement that could be made...
Anyway, I'm glad that my thoughts have reached the creators of this great project and hopefully my feedback has been of some use.
Biiiipy Bip
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!