Overall Statistics
Total Trades
8
Average Win
0%
Average Loss
0%
Compounding Annual Return
6.359%
Drawdown
17.100%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0.749
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.046
Beta
0.131
Annual Standard Deviation
0.071
Annual Variance
0.005
Information Ratio
-0.012
Tracking Error
0.166
Treynor Ratio
0.405
Total Fees
$8.00
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/QCAlgorithm/blob/master/QuantConnect.Algorithm/QCAlgorithm.cs
    */
    public class AWP : QCAlgorithm
    {
        //List<string> _assets = new List<string>() { "OEF", "IJR", "EFA", "EEM", "IEF", "TLT", "DBC", "GLD" };
        //List<double> _alloc = new List<double>() { 0.18, 0.03, 0.06, 0.03, 0.15, 0.4, 0.075, 0.075 };
        
        TupleList<double, string> _allocations = new TupleList<double, string>
		{
    		{ 0.18, "OEF" },
    		{ 0.03, "IJR" },
    		{ 0.06, "EFA" },
    		{ 0.03, "EEM" },
    		{ 0.15, "IEF" },
    		{ 0.4, "TLT" },
    		{ 0.075, "DBC" },
    		{ 0.075, "GLD" }
		};
        
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize() 
        {
			
            //Start and End Date range for the backtest:
            SetStartDate(2005, 1, 1);
            SetEndDate(DateTime.Now.Date.AddDays(-1));
            
            //Cash allocation
            SetCash(25000);
            
            foreach (var symbol in _allocations)
            {
            	//Add as many securities as you like. All the data will be passed into the event handler:
            	AddSecurity(SecurityType.Equity, symbol.Item2, Resolution.Daily);
            }
        }

        //Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
        public void OnData(TradeBars data) 
        {   
            foreach(var symbol in _allocations)
            {
            	if (!Portfolio[symbol.Item2].HoldStock)
            	{
                	if(data.ContainsKey(symbol.Item2))
                	{
                		SetHoldings(symbol.Item2,  symbol.Item1);
                	}
            	}
            }
        }
        
        //easify list of symbols and allocations
        public class TupleList<T1, T2> : List<Tuple<T1, T2>>
		{
    		public void Add(T1 item, T2 item2)
    		{
        		Add( new Tuple<T1, T2>(item, item2));
    		}
		}
		
    }
}