Overall Statistics
Total Trades
18
Average Win
0.00%
Average Loss
0.00%
Compounding Annual Return
0.000%
Drawdown
0.000%
Expectancy
-0.266
Net Profit
0.000%
Sharpe Ratio
-0.711
Probabilistic Sharpe Ratio
1.746%
Loss Rate
56%
Win Rate
44%
Profit-Loss Ratio
0.65
Alpha
-0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.625
Tracking Error
0.301
Treynor Ratio
-9.062
Total Fees
$18.00
Estimated Strategy Capacity
$610000000.00
Lowest Capacity Asset
SPY R735QTJ8XC9X
namespace QuantConnect
{
    public class DailyResolutionOrderTest : QCAlgorithm
    {
        Symbol _symbol;
        OrderTicket _testOrderTicket;
	
        public override void Initialize()
        {
            SetStartDate(2019, 11, 10);
            SetEndDate(2020, 11, 10);

            SetCash(100000000m);

            _symbol = AddEquity("SPY", Resolution.Daily).Symbol;
        }

        /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
        /// Slice object keyed by symbol containing the stock data
        public override void OnData(Slice data)
        {
            if (!data.ContainsKey(_symbol))
            {
                return;
            }

            TradeBar bar = data[_symbol];
            Log($"OnData Event: {this.Time}({this.Time.DayOfWeek}) {bar}");

            if (!this.Portfolio[_symbol].Invested && _testOrderTicket == null)
            {
                decimal stopPrice = bar.Close * 1.02m;
                _testOrderTicket = StopMarketOrder(_symbol, 100, stopPrice);
                return;
            }
            
            if (this.Portfolio[_symbol].Invested && _testOrderTicket != null)
            {
                MarketOrder(_symbol, -100);
                _testOrderTicket = null;
            }
        }
        
        public override void OnOrderEvent(OrderEvent orderEvent)
        {
            Log($"OnOrderEvent: {orderEvent}");
        }
    }
}