Overall Statistics
Total Trades
451
Average Win
0.04%
Average Loss
-0.03%
Compounding Annual Return
-16.126%
Drawdown
1.100%
Expectancy
-0.020
Net Profit
-0.176%
Sharpe Ratio
-1.839
Loss Rate
55%
Win Rate
45%
Profit-Loss Ratio
1.20
Alpha
-0.432
Beta
0.458
Annual Standard Deviation
0.06
Annual Variance
0.004
Information Ratio
-12.479
Tracking Error
0.065
Treynor Ratio
-0.24
Total Fees
$525.51
namespace QuantConnect 
{
	public class BasicTemplateAlgorithm : QCAlgorithm
    {
        public override void Initialize()
        {
            SetStartDate(DateTime.Now.Date.AddDays(-5));         
            SetEndDate(DateTime.Now.Date.AddDays(-1));
            
            SetCash(100000);
            
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
        }
        
        public void OnData(TradeBars data) 
        {
        	double[] HistoricalPrice = new double[6];
        	
        	Schedule.On(DateRules.EveryDay(), TimeRules.Every(TimeSpan.FromMinutes(1)), () =>
            	{
            		if (!Portfolio.HoldStock)
            		{
            				var allHistory = History(6, Resolution.Minute);
            				var closeHistory = allHistory.Get("SPY", Field.Close);
            				HistoricalPrice = closeHistory.ToDoubleArray();
            				
            				if(HistoricalPrice[5] > HistoricalPrice[0])
            				{
            					int quantity = (int)Math.Floor((Portfolio.Cash / 2) / data["SPY"].Close);
            					Order("SPY",  quantity);
            					Schedule.On(DateRules.EveryDay(), TimeRules.Every(TimeSpan.FromMinutes(6)), () =>
            					{
            						Liquidate();
            					});
            				}
            		}
            	});
        }
    }
}