Overall Statistics
namespace QuantConnect
{
    /// <summary>
    /// Basic template algorithm simply initializes the date range and cash
    /// </summary>
    public class DailyIdentityAlgorithm : QCAlgorithm
    {
        private List<DailyBar> _dailyBars;

        /// <summary>
        /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
        /// </summary>
        public override void Initialize()
        {
            SetStartDate(DateTime.Now.AddMonths(-1));   //Set Start Date
            SetEndDate(DateTime.Now.AddDays(-1));       //Set End Date
            SetCash(100000);                            //Set Strategy Cash
            // Find more symbols here: http://quantconnect.com/data
            AddEquity("SPY", Resolution.Minute);
            AddEquity("AIG", Resolution.Minute);
            AddEquity("BAC", Resolution.Minute);
            AddEquity("IBM", Resolution.Minute);

            _dailyBars = new List<DailyBar>();

            foreach (var security in Portfolio.Securities)
            {
                var symbol = security.Key;
                _dailyBars.Add(new DailyBar(symbol,
                    Identity(symbol, Resolution.Daily, Field.Open),
                    Identity(symbol, Resolution.Daily, Field.High),
                    Identity(symbol, Resolution.Daily, Field.Low),
                    Identity(symbol, Resolution.Daily, Field.Close)));
            }
        }

        /// <summary>
        /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
        /// </summary>
        /// <param name="data">Slice object keyed by symbol containing the stock data</param>
        public override void OnData(Slice data)
        {
            if (!Portfolio.Invested)
            {
                SetHoldings("SPY", 1);
                Debug("Purchased Stock");
            }

            Debug(Environment.NewLine + string.Join(Environment.NewLine, _dailyBars.Select(x => x.ToString())));
        }
    }
    public class DailyBar
    {
        private Identity _open;
        private Identity _high;
        private Identity _low;
        private Identity _close;
        public Symbol Symbol { get; private set; }
        public decimal Open { get { return _open; } }
        public decimal High { get { return _high; } }
        public decimal Low { get { return _low; } }
        public decimal Close { get { return _close; } }
        public DateTime EndTime { get { return IsReady ? _close.Current.EndTime : DateTime.MinValue; } }
        public bool IsReady { get { return _close.IsReady; } }

        public DailyBar(Symbol symbol, Identity open, Identity high, Identity low, Identity close)
        {
            Symbol = symbol;
            _open = open;
            _high = high;
            _low = low;
            _close = close;
        }

        public override string ToString()
        {
            return IsReady
                ? string.Format("{0} {1} -> O: {2:0.00} H: {3:0.00} L: {4:0.00} C: {5:0.00}", EndTime, Symbol, Open, High, Low, Close)
                : Symbol.ID + " is not ready";
        }

    }
}