Overall Statistics
Total Trades
1
Average Win
59.58%
Average Loss
0%
Compounding Annual Return
59.648%
Drawdown
11.700%
Expectancy
0
Net Profit
59.58%
Sharpe Ratio
2.497
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
-0.007
Beta
1.726
Annual Standard Deviation
0.194
Annual Variance
0.038
Information Ratio
2.272
Tracking Error
0.088
Treynor Ratio
0.281
-no value-
using System;
using QuantConnect;
using QuantConnect.Algorithm;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

namespace Sandbox
{
    public class SimpleMovingAverageExample : QCAlgorithm
    {
        private SimpleMovingAverage sma;
        public override void Initialize()
        {
            // set start/end dates of backtest
            SetStartDate(2013, 01, 01);
            SetEndDate(2014, 01, 01);

            // request data
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
            
            // define our 10 period sma
            sma = new SimpleMovingAverage(10);
        }

        private DateTime previous;
        public void OnData(TradeBars data)
        {
            if (!Portfolio.HoldStock)
            {
                SetHoldings("SPY", 1);
            }
            
            TradeBar spy;
            if (data.TryGetValue("SPY", out spy) && spy.Time.Date != previous.Date)
            {
                // pump the daily data into our sma
                sma.Update(spy.Time, spy.Value);

                // plot our s
                Plot("SPY", sma);
                previous = spy.Time;
            }
        }
    }
}