Overall Statistics
Total Trades
623
Average Win
0.01%
Average Loss
-0.01%
Compounding Annual Return
-88.503%
Drawdown
0.800%
Expectancy
-0.249
Net Profit
-0.591%
Sharpe Ratio
-11.225
Loss Rate
70%
Win Rate
30%
Profit-Loss Ratio
1.54
Alpha
-1.489
Beta
-1.999
Annual Standard Deviation
0.066
Annual Variance
0.004
Information Ratio
-3.74
Tracking Error
0.1
Treynor Ratio
0.372
Total Fees
$623.00
using QuantConnect.Data;
using QuantConnect.Data.Market;
using QuantConnect.Securities;
using System;
using System.Collections.Generic;
using QuantConnect.Orders;
using QuantConnect.Securities.Interfaces;
using QuantConnect.Interfaces;
using QuantConnect.Indicators;
using QuantConnect.Scheduling;

namespace QuantConnect.Algorithm.CSharp
{
    public class Test : QCAlgorithm
    {
        public override void Initialize()
        {
            //backtest prepare
            SetStartDate(2016, 10, 28);
			SetEndDate(2016, 10, 29);
            
            SetCash(100000);             //Set Strategy Cash

            AddEquity("AMZN", Resolution.Second,Market.USA);

            Chart plotter = new Chart("Plotter", ChartType.Overlay);
			plotter.AddSeries(new Series("AMZN", SeriesType.Line));
			plotter.AddSeries(new Series("Buy", SeriesType.Scatter));
			plotter.AddSeries(new Series("Sell", SeriesType.Scatter));
		
			AddChart(plotter);

        }

        public override void OnData(Slice data)
        {
        	Random random = new Random();
        	int num = random.Next(1, 100);
        	Boolean doAction = num%3==0;
        	
            foreach (String symbol in data.Keys)
            {

				if ( !Portfolio.Invested && doAction)
                {
                    SetHoldings( "AMZN" , 0.25 );
                    
                }
                
                else if ( Portfolio.Invested && doAction)
                {
                    Liquidate();
				}
            }
            
            Plot("Plotter", "AMZN", Securities["AMZN"].Price);
        }
        
        public override void OnOrderEvent(OrderEvent orderEvent)
        {
            var order = Transactions.GetOrderById(orderEvent.OrderId);
            decimal _FillPrice = orderEvent.FillPrice;
			
			
			if (orderEvent.FillQuantity > 0 && _FillPrice > 0)
            {

				Plot("Plotter", "Buy", _FillPrice);
				
            }
            else if (orderEvent.FillQuantity < 0 && _FillPrice > 0)
            {
            	Plot("Plotter", "Sell", _FillPrice);
            
            }
        }
        
        public override void OnEndOfDay()
        {
            try
            {
                
            }
            catch (Exception err)
            {
                Error("OnEndOfDay Err:" + err.Message);
            }
        }
    }
}