Overall Statistics
using NodaTime;

namespace QuantConnect 
{   
    /*
    *   Demonstration of Problem on data timing when plotting in the "cloud" Vs 
    *   desktop
    */
    public class DataTimingProblem : QCAlgorithm
    {
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize()
        {
            string _co = "CO";

            //Start and End Date range for the backtest:
            SetStartDate(2016, 07, 26);
            SetEndDate(2016, 07, 28);

            //Cash allocation
            SetCash(25000);

            //Add as many securities as you like. All the data will be passed into the event handler:
            AddData<RCL>(_co);

            var stockPlot = new Chart("Market Price Plot");
            var assetPrice = new Series("Price", SeriesType.Line, 0);
            var rcCA1 = new Series("C1");

            stockPlot.AddSeries(assetPrice);

            AddChart(stockPlot);
        }

        //
        public void OnData(TradeBars data)
        {
            //
        }

        // Event handler
        public void OnData(RCL data)
        {
            Plot("Market Price Plot", "Price", data.Value);
            Log(string.Format("{0} -> {1}: ${2}", data.Time, data.Symbol, data.Value));
        }

        public class RCL : BaseData
        {
            public decimal CL = 0; // only one field

            public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLive)
            {
                var url = "https://dl.dropboxusercontent.com/u/1049831/For_QC/rcoil20160727to28.csv";
                return new SubscriptionDataSource(url, SubscriptionTransportMedium.RemoteFile);
            }

            public override BaseData Reader(SubscriptionDataConfig config, string line, System.DateTime date, bool isLive)
            {
                var rcBar = new RCL() { Symbol = config.Symbol };

                try
                {
                    var data = line.Split(',');

                    rcBar.Time = DateTime.ParseExact(data[0], "yyyy-MM-dd HH:mm:sszz", CultureInfo.InvariantCulture)
                        .ConvertFromUtc(TimeZones.Chicao);

                    // Parse data
                    // For simplicity, only parse one column of data as example
                    rcBar.CL = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture);
                    rcBar.Value = rcBar.CL;
                }
                catch
                { }
                return rcBar;
            }
        }
    }
}