Hey,
I'm looking to create a simple futures strategy that looks at the past (for example) 5 days of data, and uses these 5 Daily TradeBars to determine an entry. One example might be mean reverting - if 5 closes are consecutive highs, then go short, and if consecutive lows, go long. I digress, the problem I'm having is that Futures do not support the Daily data resolution, so I was using a Consolidator to consolidate Minute data into Daily data. I have this working well with my Futures template algo that handles Rollover, but the Consolidator breaks after the 1st rollover. Per the Logs in my attached Backtest (for whatever reason the Backtest dropdown is not showing my latest backtests after refreshing the page etc, will try to attach in the comments):
2019-03-14 14:16:00 : Runtime Error: Consolidators can only be used with a single symbol. The previous consolidated SecurityIdentifier (ES X2U8QNK1AEIP) is not the same as in the current data (ES X5IQJTEKSC8X).
You can see in the logs before this occurs, I remove the subscription, though it seems like multiple concurrent subscriptions is not the error it's concerned about:
2019-03-14 14:15:00 : Subscription REMOVED from consolidator _dailyConsolidator for contract ES15H19
2019-03-14 14:15:00 : list of sorted recent contracts: ES21M19, ES20U19
2019-03-14 14:15:00 : New active contract set to ES21M19
2019-03-14 14:15:00 : Subscription ADDED for consolidator _dailyConsolidator for contract ES21M19
2019-03-14 14:15:00 : Portfolio liquidated.
2019-03-14 14:15:00 : New contract purchased: ES21M19
2019-03-14 14:15:00 : Contract ES21M19 has will have rollover triggered on: 6/20/2019
I looked through the QC forums and found some posts (post 1) (post 2) that rougly discuss futures, consolidators, and rollover, but do not address my problem of using a consolidator for multiple futures contracts as they are rolled over.
Any tips on how I can get Daily data from rolled over futures contracts? Is there a way I can get the QC Consolidator to work for multiple futures contracts in a single backtest, perhaps by some crafty abstraction of the OnDay() event handler?
Austin
I'm just now realizing that QC won't let me share a backtest that contains a runtime error... To reproduce the error, take the attached backtest and un-comment lines 88-89 and lines 129-130.
Austin
I've solved my issue with .. a solution that feels a bit bodgey. I'm not even sure what the name for a "pattern" like this would be, but basically I put the TradeBarConsolidator I was subscribing to inside of a class called ConsolidatorManager whose only property was the TradeBarConsolidator (see the last 5 lines of the code attached in my backtest). I override these ConsolidatorManager's every time my Rollover code sets up a new Front Contract.
This works, but my goal was to create a clean Futures code template that recieves Daily TradeBars that other community members can jump in easily and contribute Futures backtests...
So if anyone has a better idea for how I can get Daily Futures TradeBar data, please let me know. I'll be using this in the meantime to build Daily Futures algos, which I hope to share soon!
Austin
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!