Overall Statistics
namespace QuantConnect 
{   
    /*
    *   QuantConnect University: Generic Quandl Data Importer
    *
    *   Using the underlying dynamic data class "Quandl" we take care of the data 
    *   importing and definition for you. Simply point QuantConnect to the Quandl Short Code.
    *
    *   The Quandl object has properties which match the spreadsheet headers.
    *   If you have multiple quandl streams look at data.Symbol to distinguish them.
    */
    public class QCUQuandlImporter : QCAlgorithm
    {
        string _quandlCode = "YAHOO/INDEX_SPY";
        
        //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(DateTime.Now.Date.AddDays(-1)); 
            
            //Cash allocation
            SetCash(25000);
            
            //Add Generic Quandl Data:
            AddData<Quandl>("YAHOO/INDEX_SPY", Resolution.Minute); 
        }

        //Data Event Handler: New data arrives here. "TradeBars" type is a dictionary of strings so you can access it by symbol.
        public void OnData(Quandl data) 
        {
        	Log("Entered OnData");
            if (!Portfolio.HoldStock) 
            {
                //SetHoldings sets out our cash allocation from +1 to -1; 
                SetHoldings(_quandlCode, 1);
                
                //Debug sends messages to the user console: "Time" is the algorithm time keeper object 
                Debug("Purchased " + _quandlCode + " >> " + Time.ToShortDateString());
            }
        }
    }
}