Samples.Roll.RollSellSide.OnSubscribe C# (CSharp) Method

OnSubscribe() protected method

protected OnSubscribe ( InstrumentList instruments ) : void
instruments InstrumentList
return void
        protected override void OnSubscribe(InstrumentList instruments)
        {
            // Get size of bar.
            barSize = (long)Global[barSizeCode];

            // Get roll info.
            rollInfo = (List<RollInfo>)Global[rollInfoCode];

            // Get root instrument.
            rootInstrument = instruments.GetByIndex(0);

            // Get current futures contract.
            currentFuturesContract = rootInstrument.Legs[legIndex].Instrument;

            // Add current futures contract to bar factory.
            BarFactory.Add(currentFuturesContract, BarType.Time, barSize);

            // Add current futures contract to strategy.
            AddInstrument(currentFuturesContract);

            // Add reminder to maturity date and roll time.
            AddReminder(rollInfo[legIndex].Maturity.Date + TimeOfRoll);

            AddGroups();
        }