Overall Statistics
Total Trades
1
Average Win
11.10%
Average Loss
0.00%
Annual Return
22.221%
Drawdown
14.400%
Expectancy
0.000
Net Profit
11.097%
Sharpe Ratio
0.865
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
-0.008
Beta
0.898
Annual Standard Deviation
0.288
Annual Variance
0.083
Information Ratio
-0.134
Tracking Error
0.274
Treynor Ratio
0.277
using System;
using System.Collections;
using System.Collections.Generic; 
using QuantConnect.Securities;  
using QuantConnect.Models;   

namespace QuantConnect { 
    /*************************************************************************** 
        DATA EVENTS: TRADEBAR CLASS
        When you request Second or Minute resolution market data it is pushed 
        into the OnData(TradeBars data) Method on the designated time interval. 
        You must override the base class or an exception will be thrown.
        
        Data is packaged into a TradeBar. It represents a sum of all activity in 
        a period. The TradeBar Class extend the base data class BaseData. It has 
        common properties found in a market-candle: Open, High, Low and Close. 
        We also provide the total volume for the day, and stock symbol of the data
    ***************************************************************************/
    
    public class TradeBarExample : QCAlgorithm
    {
        public override void Initialize()
        {
            AddSecurity(SecurityType.Equity, "MSFT", Resolution.Minute);
            SetCash(50000);
            SetStartDate(2013, 6, 21); 
            SetEndDate(2013, 12, 21); 
        }
       //Second and Minute Resolution Event Handler:
        public void OnData(TradeBars data)
        {
            try
            {
                //If MSFT stock open at a price greater than 44.5, sell all MSFT stocks in portfolio
    	        if (Portfolio.HoldStock && data["MSFT"].Close > 44.5m)
    	        {
                    Order("MSFT", -Portfolio["MSFT"].Quantity);
    	        }
    	        if (!Portfolio.HoldStock && data["MSFT"].Close < 40.01m && Portfolio.Cash > data["MSFT"].Close)
    	        {
                    var quantity = (int)(Portfolio.Cash / data["MSFT"].Close);
                    Order("MSFT", quantity);
    	        }
            }
	        catch(Exception err) 
            {
                Error("OnData Err: " + err.Message);    
            }
        }
    }
}