Overall Statistics
Total Trades
3
Average Win
0%
Average Loss
-1.28%
Compounding Annual Return
-24.104%
Drawdown
2.900%
Expectancy
-1
Net Profit
-2.389%
Sharpe Ratio
-7.552
Loss Rate
100%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
-0.402
Beta
7.151
Annual Standard Deviation
0.035
Annual Variance
0.001
Information Ratio
-8.131
Tracking Error
0.035
Treynor Ratio
-0.037
Total Fees
$3.00
using QuantConnect.Data.Market;
using QuantConnect.Orders;

namespace QuantConnect.Algorithm.CSharp.PrimatLab
{
    public class Issue1 : QCAlgorithm
    {
        private OrderTicket _orderEntry = null;
        private OrderTicket _orderStopLoss = null;
        private OrderTicket _orderStopLoss2 = null;

        public override void Initialize()
        {
            SetStartDate(2018, 1, 1);
            SetEndDate(2018, 2, 1);
            SetCash(100000);
            AddEquity("SPY", Resolution.Daily);
        }

        public void OnData(TradeBars data)
        {
            foreach (var symbol in data.Keys)
            {
                Debug(data[symbol].Time + " : " + data[symbol].Close);
                if (_orderEntry == null)
                {
                    _orderEntry = MarketOrder(symbol, -100, false, "Entry");
                    _orderStopLoss2 = StopMarketOrder(symbol, 100, 278.0m, "StopLoss2");
                }
            }
        }

        public override void OnOrderEvent(OrderEvent orderEvent)
        {
            var order = Transactions.GetOrderById(orderEvent.OrderId);
            if (order.Tag == "Entry" && orderEvent.Status == OrderStatus.Filled)
            {
                Debug("Enter short at " + orderEvent.FillPrice + " set STOPLOSS at 275");
                _orderStopLoss = StopMarketOrder(order.Symbol, order.Quantity, 275.0m, "StopLoss");
            }
            if (order.Tag != "Entry")
                Debug(order.Tag + " " + order.Status.ToString());
        }
    }
}