Back

Specifying only the front month futures contract

I'm experimenting with the BasicTemplateFuturesHistoryAlgorithm example. I'm using a live Interactive Brokers connection and it seems to be working well. I'm just wondering how to specify to only receive updated for the current front month contract? E.g. i'd like to only receive CLQ18

Currently i'm seeing output like this;

20180626 14:50:00.001 Trace:: Log: CLF19,Bid=66.77 Ask=66.79 Last=66.65 OI=13953
20180626 14:50:00.001 Trace:: Log: CLQ18,Bid=70.8 Ask=70.81 Last=70.8 OI=217338
20180626 14:50:00.005 Trace:: Log: CLU18,Bid=69.51 Ask=69.52 Last=69.52 OI=247271
20180626 14:50:00.008 Trace:: Log: CLV18,Bid=68.34 Ask=68.35 Last=68.35 OI=71017
20180626 14:50:00.013 Trace:: Log: CLX18,Bid=67.71 Ask=67.73 Last=67.74 OI=30568
20180626 14:50:00.018 Trace:: Log: CLZ18,Bid=67.23 Ask=67.25 Last=67.24 OI=285264

Update Backtest







Okay so after a bit of experimentation i found that by not specifying any type of filter on the contract i could get the front month ticks. E.g.

private const string RootWTI = Futures.Energies.CrudeOilWTI;
public Symbol WTI = QuantConnect.Symbol.Create ( RootWTI, SecurityType.Future, Market.USA;

public override void Initialize() {
        var futureWTI = AddFuture ( RootWTI, Resolution.Tick );

...

}

0

Update Backtest





0

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.


Loading...

This discussion is closed