Overall Statistics
Total Trades
263
Average Win
0.05%
Average Loss
-0.05%
Compounding Annual Return
-29.106%
Drawdown
0.900%
Expectancy
-0.034
Net Profit
-0.251%
Sharpe Ratio
-3.51
Loss Rate
51%
Win Rate
49%
Profit-Loss Ratio
0.98
Alpha
-0.195
Beta
-0.775
Annual Standard Deviation
0.06
Annual Variance
0.004
Information Ratio
-2.951
Tracking Error
0.078
Treynor Ratio
0.271
Total Fees
$303.81
namespace QuantConnect 
{
	public class BasicTemplateAlgorithm : QCAlgorithm
    {
    	private DateTime liquidationTime;
	
	    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) 
        {
        	if (!Portfolio.HoldStock)
            {
            	var allHistory = History(6, Resolution.Minute);
            	var closeHistory = allHistory.Get("SPY", Field.Close);
            	var HistoricalPrice = closeHistory.ToDoubleArray();
            				
            	if (HistoricalPrice[5] > HistoricalPrice[0])
            	{
            		SetHoldings("SPY",  0.5m);
            	}
            }
            else
            {
            	if (Time >= liquidationTime)
            	{
            		Liquidate();
            	}
            }
        	
        }
        
        public override void OnOrderEvent(OrderEvent orderEvent)
        {
        	if(orderEvent.Status.IsFill())
        	{
        		liquidationTime = Time.AddMinutes(6);
        	}
        }
    }
}