Hi I have the following code (that's just an example) and here is a discrepance that I found..
public class FuturesAlgorithm : QCAlgorithm
{
private Future future;
private List<Symbol> _futureContracts = new List<Symbol>();
private DateTime oldTime = new DateTime (2001, 01, 26);
private FuturesContract contract;
private TradeBarConsolidator consolidator;
private BollingerFuture bb = new BollingerFuture(36, 1.25m);
public override void Initialize()
{
SetStartDate(2018, 05, 12);
SetEndDate(2018, 05, 17);
SetCash(100000);
consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(30));
consolidator.DataConsolidated += OnDataConsolidated;
future = AddFuture("BTC", Resolution.Minute);
future.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(92));
}
public override void OnData(Slice data)
{
foreach(var chain in data.FutureChains)
{
foreach(var cc in chain.Value)
{
Log($"symbol: {cc.Symbol.Value} exp: {cc.Expiry}");
}
}
}
This code will produce the following output:
2018-05-13 18:30:00 symbol: BTCM18 exp: 6/1/2018 12:00:00 AM
2018-05-13 18:30:00 symbol: BTCN18 exp: 7/1/2018 12:00:00 AM
Here:
1) Expiry dates are shifted 1 month backward- BTCM18 for example expires on Jul 1.
2) Despite this, algo will in fact give you data for June and July future. But - for BTC the front futures contract is the nearest - expiring at the end of this month - if there is a way to handle it?
Thanks,
Ilshat Garipov
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!