Overall Statistics
namespace QuantConnect 
{   
    /*
    *   QuantConnect University: Full Basic Template:
    *
    *   The underlying QCAlgorithm class is full of helper methods which enable you to use QuantConnect.
    *   We have explained some of these here, but the full algorithm can be found at:
    *   https://github.com/QuantConnect/Lean/tree/master/Algorithm
    */
    /// <summary>
    /// Basic template algorithm simply initializes the date range and cash
    /// </summary>
    public class LRP : QCAlgorithm
    {
        //the leverage for each holding
        decimal leverage = 2.5m;
        //the months to perform rebalance
        int[] months = { 3, 6, 9, 12 };

        /// <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(2010, 1, 07);  //Set Start Date
            SetEndDate(2017, 1, 1);    //Set End Date
            SetCash(100000);             //Set Strategy Cash. Should be 3 month T Bills.

            //using etf rather than options
            AddEquity("SPY", Resolution.Daily);
            AddEquity("TLT", Resolution.Daily);
            AddEquity("GLD", Resolution.Daily);

            Schedule.On(DateRules.MonthStart(), TimeRules.AfterMarketOpen("SPY"), () =>
            {
                if (months.Contains(Time.Month))
                {
                    //yearly rebalancing
                    SetHoldings("SPY", 0.5m * leverage);
                    SetHoldings("TLT", 0.4m * leverage);
                    SetHoldings("GLD", 0.1m * leverage);
                    Debug("Rebalance");
                }
            });
        }

        /// <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", 0.5m * leverage);
                SetHoldings("TLT", 0.4m * leverage);
                SetHoldings("GLD", 0.1m * leverage);
                Debug("Purchased Stock");
            }
        }

    }
}