Overall Statistics Total Trades 51 Average Win 5.97% Average Loss -0.25% Compounding Annual Return 21.553% Drawdown 17.800% Expectancy 15.697 Net Profit 291.012% Sharpe Ratio 1.06 Loss Rate 33% Win Rate 67% Profit-Loss Ratio 24.05 Alpha 0.081 Beta 0.871 Annual Standard Deviation 0.163 Annual Variance 0.027 Information Ratio 0.615 Tracking Error 0.109 Treynor Ratio 0.198 Total Fees \$69.88
```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");
}
}

}
}                        ```