Overall Statistics
namespace QuantConnect.Algorithm.CSharp
{
    public class BasicTemplateAlgorithm : QCAlgorithm
    {
        private Symbol _spy = QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA);

        public override void Initialize()
        {
            SetStartDate(2010, 10, 07);  //Set Start Date
            SetEndDate(2018, 02, 02);    //Set End Date
            SetCash(100000);             //Set Strategy Cash

            AddEquity("SPY", Resolution.Daily);
            Securities["SPY"].SetLeverage(2.0M);

            Chart plotter = new Chart("Leverage (actual)");
            plotter.AddSeries(new Series("SPY", SeriesType.Line, "%"));
			plotter.AddSeries(new Series("Total leverage", SeriesType.Line, "%"));
            AddChart(plotter);
        }
        public override void OnData(Slice data)
        {
            if (!Portfolio.Invested)
            {
                SetHoldings(_spy, 2.0M);
                Debug("Purchased Stock");
            }
        }
        
        public override void OnEndOfDay() 
        {
            try 
            {
                Plot("Leverage (actual)", "Total Leverage", (Portfolio.TotalHoldingsValue / Portfolio.TotalPortfolioValue)*100);
                Plot("Leverage (actual)", "SPY", (Securities["SPY"].Holdings.HoldingsValue/Portfolio.TotalPortfolioValue)*100);

            } 
            catch (Exception err) 
            {
                Error("OnEndOfDay Err:" + err.Message);
            }
        }
    }
}