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,
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!