Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.732
Tracking Error
0.279
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
/*
 * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
 * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

using QuantConnect.Interfaces;
using QuantConnect.Indicators;
using System.Collections.Generic;
using QuantConnect.Data.Consolidators;
using QuantConnect.Data.Market;
using QuantConnect.Securities.Future;
using System.Globalization;

namespace QuantConnect.Algorithm.CSharp
{
    /// <summary>
    /// Demonstration of how to rollover futures
    /// </summary>
    /// <meta name="tag" content="renko" />
    /// <meta name="tag" content="indicators" />
    /// <meta name="tag" content="using data" />
    /// <meta name="tag" content="consolidating data" />
    public class TroubleshootFuturesChain : QCAlgorithm
    {
    	private Future SubscribeFuture;

    	/// <summary>
        /// Initializes the algorithm state.
        /// </summary>
        public override void Initialize()
        {
            SetStartDate(2020, 1, 1);
            //SetEndDate(2020, 6, 24);
            SetEndDate(DateTime.Now.Date.AddDays(-1)); // Or use a relative date.
            SetCash(1000000);

            // Subscribe to futures chain
			SubscribeFuture = AddFuture(Futures.Indices.SP500EMini, Resolution.Minute, Market.CME, false, 0m);

			// Filter for contracts from 0 to 180 days
			SubscribeFuture.SetFilter(TimeSpan.FromDays(0), TimeSpan.FromDays(180));
			//myChains.SetFilter(universe => universe.FrontMonth());
		}

		public void OnData(TradeBars myData)
		{
		}
		
        public void OnData(Slice myData)
        {
        	foreach (var chain in myData.FutureChains)
        	{
        		// Sort our contracts in ascending order by expiry
        		var sortedByExpiryContracts = chain.Value.OrderBy(x => x.Expiry).ToList();

				string strDetail = "";  // reset strDetail
				
				foreach (var Contract in sortedByExpiryContracts)
				{
					// Concatenate each contract
					strDetail = strDetail + " " + Contract.Symbol + " " + Contract.Expiry;
				}
				
				Debug(strDetail);
			}
        }
    }
}