Overall Statistics
Total Trades
2715
Average Win
0.03%
Average Loss
-0.01%
Compounding Annual Return
38.830%
Drawdown
14.600%
Expectancy
5.580
Net Profit
92.715%
Sharpe Ratio
1.617
Loss Rate
9%
Win Rate
91%
Profit-Loss Ratio
6.25
Alpha
0.336
Beta
0.061
Annual Standard Deviation
0.215
Annual Variance
0.046
Information Ratio
0.623
Tracking Error
0.238
Treynor Ratio
5.665
Total Fees
$2717.68
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 BasicTemplateAlgorithm : QCAlgorithm
    {
    	private readonly List<string> Symbols = new List<string>{"SPY","MSFT"};
    	private readonly Dictionary<string, SymbolData> Data = new Dictionary<string, SymbolData>();
    	
        //Initialize the data and resolution you require for your strategy:
        public override void Initialize() 
        {
			
            //Start and End Date range for the backtest:
            SetStartDate(2013, 1, 1);         
            SetEndDate(2015, 1, 1);
            
            //Cash allocation
            SetCash(25000);
            
            //Add as many securities as you like. All the data will be passed into the event handler:
            foreach (var symbol in Symbols)
            {
            	AddSecurity(SecurityType.Equity, symbol, Resolution.Minute);
            	// create symbol data for each symbol and initialize it
            	Data.Add(symbol, new SymbolData(symbol, this));
            }
        }

        //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 symbolData in Data.Values)
        	{
        		// do something with our symbol data
        		if (symbolData.Security.Close > symbolData.SMA)
        		{
        			SetHoldings(symbolData.Symbol, .75m*symbolData.Security.Leverage/(decimal)Symbols.Count);
        		}
        	}
        }
    }
    
    public class SymbolData
    {
    	public readonly string Symbol;
    	public readonly Security Security;
    	public readonly SimpleMovingAverage SMA;
    	public readonly RateOfChange ROC;
    	
    	public SymbolData(string symbol, QCAlgorithm algorithm)
    	{
    		Symbol = symbol;
    		Security = algorithm.Securities[symbol];
    		var consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(5));
    		SMA = new SimpleMovingAverage(14);
    		ROC = new RateOfChange(14);
    		algorithm.RegisterIndicator(symbol, SMA, consolidator, Field.Close);
    		algorithm.RegisterIndicator(symbol, ROC, consolidator, Field.Close);
    	}
    }
}