Overall Statistics
Total Trades
154
Average Win
7.71%
Average Loss
-4.04%
Compounding Annual Return
2980.571%
Drawdown
33.900%
Expectancy
0.399
Net Profit
180.510%
Sharpe Ratio
3.362
Loss Rate
52%
Win Rate
48%
Profit-Loss Ratio
1.91
Alpha
3.914
Beta
0.27
Annual Standard Deviation
1.175
Annual Variance
1.382
Information Ratio
3.23
Tracking Error
1.181
Treynor Ratio
14.62
Total Fees
$2764.13
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
    {
    	public string ticker = "NUGT";
        //Initialize the data and resolution you require for your strategy:
        public decimal pricePaid = 0;
        
        public override void Initialize() 
        {
			
            //Start and End Date range for the backtest:
            SetStartDate(2016, 1, 4);         
            SetEndDate(DateTime.Now.Date.AddDays(-1));
            
            //Cash allocation
            SetCash(100000);
            
            //Add as many securities as you like. All the data will be passed into the event handler:
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
            AddSecurity(SecurityType.Equity, ticker, 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(TradeBars data) 
        {   
            var currentClose = data[ticker].Close;
            
            if ( data[ticker].EndTime.Hour==9 && data[ticker].EndTime.Minute == 31) {
            	int quantity = (int)Math.Floor(Portfolio.Cash / data[ticker].Close);
            	pricePaid = data[ticker].Close;
                
                //Order function places trades: enter the string symbol and the quantity you want:
                Order(ticker,  quantity);
            }
            
            if ( data[ticker].EndTime.Hour==15 && data[ticker].EndTime.Minute == 45) {
            	Liquidate();
            }
            
            if(currentClose <= pricePaid * 0.95m) {
            	//big drawdown...stop loss.
            	Liquidate();
            }
            
            
        }
        
       
        
    }
}