Loving the new support for Futures contracts by the way!
Seem to be having some difficulty hooking the SP500 contract to a 5-minute consolidator though. Has anyone had any luck with this yet?
I've wired it all up the best I could and get this when running back test:
Backtest Error: Error initializing algorithm: Type mismatch found between consolidator and symbol. Symbol: /ES expects type ZipEntryName but tried to register consolidator with input type TradeBar
Levitikon
My attempt to wire up the consolidator
Levitikon
Okay, little strange. I had to create a BackTest in order to share my implementation but in order to run a back test I had to comment out the consolidator.
Jared Broad
Hey Levi, we hacked something together to address this -- we'll add it to the github project for future people searching.
public class BasicFuturesConsolidationAlgorithm : QCAlgorithm { private const string RootSP500 = Futures.Indices.SP500EMini; public Symbol SP500 = QuantConnect.Symbol.Create(RootSP500, SecurityType.Future, Market.USA); private HashSet<Symbol> _futureContracts = new HashSet<Symbol>(); public override void Initialize() { SetStartDate(2016, 08, 17); SetEndDate(2016, 08, 20); SetCash(1000000); var futureSP500 = AddFuture(RootSP500); futureSP500.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(182)); SetBenchmark(x => 0); } public override void OnData(Slice slice) { foreach (var chain in slice.FutureChains) { foreach (var contract in chain.Value) { if (!_futureContracts.Contains(contract.Symbol)) { _futureContracts.Add(contract.Symbol); var consolidator = new QuoteBarConsolidator(TimeSpan.FromMinutes(5)); consolidator.DataConsolidated += OnDataConsolidated; SubscriptionManager.AddConsolidator(contract.Symbol, consolidator); Log("Added new consolidator for " + contract.Symbol.Value); } } } } public void OnDataConsolidated(object sender, QuoteBar quoteBar) { Log("OnDataConsolidated called"); Log(quoteBar.ToString()); } }
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.
Marc Ilgen
This seems to consolidate data for for the first contract it finds for the SP500. But eventually that contract will expire. How do we modify the above code so that it always select the nearest term non-expired contract? Or, how about the nearest contract with at least (say) 10 days until expiration?Â
Michael Manus
take a look at the code here:
https://www.quantconnect.com/forum/discussion/5270/futures-bracket-orders-with-multiple-symbols
Levitikon
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!