Hey guys, is there a way of making a project consolidator/tradebars start on flat times like lets say i have a consolidator for 15 min then i want the data to come in at like lets say for example at 10:00, 10:15, 10:30, 10:45 etc... I need this to happen on paper trading too. I also warmup my indicators with the History function.
When I go live paper trading the handlers are executed at every 15 minutes starting at whatever time the algo went live.
Many thanks.
Alexandre Catarino
Are you familiar with consolidators in Lean/QuantConnect?
public override void Initialize() { //...other initialization... AddEquity("SPY", Resolution.Minute); var consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(15)); consolidator.DataConsolidated += { Debug(Time.ToString() + " > New Bar!"); }; SubscriptionManager.AddConsolidator("SPY", consolidator); }
If you use the overload that takes a TimeSpan (e.g.: TimeSpan.FromMinutes(15)) argument, you will get flat times.
Noel Hernandez
Yes I am using the same code but I am initializing it like
var consolidator = new TradeBarConsolidator(900);
the 900 being seconds.
I will try it with the timespan, the problem is live paper trading stuff gets executed every 15 minutes from whenever the algo was started for example if the algo starts at 10:09 then the next 15 minutes will be 10:24 then 10:39 etc...
Noel Hernandez
that worked beautifully thanks a ton Alex.
Alexandre Catarino
When we use method overload the accepts an integer instead of a TimeSpan, it will count the bars, so it depends on the time of the first bar. Therefore the choice/usage depends on the needs.
Noel Hernandez
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!