Overall Statistics
Total Trades
1
Average Win
16.6%
Average Loss
0%
Compounding Annual Return
13.973%
Drawdown
9.100%
Expectancy
0
Net Profit
16.603%
Sharpe Ratio
1.162
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
0.006
Beta
0.973
Annual Standard Deviation
0.113
Annual Variance
0.013
Information Ratio
0.113
Tracking Error
0.027
Treynor Ratio
0.135
namespace QuantConnect 
{   
    /*
    *   QuantConnect University: Tick Template Algorithm
    *
    *   Tick data has its own event handler since the data format is very different to typical tradebars. 
    *   This algorithm demonstrates processing tick events/
    *
    *   Tick data is every single trade which occurred. It is much much more data and therefore roughly 100x slower.
    */
    public class TickTemplateAlgorithm : QCAlgorithm
    {
        public override void Initialize()
        {
            SetStartDate(2014, 1, 1);         
            SetEndDate(DateTime.Now.Date.AddDays(-1)); 
            
            //Cash allocation
            SetCash(25000);
            
            //Add as many securities as you like. All the data will be passed into the event handler:
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Tick);
        }

        //Tick Data Event Handler
        public void OnData(Ticks data) 
        {   
            // A "Ticks" object is a string indexed, collection of LISTS. Each list 
            // contains all the ticks which occurred in that second. 
            //
            // In backtesting they are all timestamped to the previous second, in 
            // live trading they are realtime and stream in one at a time.
             
            List<Tick> spyTicks = data["SPY"];
            
            if (!Portfolio.HoldStock) 
            {
                int quantity = (int) Math.Floor(Portfolio.Cash / spyTicks[0].Price);
                Order("SPY",  quantity);
                Debug("Purchased SPY on " + Time.ToShortDateString());
            }
        }
    }
}