Overall Statistics
Total Trades
4
Average Win
0.00%
Average Loss
-5.15%
Compounding Annual Return
-19.258%
Drawdown
24.100%
Expectancy
-1.000
Net Profit
-19.195%
Sharpe Ratio
-1.177
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0.00
Alpha
-0.127
Beta
-0.374
Annual Standard Deviation
0.169
Annual Variance
0.028
Information Ratio
-1.741
Tracking Error
0.223
Treynor Ratio
0.53
using System;
using System.Collections;
using System.Collections.Generic; 
using QuantConnect.Securities;  
using QuantConnect.Models;   

namespace QuantConnect 
{   
    // Name your algorithm class anything, as long as it inherits QCAlgorithm
    public class SynchronousOrderProcessingAlgorithm : QCAlgorithm
    {
        int step = 0;
        
        public override void Initialize()
        {
            SetStartDate(2013, 6, 1);         
            SetEndDate(2014, 5, 30); 
            SetCash(100000);
            AddSecurity(SecurityType.Equity, "MSFT", Resolution.Minute);
            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);
            AddSecurity(SecurityType.Equity, "IBM", Resolution.Minute);
        }
        
        public void OnData(TradeBars data)
        {
            //First Order, Set 50% MSFT:
            if (!Portfolio.Invested)
            {
                SetHoldings("MSFT", 0.5); step++;
            }

            if (Time.Date == new DateTime(2013, 7, 1) && step == 1)
            {
                SetHoldings("MSFT", 1); step++;
            }

            if (Time.Date == new DateTime(2013, 8, 1) && step == 2)
            {
                SetHoldings("IBM", 1, true); step++;
            }

            if (Time.Date == new DateTime(2013, 9, 3) && step == 3)
            {
                SetHoldings("IBM", -0.5, true); step++;
            }

            if (Time.Date == new DateTime(2013, 10, 1) && step == 4)
            {
                SetHoldings("SPY", -0.5); step++; // Fail
            }
            
            if (Time.Date == new DateTime(2013, 11, 1) && step == 5)
            {
                SetHoldings("IBM", -0.5, true);  //Succeed.
                SetHoldings("SPY", -0.5);  step++;
            }
        }
    }
}