Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
49.196%
Drawdown
33.100%
Expectancy
0
Net Profit
0%
Sharpe Ratio
1.014
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.094
Beta
2.833
Annual Standard Deviation
0.324
Annual Variance
0.105
Information Ratio
1.115
Tracking Error
0.221
Treynor Ratio
0.116
Total Fees
$0.00
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";
        Security security;
        
        //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(150000);
            
            //Add Generic Quandl Data:
            AddData<Quandl>(_quandlCode, Resolution.Minute, false, 1/.15m);
            
            Debug("Leverage: " + Securities[_quandlCode].Leverage);
        }

        //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) 
        {
            if (!Portfolio.HoldStock) 
            {
            	// Buy $1M  
            	var quantity = (int)(1000000 / data.Price);
                
                Order(_quandlCode, quantity);
                
                //Debug sends messages to the user console: "Time" is the algorithm time keeper object 
                Debug("Purchased " + _quandlCode + " >> " + Time.ToShortDateString());
            }
        }
    }
}