Overall Statistics
Total Trades
2719
Average Win
0.05%
Average Loss
-0.07%
Compounding Annual Return
-0.776%
Drawdown
12.700%
Expectancy
-0.069
Net Profit
-2.805%
Sharpe Ratio
-0.095
Loss Rate
46%
Win Rate
54%
Profit-Loss Ratio
0.73
Alpha
-0.02
Beta
0.105
Annual Standard Deviation
0.062
Annual Variance
0.004
Information Ratio
-1.079
Tracking Error
0.131
Treynor Ratio
-0.056
Total Fees
$2719.00
namespace QuantConnect 
{   
    /*
    *   QuantConnect University: How do I use a rolling window of data?
    *
    *   Our indicator library is a powerful collection of tools. Included in this collection is 
    *   the rolling window indicator for giving you easy access to a fixed length window of data.
    */
    public class QCURollingWindow : QCAlgorithm
    {
        RollingWindow<TradeBar> _window = new RollingWindow<TradeBar>(3600);
        
        public override void Initialize()
        {
            SetStartDate(2013, 1, 1);         
            SetEndDate(DateTime.Now.Date.AddDays(-1)); 
            SetCash(25000);
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
        }

        public void OnData(TradeBars data) 
        {   
            //Inject data into the rolling window.
            _window.Add(data["SPY"]);
            if (!_window.IsReady) return;
            
            if (_window[0].Close > _window[3599].Close) {
                SetHoldings("SPY", -0.5);
            } else {
                SetHoldings("SPY", 0.5);
            }
        }
    }
}